David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 1 | --- |
David K. Bainbridge | 8db2f30 | 2016-05-19 23:41:13 -0700 | [diff] [blame] | 2 | - 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. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 10 | - name: Applications |
| 11 | become: yes |
alshabib | 54cdbb2 | 2016-06-03 16:37:01 -0700 | [diff] [blame] | 12 | apt: name={{ item }} state=latest force=yes |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 13 | with_items: |
alshabib | 54cdbb2 | 2016-06-03 16:37:01 -0700 | [diff] [blame] | 14 | - build-essential |
David K. Bainbridge | e9f284d | 2016-05-18 14:13:43 -0700 | [diff] [blame] | 15 | - git |
| 16 | - python-pip |
alshabib | 54cdbb2 | 2016-06-03 16:37:01 -0700 | [diff] [blame] | 17 | - ifenslave-2.6 |
David K. Bainbridge | e9f284d | 2016-05-18 14:13:43 -0700 | [diff] [blame] | 18 | |
David K. Bainbridge | 589a08f | 2016-06-15 18:14:18 -0700 | [diff] [blame^] | 19 | - name: Ensure Docker Insecure Repository |
| 20 | become: yes |
| 21 | lineinfile: |
| 22 | dest: /etc/default/docker |
| 23 | line: 'DOCKER_OPTS="$DOCKER_OPTS --insecure-registry docker-registry:5000"' |
| 24 | insertafter: '^DOCKER_OPTS' |
| 25 | register: docker_config |
| 26 | |
| 27 | - name: Docker Restart |
| 28 | become: yes |
| 29 | service: |
| 30 | name=docker |
| 31 | state=restarted |
| 32 | when: docker_config.changed |
| 33 | |
David K. Bainbridge | e9f284d | 2016-05-18 14:13:43 -0700 | [diff] [blame] | 34 | - name: Ensure Docker Ansible Support |
| 35 | become: yes |
| 36 | pip: |
| 37 | name=docker-py |
| 38 | version=0.3.1 |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 39 | |
| 40 | - name: Set Default Password |
| 41 | become: yes |
| 42 | user: |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 43 | name={{ ansible_user }} |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 44 | password="$6$TjhJuOgh8xp.v$z/4GwFbn5koVmkD6Ex9wY7bgP7L3uP2ujZkZSs1HNdzQdz9YclbnZH9GvqMC/M1iwC0MceL05.13HoFz/bai0/" |
David K. Bainbridge | 2a80422 | 2016-05-16 12:36:32 -0700 | [diff] [blame] | 45 | when: '"{{ ansible_user }}" == "ubuntu"' |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 46 | |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 47 | - name: Authorize SSH Key |
| 48 | become: yes |
| 49 | authorized_key: |
| 50 | key="{{ pub_ssh_key }}" |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 51 | user={{ ansible_user }} |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 52 | state=present |
| 53 | |
| 54 | - name: Verify Private SSH Key |
| 55 | become: yes |
| 56 | stat: |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 57 | path=/home/{{ ansible_user }}/.ssh/id_rsa |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 58 | register: private_key |
| 59 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 60 | - name: Ensure SSH Key |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 61 | become: yes |
| 62 | copy: |
| 63 | src=files/{{ item }} |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 64 | dest=/home/{{ ansible_user }}/.ssh/{{ item }} |
| 65 | owner={{ ansible_user }} |
| 66 | group={{ ansible_user }} |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 67 | mode=0600 |
| 68 | with_items: |
| 69 | - id_rsa |
| 70 | - id_rsa.pub |
David K. Bainbridge | 81bda33 | 2016-06-14 22:58:41 -0700 | [diff] [blame] | 71 | - config |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 72 | |
| 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 | |
alshabib | e16ef4c | 2016-05-27 17:13:23 -0700 | [diff] [blame] | 82 | - 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. Bainbridge | 0820cab | 2016-06-02 17:43:32 -0700 | [diff] [blame] | 85 | changed_when: False |
alshabib | e16ef4c | 2016-05-27 17:13:23 -0700 | [diff] [blame] | 86 | |
| 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. Bainbridge | 0820cab | 2016-06-02 17:43:32 -0700 | [diff] [blame] | 90 | changed_when: False |
alshabib | e16ef4c | 2016-05-27 17:13:23 -0700 | [diff] [blame] | 91 | |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 92 | - name: Verify i40e Driver |
| 93 | command: modinfo --field=version i40e |
| 94 | register: i40e_version |
alshabib | e16ef4c | 2016-05-27 17:13:23 -0700 | [diff] [blame] | 95 | when: intel_nic_present.stdout == "1" |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 96 | changed_when: False |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 97 | failed_when: False |
David K. Bainbridge | 4ec841c | 2016-05-11 22:10:15 -0700 | [diff] [blame] | 98 | tags: |
| 99 | - interface_config |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 100 | |
alshabib | e16ef4c | 2016-05-27 17:13:23 -0700 | [diff] [blame] | 101 | - name: Verify mlx4 Driver |
| 102 | command: modinfo --field=version mlx4_core |
| 103 | register: mlx4_version |
| 104 | when: mlx_nic_present.stdout == "1" |
| 105 | changed_when: False |
| 106 | failed_when: False |
| 107 | tags: |
| 108 | - interface_config |
| 109 | |
| 110 | - name: Update mlx4 Driver |
| 111 | include: tasks/mlx4_driver.yml |
| 112 | when: mlx_nic_present.stdout == "1" and mlx4_version.stdout != '3.1-1.0.4' |
| 113 | tags: |
| 114 | - interface_config |
| 115 | |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 116 | - name: Update i40e Driver |
| 117 | include: tasks/i40e_driver.yml |
alshabib | e16ef4c | 2016-05-27 17:13:23 -0700 | [diff] [blame] | 118 | when: intel_nic_present.stdout == "1" and i40e_version.stdout != '1.4.25' |
David K. Bainbridge | 4ec841c | 2016-05-11 22:10:15 -0700 | [diff] [blame] | 119 | tags: |
| 120 | - interface_config |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 121 | |
| 122 | - name: Consistent Interface Naming |
| 123 | become: yes |
David K. Bainbridge | 8db2f30 | 2016-05-19 23:41:13 -0700 | [diff] [blame] | 124 | 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 }} |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 125 | register: ifaces_changed |
David K. Bainbridge | 8db2f30 | 2016-05-19 23:41:13 -0700 | [diff] [blame] | 126 | changed_when: ifaces_changed.stdout.find("true") != -1 |
David K. Bainbridge | 4ec841c | 2016-05-11 22:10:15 -0700 | [diff] [blame] | 127 | tags: |
| 128 | - interface_config |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 129 | |
alshabib | 54cdbb2 | 2016-06-03 16:37:01 -0700 | [diff] [blame] | 130 | - 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. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 141 | - name: Reboot Required |
| 142 | become: yes |
| 143 | command: /sbin/reboot |
David K. Bainbridge | 8db2f30 | 2016-05-19 23:41:13 -0700 | [diff] [blame] | 144 | async: 0 |
David K. Bainbridge | b5e232a | 2016-05-17 13:55:24 -0700 | [diff] [blame] | 145 | poll: 0 |
| 146 | ignore_errors: true |
David K. Bainbridge | df0f7e0 | 2016-05-20 09:18:28 -0700 | [diff] [blame] | 147 | when: ifaces_changed.stdout.find("true") != -1 |
David K. Bainbridge | 4ec841c | 2016-05-11 22:10:15 -0700 | [diff] [blame] | 148 | tags: |
| 149 | - interface_config |
David K. Bainbridge | cd4caeb | 2016-05-23 14:58:12 -0700 | [diff] [blame] | 150 | - reboot |
David K. Bainbridge | b5e232a | 2016-05-17 13:55:24 -0700 | [diff] [blame] | 151 | |
| 152 | - name: Wait For Restart |
David K. Bainbridge | 8db2f30 | 2016-05-19 23:41:13 -0700 | [diff] [blame] | 153 | local_action: wait_for port=22 host={{ inventory_hostname }} search_regex=OpenSSH delay=30 timeout=600 connect_timeout=15 |
David K. Bainbridge | 22d5f3c | 2016-05-20 09:21:56 -0700 | [diff] [blame] | 154 | when: ifaces_changed.stdout.find("true") != -1 |
David K. Bainbridge | ed10154 | 2016-05-18 20:26:15 -0700 | [diff] [blame] | 155 | tags: |
| 156 | - interface_config |
David K. Bainbridge | cd4caeb | 2016-05-23 14:58:12 -0700 | [diff] [blame] | 157 | - reboot |