Merge "Remove tasks for Ansible <= 2.3"
This commit is contained in:
commit
66d9b08853
@ -34,32 +34,11 @@
|
|||||||
# pick up the group membership. We do this by removing the SSH ControlPersist
|
# pick up the group membership. We do this by removing the SSH ControlPersist
|
||||||
# connection.
|
# connection.
|
||||||
|
|
||||||
# NOTE: This method does not work in Ansible 2.3, which uses a SHA1 hash of the
|
# NOTE: Ideally we'd use a meta task with the reset_connection option but due
|
||||||
# connection parameters to determine the control persist socket path.
|
# to https://github.com/ansible/ansible/issues/27520 this does not work
|
||||||
- name: Drop the persistent SSH connection to activate the new group membership
|
# (checked in Ansible 2.3.2.0). Instead, we use the heavy handed method of
|
||||||
local_action:
|
# removing all ansible control sockets. Limitation: if this user is running
|
||||||
module: shell ssh -O stop {{ cp_hostname }} -o ControlPath={{ cp_path }}
|
# another ansible process, we will kill its connections.
|
||||||
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.
|
|
||||||
- name: Find persistent SSH connection control sockets
|
- name: Find persistent SSH connection control sockets
|
||||||
local_action:
|
local_action:
|
||||||
module: find
|
module: find
|
||||||
@ -71,7 +50,6 @@
|
|||||||
run_once: True
|
run_once: True
|
||||||
when:
|
when:
|
||||||
- group_result|changed
|
- group_result|changed
|
||||||
- ansible_version | version_compare('2.3', 'ge')
|
|
||||||
|
|
||||||
- name: Drop all persistent SSH connections to activate the new group membership
|
- name: Drop all persistent SSH connections to activate the new group membership
|
||||||
local_action:
|
local_action:
|
||||||
|
@ -1,29 +1,11 @@
|
|||||||
---
|
---
|
||||||
# NOTE: We are installing this into the system python packages because it does
|
# The NETCONF client ncclient is required. This must be installed on the
|
||||||
# not seem to be possible to use ansible_python_interpreter in combination with
|
# Ansible control host where the ansible-connection subprocess is executed.
|
||||||
# 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.
|
|
||||||
- name: Ensure python dependencies are installed
|
- name: Ensure python dependencies are installed
|
||||||
local_action:
|
local_action:
|
||||||
module: pip
|
module: pip
|
||||||
name: ncclient
|
name: ncclient
|
||||||
virtualenv: "{{ lookup('env', 'VIRTUAL_ENV') | default(omit, true) }}"
|
virtualenv: "{{ lookup('env', 'VIRTUAL_ENV') | default(omit, true) }}"
|
||||||
when: ansible_version | version_compare('2.3', 'ge')
|
|
||||||
become: "{{ lookup('env', 'VIRTUAL_ENV') == None }}"
|
become: "{{ lookup('env', 'VIRTUAL_ENV') == None }}"
|
||||||
|
|
||||||
- name: Ensure Juniper switches are configured
|
- name: Ensure Juniper switches are configured
|
||||||
|
Loading…
Reference in New Issue
Block a user