blob: b5d9c3a11d12a87fc8f345b2c54c7eaa05b60b55 [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
32- name: Docker Restart
33 become: yes
34 service:
35 name=docker
36 state=restarted
37 when: docker_config.changed
38
David K. Bainbridgee9f284d2016-05-18 14:13:43 -070039- name: Ensure Docker Ansible Support
40 become: yes
41 pip:
42 name=docker-py
43 version=0.3.1
David K. Bainbridge317e7d72016-05-11 08:31:44 -070044
45- name: Set Default Password
46 become: yes
47 user:
David K. Bainbridgeb5415042016-05-13 17:06:10 -070048 name={{ ansible_user }}
David K. Bainbridge317e7d72016-05-11 08:31:44 -070049 password="$6$TjhJuOgh8xp.v$z/4GwFbn5koVmkD6Ex9wY7bgP7L3uP2ujZkZSs1HNdzQdz9YclbnZH9GvqMC/M1iwC0MceL05.13HoFz/bai0/"
David K. Bainbridge2a804222016-05-16 12:36:32 -070050 when: '"{{ ansible_user }}" == "ubuntu"'
David K. Bainbridge317e7d72016-05-11 08:31:44 -070051
David K. Bainbridge39d0c782016-05-11 13:27:57 -070052- name: Authorize SSH Key
53 become: yes
54 authorized_key:
55 key="{{ pub_ssh_key }}"
David K. Bainbridgeb5415042016-05-13 17:06:10 -070056 user={{ ansible_user }}
David K. Bainbridge39d0c782016-05-11 13:27:57 -070057 state=present
58
59- name: Verify Private SSH Key
60 become: yes
61 stat:
David K. Bainbridgeb5415042016-05-13 17:06:10 -070062 path=/home/{{ ansible_user }}/.ssh/id_rsa
David K. Bainbridge39d0c782016-05-11 13:27:57 -070063 register: private_key
64
David K. Bainbridgeb5415042016-05-13 17:06:10 -070065- name: Ensure SSH Key
Andy Bavierceab2302016-07-07 09:04:07 -040066 become: no
David K. Bainbridge39d0c782016-05-11 13:27:57 -070067 copy:
68 src=files/{{ item }}
Andy Bavierceab2302016-07-07 09:04:07 -040069 dest={{ ansible_env['PWD'] }}/.ssh/{{ item }}
David K. Bainbridgeb5415042016-05-13 17:06:10 -070070 owner={{ ansible_user }}
David K. Bainbridge39d0c782016-05-11 13:27:57 -070071 mode=0600
72 with_items:
73 - id_rsa
74 - id_rsa.pub
David K. Bainbridge81bda332016-06-14 22:58:41 -070075 - config
David K. Bainbridge39d0c782016-05-11 13:27:57 -070076
77- name: Ensure CORD SUDO
78 become: yes
79 copy:
80 src=files/99-cord-sudoers
81 dest=/etc/sudoers.d/99-cord-sudoers
82 owner=root
83 group=root
84 mode=0600
85
alshabibe16ef4c2016-05-27 17:13:23 -070086- name: Verify Mellanox 40Gb NIC
87 shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c ConnectX-3 || true
88 register: mlx_nic_present
David K. Bainbridge0820cab2016-06-02 17:43:32 -070089 changed_when: False
alshabibe16ef4c2016-05-27 17:13:23 -070090
91- name: Verify Intel 40Gb NIC
92 shell: /usr/bin/lspci | grep "Ethernet controller" | grep -c "XL710 for 40GbE QSFP+" || true
93 register: intel_nic_present
David K. Bainbridge0820cab2016-06-02 17:43:32 -070094 changed_when: False
alshabibe16ef4c2016-05-27 17:13:23 -070095
David K. Bainbridge317e7d72016-05-11 08:31:44 -070096- name: Verify i40e Driver
97 command: modinfo --field=version i40e
98 register: i40e_version
David K. Bainbridge10a8b982016-06-28 10:43:44 -070099 when: intel_nic_present.stdout != "0"
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700100 changed_when: False
David K. Bainbridgeb5415042016-05-13 17:06:10 -0700101 failed_when: False
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700102 tags:
103 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700104
alshabibe16ef4c2016-05-27 17:13:23 -0700105- name: Verify mlx4 Driver
106 command: modinfo --field=version mlx4_core
107 register: mlx4_version
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700108 when: mlx_nic_present.stdout != "0"
alshabibe16ef4c2016-05-27 17:13:23 -0700109 changed_when: False
110 failed_when: False
111 tags:
112 - interface_config
113
114- name: Update mlx4 Driver
115 include: tasks/mlx4_driver.yml
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700116 when: mlx_nic_present.stdout != "0" and mlx4_version.stdout != '3.1-1.0.4'
alshabibe16ef4c2016-05-27 17:13:23 -0700117 tags:
118 - interface_config
119
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700120- name: Update i40e Driver
121 include: tasks/i40e_driver.yml
David K. Bainbridge10a8b982016-06-28 10:43:44 -0700122 when: intel_nic_present.stdout != "0" and i40e_version.stdout != '1.4.25'
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700123 tags:
124 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700125
126- name: Consistent Interface Naming
127 become: yes
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700128 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 -0700129 register: ifaces_changed
David K. Bainbridge8db2f302016-05-19 23:41:13 -0700130 changed_when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700131 tags:
132 - interface_config
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700133
alshabib54cdbb22016-06-03 16:37:01 -0700134- name: Load modules at boot
135 become: yes
136 lineinfile:
137 dest: /etc/modules
138 line: "{{ item }}"
139 with_items:
140 - lp
141 - loop
142 - rtc
143 - bonding
144
David K. Bainbridge317e7d72016-05-11 08:31:44 -0700145- name: Reboot Required
146 become: yes
147 command: /sbin/reboot
David K. Bainbridge8db2f302016-05-19 23:41:13 -0700148 async: 0
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700149 poll: 0
150 ignore_errors: true
David K. Bainbridgedf0f7e02016-05-20 09:18:28 -0700151 when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridge4ec841c2016-05-11 22:10:15 -0700152 tags:
153 - interface_config
David K. Bainbridgecd4caeb2016-05-23 14:58:12 -0700154 - reboot
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700155
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700156- name: Ensure Port Defined
157 set_fact:
158 ansible_ssh_port: 22
159 when: ansible_ssh_port is not defined
160
David K. Bainbridgeb5e232a2016-05-17 13:55:24 -0700161- name: Wait For Restart
David K. Bainbridge9d1e02d2016-06-22 09:22:16 -0700162 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 -0700163 when: ifaces_changed.stdout.find("true") != -1
David K. Bainbridgeed101542016-05-18 20:26:15 -0700164 tags:
165 - interface_config
David K. Bainbridgecd4caeb2016-05-23 14:58:12 -0700166 - reboot