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 |
David K. Bainbridge | 73ff2c2 | 2016-05-18 17:13:09 -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: |
| 14 | - build-essential |
David K. Bainbridge | e9f284d | 2016-05-18 14:13:43 -0700 | [diff] [blame] | 15 | - git |
| 16 | - python-pip |
| 17 | |
| 18 | - name: Ensure Docker Ansible Support |
| 19 | become: yes |
| 20 | pip: |
| 21 | name=docker-py |
| 22 | version=0.3.1 |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 23 | |
| 24 | - name: Set Default Password |
| 25 | become: yes |
| 26 | user: |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 27 | name={{ ansible_user }} |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 28 | password="$6$TjhJuOgh8xp.v$z/4GwFbn5koVmkD6Ex9wY7bgP7L3uP2ujZkZSs1HNdzQdz9YclbnZH9GvqMC/M1iwC0MceL05.13HoFz/bai0/" |
David K. Bainbridge | 2a80422 | 2016-05-16 12:36:32 -0700 | [diff] [blame] | 29 | when: '"{{ ansible_user }}" == "ubuntu"' |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 30 | |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 31 | - name: Authorize SSH Key |
| 32 | become: yes |
| 33 | authorized_key: |
| 34 | key="{{ pub_ssh_key }}" |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 35 | user={{ ansible_user }} |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 36 | state=present |
| 37 | |
| 38 | - name: Verify Private SSH Key |
| 39 | become: yes |
| 40 | stat: |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 41 | path=/home/{{ ansible_user }}/.ssh/id_rsa |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 42 | register: private_key |
| 43 | |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 44 | - name: Ensure SSH Key |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 45 | become: yes |
| 46 | copy: |
| 47 | src=files/{{ item }} |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 48 | dest=/home/{{ ansible_user }}/.ssh/{{ item }} |
| 49 | owner={{ ansible_user }} |
| 50 | group={{ ansible_user }} |
David K. Bainbridge | 39d0c78 | 2016-05-11 13:27:57 -0700 | [diff] [blame] | 51 | mode=0600 |
| 52 | with_items: |
| 53 | - id_rsa |
| 54 | - id_rsa.pub |
| 55 | |
| 56 | - name: Ensure CORD SUDO |
| 57 | become: yes |
| 58 | copy: |
| 59 | src=files/99-cord-sudoers |
| 60 | dest=/etc/sudoers.d/99-cord-sudoers |
| 61 | owner=root |
| 62 | group=root |
| 63 | mode=0600 |
| 64 | |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 65 | - name: Verify i40e Driver |
| 66 | command: modinfo --field=version i40e |
| 67 | register: i40e_version |
| 68 | changed_when: False |
David K. Bainbridge | b541504 | 2016-05-13 17:06:10 -0700 | [diff] [blame] | 69 | failed_when: False |
David K. Bainbridge | 4ec841c | 2016-05-11 22:10:15 -0700 | [diff] [blame] | 70 | tags: |
| 71 | - interface_config |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 72 | |
| 73 | - name: Update i40e Driver |
| 74 | include: tasks/i40e_driver.yml |
| 75 | when: i40e_version.stdout != '1.4.25' |
David K. Bainbridge | 4ec841c | 2016-05-11 22:10:15 -0700 | [diff] [blame] | 76 | tags: |
| 77 | - interface_config |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 78 | |
| 79 | - name: Consistent Interface Naming |
| 80 | become: yes |
David K. Bainbridge | 8db2f30 | 2016-05-19 23:41:13 -0700 | [diff] [blame] | 81 | 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] | 82 | register: ifaces_changed |
David K. Bainbridge | 8db2f30 | 2016-05-19 23:41:13 -0700 | [diff] [blame] | 83 | changed_when: ifaces_changed.stdout.find("true") != -1 |
David K. Bainbridge | 4ec841c | 2016-05-11 22:10:15 -0700 | [diff] [blame] | 84 | tags: |
| 85 | - interface_config |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 86 | |
| 87 | - name: Reboot Required |
| 88 | become: yes |
| 89 | command: /sbin/reboot |
David K. Bainbridge | 8db2f30 | 2016-05-19 23:41:13 -0700 | [diff] [blame] | 90 | async: 0 |
David K. Bainbridge | b5e232a | 2016-05-17 13:55:24 -0700 | [diff] [blame] | 91 | poll: 0 |
| 92 | ignore_errors: true |
David K. Bainbridge | 317e7d7 | 2016-05-11 08:31:44 -0700 | [diff] [blame] | 93 | when: ifaces_changed.stdout != "false" |
David K. Bainbridge | 4ec841c | 2016-05-11 22:10:15 -0700 | [diff] [blame] | 94 | tags: |
| 95 | - interface_config |
David K. Bainbridge | b5e232a | 2016-05-17 13:55:24 -0700 | [diff] [blame] | 96 | |
| 97 | - name: Wait For Restart |
David K. Bainbridge | 8db2f30 | 2016-05-19 23:41:13 -0700 | [diff] [blame] | 98 | local_action: wait_for port=22 host={{ inventory_hostname }} search_regex=OpenSSH delay=30 timeout=600 connect_timeout=15 |
| 99 | when: ifaces_changed.stdout != "false" |
David K. Bainbridge | ed10154 | 2016-05-18 20:26:15 -0700 | [diff] [blame] | 100 | tags: |
| 101 | - interface_config |