IOS_Config Question. New User

76 views
Skip to first unread message

Neal Z

unread,
Jan 29, 2017, 12:14:56 AM1/29/17
to Ansible Project

I am a new user of Ansible.


I am trying to use the IOS_Config module and a I cannot find the syntax error in my playbook (See Below).  I suspect I may be missing the IOS_Config module? I am on Mac running 2.2. But I am unsure if I have the developer modules or not.


Have confirmed no invisible characters in the file.




I am getting this error:



MacBook-Pro:ansible nealzipper$ ansible-playbook -i inventory backup-configs.yml -vvv

 

Using /etc/ansible/ansible.cfg as config file

ERROR
! Syntax Error while loading YAML.


The error appears to have been in '/Users/neal/ansible/backup-configs.yml': line 20, column 7, but may

be elsewhere
in the file depending on the exact syntax problem.


The offending line appears to be:

     
- name: SAVE AND BACKUP CONFIGS

     
^ here

MacBook-Pro:ansible neal$



Here my playbook :


---



 
- name: PLAY - BACKUP

    hosts
: all

    gather_facts
: no

    connection
: local




    tasks
:




       
- name: OBTAIN LOGIN CREDENTIALS

         include_vars
: ./secrets.yml




       
- name: DEFINE PROVIDER

         set_fact
:

         provider
:

            host
: "{{ inventory_hostname }}"

            username
: "{{ creds['username'] }}"

            password
: "{{ creds['password'] }}"

            auth_pass
: "{{ creds['auth_pass'] }}"




     
- name: SAVE AND BACKUP CONFIGS

        ios_config
:

          backup
: yes

          local_file
: {{ filename }}



          platform
: {{ net_platform }}


Jinesh Choksi

unread,
Feb 1, 2017, 5:20:20 AM2/1/17
to Ansible Project
Hi

There were a couple of small yaml syntax errors in your playbook. Here is what it should look like:

---
- name: PLAY - BACKUP
  hosts:
    - localhost
  gather_facts: no
  connection: local

  tasks:
     - name: OBTAIN LOGIN CREDENTIALS
       include_vars: ./secrets.yml

     - name: DEFINE PROVIDER
       set_fact:
           provider:
             host: "{{ inventory_hostname }}"
             username: "{{ creds['username'] }}"
             password: "{{ creds['password'] }}"
             auth_pass: "{{ creds['auth_pass'] }}"

     - name: SAVE AND BACKUP CONFIGS
       ios_config:
          backup: yes
          local_file: "{{ filename }}"
          platform: "{{ net_platform }}"


Now I was able to run this but it fails because I don't have any of the vars defined and so it could still be possible there are more syntax issues which I've not encountered yet.

Anyway, at least it will move you a little forwards in your adventure. :-)

Good luck

Regards,
Jinesh
Reply all
Reply to author
Forward
0 new messages