blob: 53c3c6093f43f509a63e056989fdade1768a5d1a [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. Bainbridgee9f284d2016-05-18 14:13:43 -070019
David K. Bainbridge589a08f2016-06-15 18:14:18 -070020- name: Ensure Docker Insecure Repository
21 become: yes
22 lineinfile:
23 dest: /etc/default/docker
24 line: 'DOCKER_OPTS="$DOCKER_OPTS --insecure-registry docker-registry:5000"'
25 insertafter: '^DOCKER_OPTS'
26 register: docker_config
27
28- name: Docker Restart
29 become: yes
30 service:
31 name=docker
32 state=restarted
33 when: docker_config.changed
34
David K. Bainbridgee9f284d2016-05-18 14:13:43 -070035- name: Ensure Docker Ansible Support
36 become: yes
37 pip:
38 name=docker-py
39 version=0.3.1
David K. Bainbridge317e7d72016-05-11 08:31:44 -070040
41- name: Set Default Password
42 become: yes
43 user:
David K. Bainbridgeb5415042016-05-13 17:06:10 -070044 name={{ ansible_user }}
David K. Bainbridge317e7d72016-05-11 08:31:44 -070045 password="$6$TjhJuOgh8xp.v$z/4GwFbn5koVmkD6Ex9wY7bgP7L3uP2ujZkZSs1HNdzQdz9YclbnZH9GvqMC/M1iwC0MceL05.13HoFz/bai0/"
David K. Bainbridge2a804222016-05-16 12:36:32 -070046 when: '"{{ ansible_user }}" == "ubuntu"'
David K. Bainbridge317e7d72016-05-11 08:31:44 -070047
David K. Bainbridge39d0c782016-05-11 13:27:57 -070048- name: Authorize SSH Key
49 become: yes
50 authorized_key:
51 key="{{ pub_ssh_key }}"
David K. Bainbridgeb5415042016-05-13 17:06:10 -070052 user={{ ansible_user }}
David K. Bainbridge39d0c782016-05-11 13:27:57 -070053 state=present
54
55- name: Verify Private SSH Key
56 become: yes
57 stat:
David K. Bainbridgeb5415042016-05-13 17:06:10 -070058 path=/home/{{ ansible_user }}/.ssh/id_rsa
David K. Bainbridge39d0c782016-05-11 13:27:57 -070059 register: private_key
60
David K. Bainbridgeb5415042016-05-13 17:06:10 -070061- name: Ensure SSH Key
Andy Bavierceab2302016-07-07 09:04:07 -040062 become: no
David K. Bainbridge39d0c782016-05-11 13:27:57 -070063 copy:
64 src=files/{{ item }}
Andy Bavierceab2302016-07-07 09:04:07 -040065 dest={{ ansible_env['PWD'] }}/.ssh/{{ item }}
David K. Bainbridgeb5415042016-05-13 17:06:10 -070066 owner={{ ansible_user }}
David K. Bainbridge39d0c782016-05-11 13:27:57 -070067 mode=0600
68 with_items:
69 - id_rsa
70 - id_rsa.pub
David K. Bainbridge81bda332016-06-14 22:58:41 -070071 - config
David K. Bainbridge39d0c782016-05-11 13:27:57 -070072
73- name: Ensure CORD SUDO
74 become: yes
75 copy:
76 src=files/99-cord-sudoers
77 dest=/etc/sudoers.d/99-cord-sudoers
78 owner=root
79 group=root
80 mode=0600
81
alshabibe16ef4c2016-05-27 17:13:23 -070082- name: Verify Mellanox 40Gb NIC
83 shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c ConnectX-3 || true
84 register: mlx_nic_present
David K. Bainbridge0820cab2016-06-02 17:43:32 -070085 changed_when: False
alshabibe16ef4c2016-05-27 17:13:23 -070086
87- name: Verify Intel 40Gb NIC
88 shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c "XL710 for 40GbE QSFP+" || true
89 register: intel_nic_present
David K. Bainbridge0820cab2016-06-02 17:43:32 -070090 changed_when: False
alshabibe16ef4c2016-05-27 17:13:23 -070091
David K. Bainbridge317e7d72016-05-11 08:31:44 -070092- name: Verify i40e Driver
93 command: modinfo --field=version i40e
94 register: i40e_version
David K. Bainbridge10a8b982016-06-28 10:43:44 -070095 when: intel_nic_present.stdout != "0"
David K. Bainbridge317e7d72016-05-11 08:31:44 -070096 changed_when: False
David K. Bainbridgeb5415042016-05-13 17:06:10 -070097 failed_when: False
David K. Bainbridge4ec841c2016-05-11 22:10:15 -070098 tags:
99 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700100
alshabibe16ef4c2016-05-27 17:13:23 -0700101- name: Verify mlx4 Driver
102 command: modinfo --field=version mlx4_core
103 register: mlx4_version
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700104 when: mlx_nic_present.stdout != "0"
alshabibe16ef4c2016-05-27 17:13:23 -0700105 changed_when: False
106 failed_when: False
107 tags:
108 - interface_config
109
110- name: Update mlx4 Driver
111 include: tasks/mlx4_driver.yml
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700112 when: mlx_nic_present.stdout != "0" and mlx4_version.stdout != '3.1-1.0.4'
alshabibe16ef4c2016-05-27 17:13:23 -0700113 tags:
114 - interface_config
115
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700116- name: Update i40e Driver
117 include: tasks/i40e_driver.yml
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700118 when: intel_nic_present.stdout != "0" and i40e_version.stdout != '1.4.25'
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700119 tags:
120 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700121
122- name: Consistent Interface Naming
123 become: yes
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700124 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 -0700125 register: ifaces_changed
David K. Bainbridge8db2f302016-05-19 23:41:13 -0700126 changed_when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700127 tags:
128 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700129
alshabib54cdbb22016-06-03 16:37:01 -0700130- name: Load modules at boot
131 become: yes
132 lineinfile:
133 dest: /etc/modules
134 line: "{{ item }}"
135 with_items:
136 - lp
137 - loop
138 - rtc
139 - bonding
140
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700141- name: Reboot Required
142 become: yes
143 command: /sbin/reboot
David K. Bainbridge8db2f302016-05-19 23:41:13 -0700144 async: 0
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700145 poll: 0
146 ignore_errors: true
David K. Bainbridgedf0f7e02016-05-20 09:18:28 -0700147 when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700148 tags:
149 - interface_config
David K. Bainbridgecd4caeb2016-05-23 14:58:12 -0700150 - reboot
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700151
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700152- name: Ensure Port Defined
153 set_fact:
154 ansible_ssh_port: 22
155 when: ansible_ssh_port is not defined
156
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700157- name: Wait For Restart
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700158 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 -0700159 when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridgeed101542016-05-18 20:26:15 -0700160 tags:
161 - interface_config
David K. Bainbridgecd4caeb2016-05-23 14:58:12 -0700162 - reboot