Need help to run my first ansible playbook

36 views
Skip to first unread message

Richard

unread,
Nov 26, 2019, 10:26:55 PM11/26/19
to Ansible Project
I need help to run write ansible playbook to run show commands on Cisco Starent devices
And I'm running into some errors

Playbook
 ---

 - name: Run Show Command
   hosts: all
   connection: network_cli
   gather_facts: no

  tasks:
    - name: Gather Fact on all hosts
      ios_facts:

    - name: Run show Command
      ios_commands:
             - commands: "show alarm outstanding"

 ---


Errror

ansible@denchpw26:~$ sudo nano CiscoCheck_playbook.ymlCSR, -u a
ansible@denchpw26:~$ clear
ansible@denchpw26:~$ ansible-playbook -i all, -u ansible -k -e ansible_network_os=ios CiscoCheck_playbook.yml
SSH password:
 [WARNING]: Found both group and host with same name: all

ERROR! Syntax Error while loading YAML.
  mapping values are not allowed in this context

The error appears to have been in '/home/ansible/CiscoCheck_playbook.yml': line 3, column 8, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


 - name: Run Show Command
       ^ here

Michael

unread,
Nov 26, 2019, 10:42:19 PM11/26/19
to Ansible Project
It appears you may have wrongly mapped the attribute - commands beneath the  ios_commands module in task "Run Show Command"

see examples here and pay attention to indentation, the line "tasks" appears to be wrongly indented also.

I would try the following:

---

 - name: Run Show Command
   hosts: all
   connection: network_cli
   gather_facts: no

   tasks:
   - name: Gather Fact on all hosts
     ios_facts:

   - name: Run show Command
     ios_commands:
       commands: "show alarm outstanding"

Richard

unread,
Nov 26, 2019, 11:29:55 PM11/26/19
to Ansible Project
Thanks for your help Michael.
The playbook is working now but ran into a another error

PLAY [Run Show Command] ************************************************************************

TASK [run show command] ************************************************************************
fatal: [all]: FAILED! => {"msg": "[Errno -3] Temporary failure in name resolution"}
        to retry, use: --limit @/home/ansible/test_playbook.retry

PLAY RECAP *************************************************************************************
all                        : ok=0    changed=0    unreachable=0    failed=1


On Tuesday, November 26, 2019 at 10:26:55 PM UTC-5, Richard wrote:

Stefan Hornburg (Racke)

unread,
Nov 27, 2019, 3:18:21 AM11/27/19
to ansible...@googlegroups.com
On 11/27/19 5:29 AM, 'Richard' via Ansible Project wrote:
> Thanks for your help Michael.
> The playbook is working now but ran into a another error
>
> PLAY [Run Show Command] ************************************************************************
>
> TASK [run show command] ************************************************************************
> fatal: [all]: FAILED! => {"msg": "[Errno -3] Temporary failure in name resolution"}
>         to retry, use: --limit @/home/ansible/test_playbook.retry
>
> PLAY RECAP *************************************************************************************
> all                        : ok=0    changed=0    unreachable=0    failed=1
>

Your inventory is broken: [WARNING]: Found both group and host with same name: all

Regards
Racke
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/bee9c34b-6949-49a0-99c9-e4bfeebd26f3%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/bee9c34b-6949-49a0-99c9-e4bfeebd26f3%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc
Reply all
Reply to author
Forward
0 new messages