For legacy playbooks, Ansible still supports ``ansible_connection: local`` on all JUNOS modules. We recommend modernizing to use ``ansible_connection: netconf`` or ``ansible_connection: network_cli`` as soon as possible.
For legacy playbooks, Ansible still supports ``ansible_connection=local`` on all JUNOS modules. We recommend modernizing to use ``ansible_connection=netconf`` or ``ansible_connection=network_cli`` as soon as possible.
- If you are using SSH keys (including an ssh-agent) you can remove the ``ansible_ssh_pass`` configuration.
@ -58,10 +59,9 @@ Example CLI Task
..code-block:: yaml
- name: Backup current switch config (junos)
junos_config:
backup: yes
register: backup_junos_location
- name: Retrieve Junos OS version
junos_command:
commands: show version
when: ansible_network_os == 'junos'
@ -76,26 +76,28 @@ Before you can use NETCONF to connect to a switch, you must:
- install the ``ncclient`` python package on your control node(s) with ``pip install ncclient``
- enable NETCONF on the Junos OS device(s)
To enable NETCONF on a new switch via Ansible, use the ``junos_netconf`` module via the CLI connection. Set up group_vars/junos.yml just like in the CLI example above, then run a playbook task like this:
To enable NETCONF on a new switch via Ansible, use the ``junos_netconf`` module via the CLI connection. Set up your platform-level variables just like in the CLI example above, then run a playbook task like this:
..code-block:: yaml
- name: Enable NETCONF
junos_netconf:
when: ansible_network_os == 'junos'
connection: network_cli
junos_netconf:
when: ansible_network_os == 'junos'
Once NETCONF is enabled, change your ``group_vars/junos.yml`` to use the NETCONF connection.
Once NETCONF is enabled, change your variables to use the NETCONF connection.