The way we are trying to use Ansible is to dynamically configure a server during instantiation of a VM. We won't know the IP or hostname of the VM until it is created and once the IP is known, then we want to tell Ansible what to do with it. A hosts/inventory can't be populated when we don't yet know what the IP will be. The current workaround is to launch the VM, grab the IP, modify the hosts file using sed, and then running the playbook to fully configure the server and then resetting the hosts file for next use. I feel like the hosts file dependency is really limiting how we want to use Ansible.
We will always configure one server at a time, but in this same fashion and there could be many in a day. I just tried this command and it worked this time, however, since we prefer to use UN and PW for SSH instead of keys (same reason as above, and we don't want to have to establish SSH connection and accept key each time we run Ansible on a new host) we need a method of specifying SSH credentials to the command line using this fake inventory method: ansible-playbook SNMP.yml -i 192.168.1.24, On Mon, May 19, 2014 at 12:31 PM, Matt Martz <[email protected]> wrote: > I am somewhat confused. You can't use an inventory file because you have > too many hosts, but need to use one because you have too many usernames and > passwords? > > When you use: -i 192.168.1.24, > > Ansible explicitly only knows of a single host called 192.168.1.24. It > has no concepts of groups or other hosts if you don't give it an inventory > file. > > Your hosts declaration would either need to be "all" or "192.168.1.24" > otherwise it will never match its knowledge of your inventory. > > Maybe you should looks into creating a dynamic inventory script to pull > from an API or CMDB containing info about your hosts. > > > > On Monday, May 19, 2014, Noah Parker <[email protected]> wrote: > >> root@MidLinux:/var# ansible-playbook -i '192.168.1.24,' SNMP.yml >> >> PLAY [SNMP] >> ******************************************************************* >> skipping: no hosts matched >> >> In the yml file, I specify SNMP for group. If I leave this blank, I get: >> >> ERROR: hosts declaration is required >> >> SNMP is a real group in the hosts file. A hosts file is not practical for >> me since I have so many servers. Additionally, I would need a way to pass >> in SSH UN and PW since those parameters are also kept in the hosts file. >> Any help would be appreciated. >> >> >> On Sunday, May 18, 2014 9:10:39 PM UTC-7, Brian Coca wrote: >>> >>> what variations? what errors would you get? more information would be >>> useful for debugging. >>> >>> On Sun, May 18, 2014 at 11:46 PM, Noah Parker <[email protected]> wrote: >>> >>>> " means that I tried using the command several times using variations >>>> in syntax and it was not successful. >>>> >>> >>> >>> >>> >>> -- >>> Brian Coca >>> Stultorum infinitus est numerus >>> 011000010111001001100101011011100010011101110100001000000111 >>> 100101101111011101010010000001110011011011010110000101110010 >>> 0111010000100001 >>> Pedo mellon a minno >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/0f991303-ebc1-44c0-ae8c-44343faa9afc%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/0f991303-ebc1-44c0-ae8c-44343faa9afc%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > Matt Martz > [email protected] > http://sivel.net/ > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ansible Project" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ansible-project/G_9JRGp5jGE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CAD8N0v9wNt2s0TGt9pqrSvS18ypWV3uXyY1xuy8u9iK9iHCXKg%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAD8N0v9wNt2s0TGt9pqrSvS18ypWV3uXyY1xuy8u9iK9iHCXKg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAOGOT-nu532wPskhYWhXWdzivjVj-hAgxU4_KMvQDJCnDtYmUQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
