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.
- 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
..code-block:: yaml
- name: Backup current switch config (junos)
- name: Retrieve Junos OS version
junos_config:
junos_command:
backup: yes
commands: show version
register: backup_junos_location
when: ansible_network_os == 'junos'
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``
- install the ``ncclient`` python package on your control node(s) with ``pip install ncclient``
- enable NETCONF on the Junos OS device(s)
- 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
..code-block:: yaml
- name: Enable NETCONF
- name: Enable NETCONF
junos_netconf:
connection: network_cli
when: ansible_network_os == 'junos'
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.