Push configs on to juniper device using ansible

885 Views Asked by At

I am trying to push configurations on a to juniper device using ansible. I am using below playbook, using netconf for connection. I am getting an error msg: Unable to load config: ConfigLoadError(severity: error , bad_element: set, message: error: syntax error)

    ---
    - name: Load merge config
      connection: local
      gather_facts: no
      hosts: juniper

      roles:
       - Juniper.junos

      tasks:
      - name: Checking NETCONF connectivity
        wait_for: host={{ inventory_hostname }} port=830

      - name: Push config
        junos_install_config:
         host={{ inventory_hostname }}
         file=push.conf 
         replace_config=true

My config file has all set commands.

1

There are 1 best solutions below

0
charan On BEST ANSWER

Thank you, it works now. Actually my config file was with set commands, all I had to do is use file name as push.set. And also had to include user under the host. Final play-book that worked.

    ---
    - hosts: Juniper
      gather_facts: no
      connection: local

      roles:
       - Juniper.junos

      tasks:
      - name: Push config
        junos_install_config:
         host={{ ansible_ssh_host }}          
         user={{ ansible_user }}
         file=push.set