Score:0

Ansible simple inventory for dhcp hosts in yaml

cn flag

Need a little hint on yaml syntax for a very simple inventory file.

I want to include dhcp range of workstations in a nice inventory file. Regarding the official documentation this could be done but i'm not on the right track Need a little clue.

---
all:
  hosts:
    site0:
      hosts:
        192.168.0.[100:200]
    site1:
      hosts:
        192.168.1.[100:200]
    site2:
      hosts:
        192.164.2.[100:200]
    site3:
      hosts:
        192.168.3.[1.50]

Can someone help me to achieve this ? Thanks

Zeitounator avatar
fr flag
appart from the missing semi-colons at the end of every line with an ip/range in your above file to make it a correct yaml hence a correct yaml ansible inventory, what is the exact problem you are facing ?
infoman33 avatar
cn flag
Hi thanks for your help. I added the semicolon. Still i have this error : `site0 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname site0: Name or service not known", "unreachable": true } `
Zeitounator avatar
fr flag
Sorry typo in my first message, I should have written "colons". Meanwhile, veryfing your file with `yamllint` and/or `ansible-lint` and/or `ansible-inventory` should give you a direct clue.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.