Try 'ansible_host'
On Tue, 21 Apr 2020 at 03:11, Scott Fella <[email protected]> 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].
> 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.
--
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/CAL8fbwP2E-qy4bx4ozgp5hOEpzeWEYusymVptmQFXrGr5OR9OA%40mail.gmail.com.