Thank you very much! I can't believe that I didn't scroll down that page far enough, basically was looking at the magic variables.
-Scott On Monday, 20 April 2020 21:49:41 UTC-7, Dick Visser wrote: > > From: > > https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html > > > On Tue, 21 Apr 2020 at 06:47, Dick Visser <[email protected] > <javascript:>> wrote: > >> Try 'ansible_host' >> >> On Tue, 21 Apr 2020 at 03:11, Scott Fella <[email protected] <javascript:>> >> wrote: >> >>> Currently trying to see if there is a way I can grab the ip defined in >>> the ansible_host and use that in a playbook. I know there is >>> inventory_hostaname, but these for example are not in dns. >>> >>> hosts inventory example: >>> >>> [aireos] >>> wlc2504-01 ansible_host=10.10.201.24 >>> wlc2504-02 ansible_host=10.10.201.25 >>> wlc5520-01 ansible_host=10.11.201.24 >>> wlc5520-02 ansible_host=10.11.201.25 >>> >>> Here is a sample of a playbook which works if the device is registered >>> in dns but fails of course when not. Is there any way I can extract the ip >>> address so I can loop through all devices in the inventory group? >>> >>> --- >>> - name: Check if SNMPv2 is working on remote host >>> hosts: aireos >>> connection: local >>> gather_facts: no >>> >>> tasks: >>> - name: Test SNMPv2 >>> local_action: command snmpget -v 2c -c testSNMPxxx >>> {{inventory_hostname}} 1.3.6.1.2.1.1.5.0 >>> register: response >>> - name: Print the complete response >>> debug: >>> var: response >>> >>> Thanks, >>> -Scott >>> >>> -- >>> 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] <javascript:>. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/302b741d-c377-41a7-ab93-837f143446c9%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/ansible-project/302b741d-c377-41a7-ab93-837f143446c9%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> Sent from a mobile device - please excuse the brevity, spelling and >> punctuation. >> > -- > Sent from a mobile device - please excuse the brevity, spelling and > punctuation. > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bba8ccda-df65-4cde-bbc8-2e22d3fc4394%40googlegroups.com.
