summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ansible/roles/docker/tasks/main.yml32
-rw-r--r--ansible/roles/junos-switch/tasks/main.yml22
2 files changed, 7 insertions, 47 deletions
diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml
index 49b13a7..4fa1a02 100644
--- a/ansible/roles/docker/tasks/main.yml
+++ b/ansible/roles/docker/tasks/main.yml
@@ -34,32 +34,11 @@
34# pick up the group membership. We do this by removing the SSH ControlPersist 34# pick up the group membership. We do this by removing the SSH ControlPersist
35# connection. 35# connection.
36 36
37# NOTE: This method does not work in Ansible 2.3, which uses a SHA1 hash of the 37# NOTE: Ideally we'd use a meta task with the reset_connection option but due
38# connection parameters to determine the control persist socket path. 38# to https://github.com/ansible/ansible/issues/27520 this does not work
39- name: Drop the persistent SSH connection to activate the new group membership 39# (checked in Ansible 2.3.2.0). Instead, we use the heavy handed method of
40 local_action: 40# removing all ansible control sockets. Limitation: if this user is running
41 module: shell ssh -O stop {{ cp_hostname }} -o ControlPath={{ cp_path }} 41# another ansible process, we will kill its connections.
42 register: socket_removal
43 failed_when:
44 - socket_removal|failed
45 - "'No such file or directory' not in socket_removal.stderr"
46 with_items: "{{ play_hosts }}"
47 run_once: True
48 when:
49 - group_result|changed
50 - ansible_version | version_compare('2.3', 'lt')
51 vars:
52 cp_hostname: "{{ hostvars[item].ansible_host|default(inventory_hostname) }}"
53 cp_username: "{{ hostvars[item].ansible_user }}"
54 cp_port: "{{ hostvars[item].ansible_ssh_port|default('22') }}"
55 cp_path: "~/.ansible/cp/ansible-ssh-{{ cp_hostname }}-{{ cp_port }}-{{ cp_username }}"
56
57# NOTE: For Ansible 2.3+, ideally we'd use a meta task with the
58# reset_connection option but due to
59# https://github.com/ansible/ansible/issues/27520 this does not work (checked
60# in Ansible 2.3.2.0). Instead, we use the heavy handed method of removing all
61# ansible control sockets. Limitation: if this user is running another ansible
62# process, we will kill its connections.
63- name: Find persistent SSH connection control sockets 42- name: Find persistent SSH connection control sockets
64 local_action: 43 local_action:
65 module: find 44 module: find
@@ -71,7 +50,6 @@
71 run_once: True 50 run_once: True
72 when: 51 when:
73 - group_result|changed 52 - group_result|changed
74 - ansible_version | version_compare('2.3', 'ge')
75 53
76- name: Drop all persistent SSH connections to activate the new group membership 54- name: Drop all persistent SSH connections to activate the new group membership
77 local_action: 55 local_action:
diff --git a/ansible/roles/junos-switch/tasks/main.yml b/ansible/roles/junos-switch/tasks/main.yml
index b9b0a06..88d6fe8 100644
--- a/ansible/roles/junos-switch/tasks/main.yml
+++ b/ansible/roles/junos-switch/tasks/main.yml
@@ -1,29 +1,11 @@
1--- 1---
2# NOTE: We are installing this into the system python packages because it does 2# The NETCONF client ncclient is required. This must be installed on the
3# not seem to be possible to use ansible_python_interpreter in combination with 3# Ansible control host where the ansible-connection subprocess is executed.
4# delegate_to. This should be investigated in future as modification of system
5# packages via pip is not ideal.
6
7# For ansible 2.2, Juniper specific python packages are required.
8- name: Ensure python dependencies are installed
9 pip:
10 name: "{{ item }}"
11 delegate_to: "{{ junos_switch_delegate_to }}"
12 with_items:
13 - junos-eznc
14 - jxmlease
15 when: ansible_version | version_compare('2.3', 'lt')
16 become: True
17
18# For ansible 2.3+, only the NETCONF client ncclient is required. This must be
19# installed on the Ansible control host where the ansible-connection subprocess
20# is executed.
21- name: Ensure python dependencies are installed 4- name: Ensure python dependencies are installed
22 local_action: 5 local_action:
23 module: pip 6 module: pip
24 name: ncclient 7 name: ncclient
25 virtualenv: "{{ lookup('env', 'VIRTUAL_ENV') | default(omit, true) }}" 8 virtualenv: "{{ lookup('env', 'VIRTUAL_ENV') | default(omit, true) }}"
26 when: ansible_version | version_compare('2.3', 'ge')
27 become: "{{ lookup('env', 'VIRTUAL_ENV') == None }}" 9 become: "{{ lookup('env', 'VIRTUAL_ENV') == None }}"
28 10
29- name: Ensure Juniper switches are configured 11- name: Ensure Juniper switches are configured