Andy Bavier | 46f1be4 | 2017-05-09 09:08:41 -0400 | [diff] [blame^] | 1 | # Fetch local user rather than relying on (deprecated) ansible_user |
| 2 | - name: Get the username running the deploy |
| 3 | local_action: command whoami |
| 4 | register: username_on_the_host |
| 5 | tags: |
| 6 | - establish_ssh_keys |
| 7 | - skip_ansible_lint |
| 8 | |
David K. Bainbridge | 5b4dafa | 2016-11-22 15:48:19 -0800 | [diff] [blame] | 9 | # SSH Key access from the current machine to the target node is required for the |
| 10 | # synchronize action to work. |
| 11 | - name: Ensure User SSH Keys |
Andy Bavier | 46f1be4 | 2017-05-09 09:08:41 -0400 | [diff] [blame^] | 12 | local_action: user name='{{ username_on_the_host.stdout }}' generate_ssh_key=yes ssh_key_bits=2048 |
David K. Bainbridge | 5b4dafa | 2016-11-22 15:48:19 -0800 | [diff] [blame] | 13 | tags: |
| 14 | - establish_ssh_keys |
| 15 | |
| 16 | - name: Ensure Key Authorized on Target Head Node |
| 17 | authorized_key: |
David K. Bainbridge | 45e454e | 2016-11-22 19:20:23 -0800 | [diff] [blame] | 18 | user: '{{ansible_ssh_user}}' |
| 19 | key: "{{lookup('file', '~/.ssh/id_rsa.pub')}}" |
David K. Bainbridge | 5b4dafa | 2016-11-22 15:48:19 -0800 | [diff] [blame] | 20 | tags: |
| 21 | - establish_ssh_keys |
| 22 | |
David K. Bainbridge | ed10154 | 2016-05-18 20:26:15 -0700 | [diff] [blame] | 23 | - name: Ensure MAAS Ansible Config Directory |
| 24 | become: yes |
| 25 | file: |
| 26 | path=/etc/maas/ansible |
| 27 | owner=maas |
| 28 | group=maas |
| 29 | state=directory |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 30 | mode="0755" |
David K. Bainbridge | ed10154 | 2016-05-18 20:26:15 -0700 | [diff] [blame] | 31 | |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame] | 32 | - name: Ensure Ansible Roles |
David K. Bainbridge | ed10154 | 2016-05-18 20:26:15 -0700 | [diff] [blame] | 33 | become: yes |
David K. Bainbridge | 5b4dafa | 2016-11-22 15:48:19 -0800 | [diff] [blame] | 34 | synchronize: |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 35 | src: "{{ item }}" |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame] | 36 | dest: /etc/maas/ansible |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 37 | with_items: |
| 38 | - roles |
| 39 | - library |
David K. Bainbridge | ed10154 | 2016-05-18 20:26:15 -0700 | [diff] [blame] | 40 | |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame] | 41 | - name: Ensure Role Permissions and Modes |
David K. Bainbridge | e18f57b | 2016-05-23 15:40:58 -0700 | [diff] [blame] | 42 | become: yes |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame] | 43 | file: |
David K. Bainbridge | 141d2ab | 2016-08-26 13:02:33 -0700 | [diff] [blame] | 44 | path: /etc/maas/ansible/roles |
David K. Bainbridge | 5ba01a9 | 2016-08-16 14:58:31 -0700 | [diff] [blame] | 45 | owner: maas |
| 46 | group: maas |
| 47 | mode: u=rwX,g=rX,o=rX |
| 48 | state: directory |
| 49 | recurse: true |
David K. Bainbridge | ed10154 | 2016-05-18 20:26:15 -0700 | [diff] [blame] | 50 | |
David K. Bainbridge | 0820cab | 2016-06-02 17:43:32 -0700 | [diff] [blame] | 51 | - name: Ensure Ansible Provisioning Script |
| 52 | become: yes |
| 53 | copy: |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 54 | dest=/etc/maas/ansible/{{ item }} |
| 55 | src=files/{{ item }} |
David K. Bainbridge | 0820cab | 2016-06-02 17:43:32 -0700 | [diff] [blame] | 56 | owner=maas |
| 57 | group=maas |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 58 | mode="0755" |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 59 | with_items: |
| 60 | - do-ansible |
| 61 | - do-switch |
David K. Bainbridge | 0820cab | 2016-06-02 17:43:32 -0700 | [diff] [blame] | 62 | |
| 63 | - name: Ensure Provisioning Log Directory |
| 64 | become: yes |
| 65 | file: |
| 66 | path=/etc/maas/ansible/logs |
| 67 | state=directory |
| 68 | owner=maas |
| 69 | group=maas |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 70 | mode="0755" |
David K. Bainbridge | 0820cab | 2016-06-02 17:43:32 -0700 | [diff] [blame] | 71 | |
David K. Bainbridge | 915105d | 2016-07-06 14:10:08 -0700 | [diff] [blame] | 72 | - name: Capture MAAS API Key |
| 73 | become: yes |
| 74 | command: maas-region-admin apikey --username={{ maas.user }} |
| 75 | register: apikey |
| 76 | changed_when: false |
| 77 | |
Charles Chan | 3c68162 | 2016-08-03 21:53:03 -0700 | [diff] [blame] | 78 | - name: Ensure Compute and Switch Node Playbooks |
David K. Bainbridge | ed10154 | 2016-05-18 20:26:15 -0700 | [diff] [blame] | 79 | become: yes |
David K. Bainbridge | 10b0c11 | 2016-05-24 13:17:23 -0700 | [diff] [blame] | 80 | template: |
David K. Bainbridge | 96c77e8 | 2016-11-07 14:59:43 -0800 | [diff] [blame] | 81 | src={{ item }}.j2 |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 82 | dest=/etc/maas/ansible/{{ item }} |
David K. Bainbridge | ed10154 | 2016-05-18 20:26:15 -0700 | [diff] [blame] | 83 | owner=maas |
| 84 | group=maas |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 85 | mode="0644" |
David K. Bainbridge | be58a0d | 2016-06-22 15:43:02 -0700 | [diff] [blame] | 86 | with_items: |
| 87 | - compute-node.yml |
| 88 | - switch-node.yml |
Charles Chan | 3c68162 | 2016-08-03 21:53:03 -0700 | [diff] [blame] | 89 | |
David K. Bainbridge | 906a9a1 | 2016-08-25 10:50:45 -0700 | [diff] [blame] | 90 | - name: Ensure Compute and Switch Variable Directory |
| 91 | become: yes |
| 92 | file: |
| 93 | path=/etc/maas/ansible/vars |
| 94 | owner=maas |
| 95 | group=maas |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 96 | mode="0755" |
David K. Bainbridge | 906a9a1 | 2016-08-25 10:50:45 -0700 | [diff] [blame] | 97 | state=directory |
| 98 | |
| 99 | - name: Ensure Compute and Switch Node Variables |
| 100 | become: yes |
| 101 | template: |
Scott Baker | b2b7fd9 | 2016-11-01 16:01:38 -0700 | [diff] [blame] | 102 | src=templates/compute-node-vars.yml.j2 |
David K. Bainbridge | a677d4e | 2016-09-11 20:01:32 -0700 | [diff] [blame] | 103 | dest=/etc/maas/ansible/vars/compute-node-vars.yml |
David K. Bainbridge | 906a9a1 | 2016-08-25 10:50:45 -0700 | [diff] [blame] | 104 | owner=maas |
| 105 | group=maas |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 106 | mode="0644" |
David K. Bainbridge | 906a9a1 | 2016-08-25 10:50:45 -0700 | [diff] [blame] | 107 | |
Charles Chan | 3c68162 | 2016-08-03 21:53:03 -0700 | [diff] [blame] | 108 | - name: Ensure Connect Switch Ansible Playbook |
| 109 | become: yes |
| 110 | copy: |
| 111 | dest=/etc/maas/ansible/{{ item }} |
| 112 | src=files/{{ item }} |
| 113 | owner=maas |
| 114 | group=maas |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 115 | mode="0644" |
Charles Chan | 3c68162 | 2016-08-03 21:53:03 -0700 | [diff] [blame] | 116 | with_items: |
Charles Chan | a4ccbde | 2016-08-02 00:12:34 -0700 | [diff] [blame] | 117 | - connect-switch.yml |
David K. Bainbridge | 915105d | 2016-07-06 14:10:08 -0700 | [diff] [blame] | 118 | |
| 119 | - name: Ensure Dynamic Inventory Script |
| 120 | become: yes |
| 121 | template: |
Scott Baker | b2b7fd9 | 2016-11-01 16:01:38 -0700 | [diff] [blame] | 122 | src=templates/pod-inventory |
David K. Bainbridge | 915105d | 2016-07-06 14:10:08 -0700 | [diff] [blame] | 123 | dest=/etc/maas/ansible/pod-inventory |
| 124 | owner=maas |
| 125 | group=maas |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 126 | mode="0755" |
David K. Bainbridge | 7ae4f19 | 2016-09-29 09:01:38 -0700 | [diff] [blame] | 127 | |
| 128 | - name: Copy CORD Utility Scripts |
| 129 | become: yes |
| 130 | copy: |
| 131 | src=files/commands/{{ item }} |
| 132 | dest=/usr/local/bin/{{ item }} |
| 133 | owner=root |
| 134 | group=root |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 135 | mode="0755" |
David K. Bainbridge | 7ae4f19 | 2016-09-29 09:01:38 -0700 | [diff] [blame] | 136 | with_items: |
| 137 | - cord |
| 138 | - cord-harvest |
| 139 | - cord-prov |
David K. Bainbridge | 058c3d6 | 2016-09-30 15:03:26 -0700 | [diff] [blame] | 140 | - cord-switch |
| 141 | - cord-generate |
David K. Bainbridge | c4e0fc5 | 2016-11-14 12:03:35 -0800 | [diff] [blame] | 142 | - cord-registry |
David K. Bainbridge | 8b17904 | 2016-11-30 15:38:42 -0800 | [diff] [blame] | 143 | |
| 144 | - name: Ensure SSH Key Storage |
| 145 | become: yes |
| 146 | file: |
| 147 | path: /etc/maas/.ssh |
| 148 | mode: "0755" |
| 149 | owner: maas |
| 150 | group: maas |
| 151 | state: directory |
| 152 | |
| 153 | - name: Copy SSH Key Pair for POD |
| 154 | become: yes |
| 155 | copy: |
| 156 | src: /etc/maas/.ssh/{{item}} |
| 157 | dest: /etc/maas/.ssh/{{item}} |
| 158 | owner: maas |
| 159 | group: maas |
| 160 | mode: "0644" |
| 161 | with_items: |
| 162 | - cord_rsa |
| 163 | - cord_rsa.pub |