using ansible 2.2.1.0, a dynamic inventory script will leave out hosts that 
are not in a group, unless you list them in hosts. should this be fixed in 
the docs? is there a better way?

#!/bin/sh

cat <<EOF
{
  "red": {
    "hosts": [
      "alpha",
      "bravo"
    ]
  },
  "_meta": {
    "hostvars": {
      "alpha": {
        "ansible_host": "192.168.0.1"
      },
      "bravo": {
        "ansible_host": "192.168.0.2"
      },
      "charlie": {
        "ansible_host": "192.168.0.3"
      },
      "delta": {
        "ansible_host": "192.168.0.4"
      }
    }
  }
}
EOF


$ ansible all --list-hosts
  hosts (2):
    alpha
    bravo

adding a hosts list fixes it,

#!/bin/sh

cat <<EOF
{
  "hosts": [
    "alpha",
    "bravo",
    "charlie",
    "delta"
  ],
  "red": {
    "hosts": [
      "alpha",
      "bravo"
    ]
  },
  "_meta": {
    "hostvars": {
      "alpha": {
        "ansible_host": "192.168.0.1"
      },
      "bravo": {
        "ansible_host": "192.168.0.2"
      },
      "charlie": {
        "ansible_host": "192.168.0.3"
      },
      "delta": {
        "ansible_host": "192.168.0.4"
      }
    }
  }
}
EOF

$ ansible all --list-hosts
  hosts (4):
    alpha
    bravo
    charlie
    delta





-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to