Hi jon, I think that's not the reason. i can debug my variable used with register command. indeed i can debug the variable.
it seems now i have issue with regular expression and i am try to find good source how to use regular expr. Regards, *Surjeet Singh* Technical Specialist – Networks DATA CCNA, CCNP(R&S) Cell : +917838707047 To become bigger person,need to walk with bigger Vision !!!! On Tue, Jan 23, 2018 at 1:35 PM, 'J Hawkesworth' via Ansible Project < [email protected]> wrote: > I think you just need to set > > gather_facts: yes > > otherwise host-related variables, such as > inventory_hostname > > won't exist when you come to use them later in your playbook. > > Hope this helps, > > Jon > > > On Saturday, January 20, 2018 at 7:26:57 AM UTC, Surjeet Singh wrote: >> >> am i impacted with some bug ? >> >> "VARIABLE IS NOT DEFINED!" >> >> root@eve-ng:/etc/ansible# ansible-playbook test.yaml >> >> PLAY [collect device facts and display OS version] >> ************************************************************ >> ********************************************** >> >> TASK [run the show commands] ****************************** >> ************************************************************ >> ************************************** >> [WARNING]: argument username has been deprecated and will be removed in >> a future version >> [WARNING]: argument host has been deprecated and will be removed in a >> future version >> [WARNING]: argument password has been deprecated and will be removed in >> a future version >> ok: [8.8.8.8] >> ok: [5.5.5.5] >> >> TASK [debug] ************************************************************ >> ************************************************************ >> ************************ >> ok: [8.8.8.8] => { >> "version.stdout[0].Version": "VARIABLE IS NOT DEFINED!" >> } >> ok: [5.5.5.5] => { >> "version.stdout[0].Version": "VARIABLE IS NOT DEFINED!" >> } >> >> PLAY RECAP ************************************************************ >> ************************************************************ >> ************************** >> 5.5.5.5 : ok=2 changed=0 unreachable=0 >> failed=0 >> 8.8.8.8 : ok=2 changed=0 unreachable=0 >> failed=0 >> >> >> >> root@eve-ng:/etc/ansible# more test.yaml >> --- >> - name: collect device facts and display OS version >> hosts: "{{ inventory | default('all') }}" >> gather_facts: no >> connection: local >> >> >> tasks: >> - name: run the show commands >> ios_command: >> commands: >> - show version >> host: "{{ inventory_hostname }}" >> username: cisco >> password: cisco >> register: version >> >> - debug: var=version.stdout[0].Version >> > -- > 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/2Ys9ni8oVak/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/b69b0955-06ef-48e1-ad6d-1a1e918eeb57%40googlegroups. > com > <https://groups.google.com/d/msgid/ansible-project/b69b0955-06ef-48e1-ad6d-1a1e918eeb57%40googlegroups.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/CA%2BpLPDT%2BsTWjSw7BEfG-uQk_KPjacivmpUKYpdcOOmVWx15Uew%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
