blob: d5dd19af0a4fb5e7635172389dfd1b3db3b5f553 [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. Bainbridged0590082016-07-14 22:25:08 -070019 - ethtool
David K. Bainbridgee9f284d2016-05-18 14:13:43 -070020
David K. Bainbridge589a08f2016-06-15 18:14:18 -070021- name: Ensure Docker Insecure Repository
22 become: yes
23 lineinfile:
24 dest: /etc/default/docker
25 line: 'DOCKER_OPTS="$DOCKER_OPTS --insecure-registry docker-registry:5000"'
26 insertafter: '^DOCKER_OPTS'
27 register: docker_config
28
29- name: Docker Restart
30 become: yes
31 service:
32 name=docker
33 state=restarted
34 when: docker_config.changed
35
David K. Bainbridgee9f284d2016-05-18 14:13:43 -070036- name: Ensure Docker Ansible Support
37 become: yes
38 pip:
39 name=docker-py
40 version=0.3.1
David K. Bainbridge317e7d72016-05-11 08:31:44 -070041
42- name: Set Default Password
43 become: yes
44 user:
David K. Bainbridgeb5415042016-05-13 17:06:10 -070045 name={{ ansible_user }}
David K. Bainbridge317e7d72016-05-11 08:31:44 -070046 password="$6$TjhJuOgh8xp.v$z/4GwFbn5koVmkD6Ex9wY7bgP7L3uP2ujZkZSs1HNdzQdz9YclbnZH9GvqMC/M1iwC0MceL05.13HoFz/bai0/"
David K. Bainbridge2a804222016-05-16 12:36:32 -070047 when: '"{{ ansible_user }}" == "ubuntu"'
David K. Bainbridge317e7d72016-05-11 08:31:44 -070048
David K. Bainbridge39d0c782016-05-11 13:27:57 -070049- name: Authorize SSH Key
50 become: yes
51 authorized_key:
52 key="{{ pub_ssh_key }}"
David K. Bainbridgeb5415042016-05-13 17:06:10 -070053 user={{ ansible_user }}
David K. Bainbridge39d0c782016-05-11 13:27:57 -070054 state=present
55
56- name: Verify Private SSH Key
57 become: yes
58 stat:
David K. Bainbridgeb5415042016-05-13 17:06:10 -070059 path=/home/{{ ansible_user }}/.ssh/id_rsa
David K. Bainbridge39d0c782016-05-11 13:27:57 -070060 register: private_key
61
David K. Bainbridgeb5415042016-05-13 17:06:10 -070062- name: Ensure SSH Key
Andy Bavierceab2302016-07-07 09:04:07 -040063 become: no
David K. Bainbridge39d0c782016-05-11 13:27:57 -070064 copy:
65 src=files/{{ item }}
Andy Bavierceab2302016-07-07 09:04:07 -040066 dest={{ ansible_env['PWD'] }}/.ssh/{{ item }}
David K. Bainbridgeb5415042016-05-13 17:06:10 -070067 owner={{ ansible_user }}
David K. Bainbridge39d0c782016-05-11 13:27:57 -070068 mode=0600
69 with_items:
70 - id_rsa
71 - id_rsa.pub
David K. Bainbridge81bda332016-06-14 22:58:41 -070072 - config
David K. Bainbridge39d0c782016-05-11 13:27:57 -070073
74- name: Ensure CORD SUDO
75 become: yes
76 copy:
77 src=files/99-cord-sudoers
78 dest=/etc/sudoers.d/99-cord-sudoers
79 owner=root
80 group=root
81 mode=0600
82
alshabibe16ef4c2016-05-27 17:13:23 -070083- name: Verify Mellanox 40Gb NIC
84 shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c ConnectX-3 || true
85 register: mlx_nic_present
David K. Bainbridge0820cab2016-06-02 17:43:32 -070086 changed_when: False
alshabibe16ef4c2016-05-27 17:13:23 -070087
88- name: Verify Intel 40Gb NIC
89 shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c "XL710 for 40GbE QSFP+" || true
90 register: intel_nic_present
David K. Bainbridge0820cab2016-06-02 17:43:32 -070091 changed_when: False
alshabibe16ef4c2016-05-27 17:13:23 -070092
David K. Bainbridge317e7d72016-05-11 08:31:44 -070093- name: Verify i40e Driver
94 command: modinfo --field=version i40e
95 register: i40e_version
David K. Bainbridge10a8b982016-06-28 10:43:44 -070096 when: intel_nic_present.stdout != "0"
David K. Bainbridge317e7d72016-05-11 08:31:44 -070097 changed_when: False
David K. Bainbridgeb5415042016-05-13 17:06:10 -070098 failed_when: False
David K. Bainbridge4ec841c2016-05-11 22:10:15 -070099 tags:
100 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700101
alshabibe16ef4c2016-05-27 17:13:23 -0700102- name: Verify mlx4 Driver
103 command: modinfo --field=version mlx4_core
104 register: mlx4_version
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700105 when: mlx_nic_present.stdout != "0"
alshabibe16ef4c2016-05-27 17:13:23 -0700106 changed_when: False
107 failed_when: False
108 tags:
109 - interface_config
110
111- name: Update mlx4 Driver
112 include: tasks/mlx4_driver.yml
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700113 when: mlx_nic_present.stdout != "0" and mlx4_version.stdout != '3.1-1.0.4'
alshabibe16ef4c2016-05-27 17:13:23 -0700114 tags:
115 - interface_config
116
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700117- name: Update i40e Driver
118 include: tasks/i40e_driver.yml
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700119 when: intel_nic_present.stdout != "0" and i40e_version.stdout != '1.4.25'
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700120 tags:
121 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700122
123- name: Consistent Interface Naming
124 become: yes
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700125 script: files/rename_ifaces.sh "{{ compute_node.interfaces.fabric }}" "{{ compute_node.addresses.fabric }}" "{{ compute_node.interfaces.external }}" "{{ compute_node.addresses.external }}" "{{ compute_node.interfaces.management }}" "{{ compute_node.addresses.management }}"
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700126 register: ifaces_changed
David K. Bainbridge8db2f302016-05-19 23:41:13 -0700127 changed_when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700128 tags:
129 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700130
alshabib54cdbb22016-06-03 16:37:01 -0700131- name: Load modules at boot
132 become: yes
133 lineinfile:
134 dest: /etc/modules
135 line: "{{ item }}"
136 with_items:
137 - lp
138 - loop
139 - rtc
140 - bonding
141
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700142- name: Reboot Required
143 become: yes
144 command: /sbin/reboot
David K. Bainbridge8db2f302016-05-19 23:41:13 -0700145 async: 0
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700146 poll: 0
147 ignore_errors: true
David K. Bainbridgedf0f7e02016-05-20 09:18:28 -0700148 when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700149 tags:
150 - interface_config
David K. Bainbridgecd4caeb2016-05-23 14:58:12 -0700151 - reboot
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700152
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700153- name: Ensure Port Defined
154 set_fact:
155 ansible_ssh_port: 22
156 when: ansible_ssh_port is not defined
157
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700158- name: Wait For Restart
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700159 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 -0700160 when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridgeed101542016-05-18 20:26:15 -0700161 tags:
162 - interface_config
David K. Bainbridgecd4caeb2016-05-23 14:58:12 -0700163 - reboot