From 1169ce111c90508c515902889dd552bcea4e2b5c Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 11 Oct 2017 16:23:30 +0000 Subject: [PATCH] Install ncclient python package for junos switches on ansible 2.3+ This package is required on the ansible control host, and is used by the ansible-connection process to access the switches via a persistent SSH connection. It must be installed in the kayobe virtual environment. --- ansible/roles/junos-switch/tasks/main.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ansible/roles/junos-switch/tasks/main.yml b/ansible/roles/junos-switch/tasks/main.yml index 7506f89c4..8f5ce0153 100644 --- a/ansible/roles/junos-switch/tasks/main.yml +++ b/ansible/roles/junos-switch/tasks/main.yml @@ -3,6 +3,8 @@ # not seem to be possible to use ansible_python_interpreter in combination with # delegate_to. This should be investigated in future as modification of system # packages via pip is not ideal. + +# For ansible 2.2, Juniper specific python packages are required. - name: Ensure python dependencies are installed pip: name: "{{ item }}" @@ -10,8 +12,20 @@ with_items: - junos-eznc - jxmlease + when: ansible_version | version_compare('2.3', 'lt') become: True +# For ansible 2.3+, only the NETCONF client ncclient is required. This must be +# installed on the ansible control host where the ansible-connection subprocess +# is executed. +- name: Ensure python dependencies are installed + local_action: + module: pip + name: ncclient + virtualenv: "{{ lookup('env', 'VIRTUAL_ENV') | default(omit, true) }}" + when: ansible_version | version_compare('2.3', 'ge') + become: "{{ lookup('env', 'VIRTUAL_ENV') == None }}" + - name: Ensure Juniper switches are configured junos_config: provider: "{{ junos_switch_provider }}"