From e6cf6ca98531dbdf3ac81712d9aa72878a085043 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 6 Nov 2018 18:33:46 +0000 Subject: [PATCH] Remove tasks for Ansible <= 2.3 The minimum version of ansible is 2.4, so these tasks are no longer required. Change-Id: Ied933d18e438955c23ad3eeff80e3377b5633a7c --- ansible/roles/docker/tasks/main.yml | 32 ++++------------------- ansible/roles/junos-switch/tasks/main.yml | 22 ++-------------- 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml index 49b13a741..4fa1a0291 100644 --- a/ansible/roles/docker/tasks/main.yml +++ b/ansible/roles/docker/tasks/main.yml @@ -34,32 +34,11 @@ # pick up the group membership. We do this by removing the SSH ControlPersist # connection. -# NOTE: This method does not work in Ansible 2.3, which uses a SHA1 hash of the -# connection parameters to determine the control persist socket path. -- name: Drop the persistent SSH connection to activate the new group membership - local_action: - module: shell ssh -O stop {{ cp_hostname }} -o ControlPath={{ cp_path }} - register: socket_removal - failed_when: - - socket_removal|failed - - "'No such file or directory' not in socket_removal.stderr" - with_items: "{{ play_hosts }}" - run_once: True - when: - - group_result|changed - - ansible_version | version_compare('2.3', 'lt') - vars: - cp_hostname: "{{ hostvars[item].ansible_host|default(inventory_hostname) }}" - cp_username: "{{ hostvars[item].ansible_user }}" - cp_port: "{{ hostvars[item].ansible_ssh_port|default('22') }}" - cp_path: "~/.ansible/cp/ansible-ssh-{{ cp_hostname }}-{{ cp_port }}-{{ cp_username }}" - -# NOTE: For Ansible 2.3+, ideally we'd use a meta task with the -# reset_connection option but due to -# https://github.com/ansible/ansible/issues/27520 this does not work (checked -# in Ansible 2.3.2.0). Instead, we use the heavy handed method of removing all -# ansible control sockets. Limitation: if this user is running another ansible -# process, we will kill its connections. +# NOTE: Ideally we'd use a meta task with the reset_connection option but due +# to https://github.com/ansible/ansible/issues/27520 this does not work +# (checked in Ansible 2.3.2.0). Instead, we use the heavy handed method of +# removing all ansible control sockets. Limitation: if this user is running +# another ansible process, we will kill its connections. - name: Find persistent SSH connection control sockets local_action: module: find @@ -71,7 +50,6 @@ run_once: True when: - group_result|changed - - ansible_version | version_compare('2.3', 'ge') - name: Drop all persistent SSH connections to activate the new group membership local_action: diff --git a/ansible/roles/junos-switch/tasks/main.yml b/ansible/roles/junos-switch/tasks/main.yml index b9b0a0615..88d6fe84b 100644 --- a/ansible/roles/junos-switch/tasks/main.yml +++ b/ansible/roles/junos-switch/tasks/main.yml @@ -1,29 +1,11 @@ --- -# NOTE: We are installing this into the system python packages because it does -# 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 }}" - delegate_to: "{{ junos_switch_delegate_to }}" - 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. +# 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