blob: f74ab55d2f9029cb29c515b4b67b9e7a441c0825 [file] [log] [blame]
David K. Bainbridge317e7d72016-05-11 08:31:44 -07001---
David K. Bainbridge8db2f302016-05-19 23:41:13 -07002- name: Verify Manditory Variables
3 fail: msg="Variable '{{ item }}' is not defined"
4 when: item not in hostvars[inventory_hostname]
5 with_items:
6 - fabric_ip
7 tags:
8 - interface_config
9
David K. Bainbridge317e7d72016-05-11 08:31:44 -070010- name: Applications
11 become: yes
alshabib54cdbb22016-06-03 16:37:01 -070012 apt: name={{ item }} state=latest force=yes
David K. Bainbridge317e7d72016-05-11 08:31:44 -070013 with_items:
alshabib54cdbb22016-06-03 16:37:01 -070014 - build-essential
David K. Bainbridgee9f284d2016-05-18 14:13:43 -070015 - git
16 - python-pip
alshabib54cdbb22016-06-03 16:37:01 -070017 - ifenslave-2.6
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -070018 - bridge-utils
David K. Bainbridge73217f32016-07-14 22:25:08 -070019 - ethtool
David K. Bainbridgecadefd42016-07-22 16:29:24 -070020 - minicom
21 - curl
22 - jq
David K. Bainbridgee9f284d2016-05-18 14:13:43 -070023
David K. Bainbridge589a08f2016-06-15 18:14:18 -070024- name: Ensure Docker Insecure Repository
25 become: yes
26 lineinfile:
27 dest: /etc/default/docker
28 line: 'DOCKER_OPTS="$DOCKER_OPTS --insecure-registry docker-registry:5000"'
29 insertafter: '^DOCKER_OPTS'
30 register: docker_config
31
David K. Bainbridgefac79ca2016-07-28 10:00:44 -070032- name: Ensure Docker Registry Mirror
33 become: yes
34 lineinfile:
35 dest: /etc/default/docker
36 line: 'DOCKER_OPTS="$DOCKER_OPTS --registry-mirror=http://docker-registry:5001"'
37 insertafter: '^DOCKER_OPTS'
38 register: docker_config_mirror
39
David K. Bainbridge589a08f2016-06-15 18:14:18 -070040- name: Docker Restart
41 become: yes
42 service:
43 name=docker
44 state=restarted
David K. Bainbridgefac79ca2016-07-28 10:00:44 -070045 when: docker_config.changed or docker_config_mirror.changed
David K. Bainbridge589a08f2016-06-15 18:14:18 -070046
David K. Bainbridgee9f284d2016-05-18 14:13:43 -070047- name: Ensure Docker Ansible Support
48 become: yes
49 pip:
50 name=docker-py
51 version=0.3.1
David K. Bainbridge317e7d72016-05-11 08:31:44 -070052
53- name: Set Default Password
54 become: yes
55 user:
David K. Bainbridgeb5415042016-05-13 17:06:10 -070056 name={{ ansible_user }}
David K. Bainbridge317e7d72016-05-11 08:31:44 -070057 password="$6$TjhJuOgh8xp.v$z/4GwFbn5koVmkD6Ex9wY7bgP7L3uP2ujZkZSs1HNdzQdz9YclbnZH9GvqMC/M1iwC0MceL05.13HoFz/bai0/"
David K. Bainbridge2a804222016-05-16 12:36:32 -070058 when: '"{{ ansible_user }}" == "ubuntu"'
David K. Bainbridge317e7d72016-05-11 08:31:44 -070059
David K. Bainbridge39d0c782016-05-11 13:27:57 -070060- name: Authorize SSH Key
61 become: yes
62 authorized_key:
63 key="{{ pub_ssh_key }}"
David K. Bainbridgeb5415042016-05-13 17:06:10 -070064 user={{ ansible_user }}
David K. Bainbridge39d0c782016-05-11 13:27:57 -070065 state=present
66
67- name: Verify Private SSH Key
68 become: yes
69 stat:
David K. Bainbridgeb5415042016-05-13 17:06:10 -070070 path=/home/{{ ansible_user }}/.ssh/id_rsa
David K. Bainbridge39d0c782016-05-11 13:27:57 -070071 register: private_key
72
David K. Bainbridgeb5415042016-05-13 17:06:10 -070073- name: Ensure SSH Key
Andy Bavierceab2302016-07-07 09:04:07 -040074 become: no
David K. Bainbridge39d0c782016-05-11 13:27:57 -070075 copy:
76 src=files/{{ item }}
Andy Bavierceab2302016-07-07 09:04:07 -040077 dest={{ ansible_env['PWD'] }}/.ssh/{{ item }}
David K. Bainbridgeb5415042016-05-13 17:06:10 -070078 owner={{ ansible_user }}
David K. Bainbridge39d0c782016-05-11 13:27:57 -070079 mode=0600
80 with_items:
81 - id_rsa
82 - id_rsa.pub
David K. Bainbridge81bda332016-06-14 22:58:41 -070083 - config
David K. Bainbridge39d0c782016-05-11 13:27:57 -070084
85- name: Ensure CORD SUDO
86 become: yes
87 copy:
88 src=files/99-cord-sudoers
89 dest=/etc/sudoers.d/99-cord-sudoers
90 owner=root
91 group=root
92 mode=0600
93
David K. Bainbridgef3071012016-08-04 09:29:55 -070094- name: Ensure Utility Scripts
95 become: yes
96 copy:
97 src=files/{{ item }}
98 dest=/usr/local/bin/{{ item }}
99 owner=root
100 group=root
101 mode=0755
102 with_items:
103 - delete-fabric-config
104 - delete-node-prov-state
105 - docker-ip
106 - fabric-pingall
107 - get-fabric-config
108 - get-node-prov-state
109 - remove-xos-components
David K. Bainbridge1e4142d2016-08-04 10:01:58 -0700110 - post-fabric-config
David K. Bainbridgee80fd392016-08-19 15:46:19 -0700111 - pull-latest-docker-images
David K. Bainbridgef3071012016-08-04 09:29:55 -0700112
alshabibe16ef4c2016-05-27 17:13:23 -0700113- name: Verify Mellanox 40Gb NIC
114 shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c ConnectX-3 || true
115 register: mlx_nic_present
David K. Bainbridge0820cab2016-06-02 17:43:32 -0700116 changed_when: False
alshabibe16ef4c2016-05-27 17:13:23 -0700117
118- name: Verify Intel 40Gb NIC
119 shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c "XL710 for 40GbE QSFP+" || true
120 register: intel_nic_present
David K. Bainbridge0820cab2016-06-02 17:43:32 -0700121 changed_when: False
alshabibe16ef4c2016-05-27 17:13:23 -0700122
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700123- name: Verify i40e Driver
124 command: modinfo --field=version i40e
125 register: i40e_version
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700126 when: intel_nic_present.stdout != "0"
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700127 changed_when: False
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700128 failed_when: False
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700129 tags:
130 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700131
alshabibe16ef4c2016-05-27 17:13:23 -0700132- name: Verify mlx4 Driver
133 command: modinfo --field=version mlx4_core
134 register: mlx4_version
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700135 when: mlx_nic_present.stdout != "0"
alshabibe16ef4c2016-05-27 17:13:23 -0700136 changed_when: False
137 failed_when: False
138 tags:
139 - interface_config
140
141- name: Update mlx4 Driver
142 include: tasks/mlx4_driver.yml
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700143 when: mlx_nic_present.stdout != "0" and mlx4_version.stdout != '3.1-1.0.4'
alshabibe16ef4c2016-05-27 17:13:23 -0700144 tags:
145 - interface_config
146
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700147- name: Update i40e Driver
148 include: tasks/i40e_driver.yml
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700149 when: intel_nic_present.stdout != "0" and i40e_version.stdout != '1.4.25'
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700150 tags:
151 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700152
153- name: Consistent Interface Naming
154 become: yes
David K. Bainbridgede51ce52016-08-22 13:54:24 -0700155 script: files/rename_ifaces.sh "{{ compute_node.interfaces.fabric }}" "{{ compute_node.addresses.fabric }}" "{{ compute_node.interfaces.external }}" "{{ compute_node.addresses.external }}" "{{ compute_node.gateway.external }}" "{{ compute_node.interfaces.management }}" "{{ compute_node.addresses.management }}" "{{ compute_node.gateway.management }}" "{{ compute_node.fabric_iface_match }}"
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700156 register: ifaces_changed
David K. Bainbridge8db2f302016-05-19 23:41:13 -0700157 changed_when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700158 tags:
159 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700160
alshabib54cdbb22016-06-03 16:37:01 -0700161- name: Load modules at boot
162 become: yes
163 lineinfile:
164 dest: /etc/modules
165 line: "{{ item }}"
166 with_items:
167 - lp
168 - loop
169 - rtc
170 - bonding
171
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700172- name: Reboot Required
173 become: yes
174 command: /sbin/reboot
David K. Bainbridge8db2f302016-05-19 23:41:13 -0700175 async: 0
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700176 poll: 0
177 ignore_errors: true
David K. Bainbridgedf0f7e02016-05-20 09:18:28 -0700178 when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700179 tags:
180 - interface_config
David K. Bainbridgecd4caeb2016-05-23 14:58:12 -0700181 - reboot
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700182
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700183- name: Ensure Port Defined
184 set_fact:
185 ansible_ssh_port: 22
186 when: ansible_ssh_port is not defined
187
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700188- name: Wait For Restart
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700189 local_action: wait_for port={{ ansible_ssh_port }} host={{ inventory_hostname }} search_regex=OpenSSH delay=30 timeout=600 connect_timeout=15
David K. Bainbridge22d5f3c2016-05-20 09:21:56 -0700190 when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridgeed101542016-05-18 20:26:15 -0700191 tags:
192 - interface_config
David K. Bainbridgecd4caeb2016-05-23 14:58:12 -0700193 - reboot