Remove tasks for Ansible <= 2.3

The minimum version of ansible is 2.4, so these tasks are no longer
required.

Change-Id: Ied933d18e438955c23ad3eeff80e3377b5633a7c
This commit is contained in:
Mark Goddard 2018-11-06 18:33:46 +00:00
parent e103d455ee
commit e6cf6ca985
2 changed files with 7 additions and 47 deletions

View File

@ -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:

View File

@ -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