blob: a9103e9a044fce1253ae620c5a1c843d274aa38e [file] [log] [blame]
Andy Bavier02024e02017-05-09 09:08:41 -04001# 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. Bainbridge5b4dafa2016-11-22 15:48:19 -08009# 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 Bavier02024e02017-05-09 09:08:41 -040012 local_action: user name='{{ username_on_the_host.stdout }}' generate_ssh_key=yes ssh_key_bits=2048
David K. Bainbridge5b4dafa2016-11-22 15:48:19 -080013 tags:
14 - establish_ssh_keys
15
16- name: Ensure Key Authorized on Target Head Node
17 authorized_key:
David K. Bainbridge45e454e2016-11-22 19:20:23 -080018 user: '{{ansible_ssh_user}}'
19 key: "{{lookup('file', '~/.ssh/id_rsa.pub')}}"
David K. Bainbridge5b4dafa2016-11-22 15:48:19 -080020 tags:
21 - establish_ssh_keys
22
David K. Bainbridgeed101542016-05-18 20:26:15 -070023- 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. Bainbridge8b179042016-11-30 15:38:42 -080030 mode="0755"
David K. Bainbridgeed101542016-05-18 20:26:15 -070031
David K. Bainbridge5ba01a92016-08-16 14:58:31 -070032- name: Ensure Ansible Roles
David K. Bainbridgeed101542016-05-18 20:26:15 -070033 become: yes
David K. Bainbridge5b4dafa2016-11-22 15:48:19 -080034 synchronize:
David K. Bainbridgea677d4e2016-09-11 20:01:32 -070035 src: "{{ item }}"
David K. Bainbridge5ba01a92016-08-16 14:58:31 -070036 dest: /etc/maas/ansible
David K. Bainbridgea677d4e2016-09-11 20:01:32 -070037 with_items:
38 - roles
39 - library
David K. Bainbridgeed101542016-05-18 20:26:15 -070040
David K. Bainbridge5ba01a92016-08-16 14:58:31 -070041- name: Ensure Role Permissions and Modes
David K. Bainbridgee18f57b2016-05-23 15:40:58 -070042 become: yes
David K. Bainbridge5ba01a92016-08-16 14:58:31 -070043 file:
David K. Bainbridge141d2ab2016-08-26 13:02:33 -070044 path: /etc/maas/ansible/roles
David K. Bainbridge5ba01a92016-08-16 14:58:31 -070045 owner: maas
46 group: maas
47 mode: u=rwX,g=rX,o=rX
48 state: directory
49 recurse: true
David K. Bainbridgeed101542016-05-18 20:26:15 -070050
David K. Bainbridge0820cab2016-06-02 17:43:32 -070051- name: Ensure Ansible Provisioning Script
52 become: yes
53 copy:
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -070054 dest=/etc/maas/ansible/{{ item }}
55 src=files/{{ item }}
David K. Bainbridge0820cab2016-06-02 17:43:32 -070056 owner=maas
57 group=maas
David K. Bainbridge8b179042016-11-30 15:38:42 -080058 mode="0755"
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -070059 with_items:
60 - do-ansible
61 - do-switch
David K. Bainbridge0820cab2016-06-02 17:43:32 -070062
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. Bainbridge8b179042016-11-30 15:38:42 -080070 mode="0755"
David K. Bainbridge0820cab2016-06-02 17:43:32 -070071
David K. Bainbridge915105d2016-07-06 14:10:08 -070072- 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 Chan3c681622016-08-03 21:53:03 -070078- name: Ensure Compute and Switch Node Playbooks
David K. Bainbridgeed101542016-05-18 20:26:15 -070079 become: yes
David K. Bainbridge10b0c112016-05-24 13:17:23 -070080 template:
David K. Bainbridge96c77e82016-11-07 14:59:43 -080081 src={{ item }}.j2
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -070082 dest=/etc/maas/ansible/{{ item }}
David K. Bainbridgeed101542016-05-18 20:26:15 -070083 owner=maas
84 group=maas
David K. Bainbridge8b179042016-11-30 15:38:42 -080085 mode="0644"
David K. Bainbridgebe58a0d2016-06-22 15:43:02 -070086 with_items:
87 - compute-node.yml
88 - switch-node.yml
Charles Chan3c681622016-08-03 21:53:03 -070089
David K. Bainbridge906a9a12016-08-25 10:50:45 -070090- 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. Bainbridge8b179042016-11-30 15:38:42 -080096 mode="0755"
David K. Bainbridge906a9a12016-08-25 10:50:45 -070097 state=directory
98
99- name: Ensure Compute and Switch Node Variables
100 become: yes
101 template:
Scott Bakerb2b7fd92016-11-01 16:01:38 -0700102 src=templates/compute-node-vars.yml.j2
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700103 dest=/etc/maas/ansible/vars/compute-node-vars.yml
David K. Bainbridge906a9a12016-08-25 10:50:45 -0700104 owner=maas
105 group=maas
David K. Bainbridge8b179042016-11-30 15:38:42 -0800106 mode="0644"
David K. Bainbridge906a9a12016-08-25 10:50:45 -0700107
Charles Chan3c681622016-08-03 21:53:03 -0700108- 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. Bainbridge8b179042016-11-30 15:38:42 -0800115 mode="0644"
Charles Chan3c681622016-08-03 21:53:03 -0700116 with_items:
Charles Chana4ccbde2016-08-02 00:12:34 -0700117 - connect-switch.yml
David K. Bainbridge915105d2016-07-06 14:10:08 -0700118
119- name: Ensure Dynamic Inventory Script
120 become: yes
121 template:
Scott Bakerb2b7fd92016-11-01 16:01:38 -0700122 src=templates/pod-inventory
David K. Bainbridge915105d2016-07-06 14:10:08 -0700123 dest=/etc/maas/ansible/pod-inventory
124 owner=maas
125 group=maas
David K. Bainbridge8b179042016-11-30 15:38:42 -0800126 mode="0755"
David K. Bainbridge7ae4f192016-09-29 09:01:38 -0700127
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. Bainbridge8b179042016-11-30 15:38:42 -0800135 mode="0755"
David K. Bainbridge7ae4f192016-09-29 09:01:38 -0700136 with_items:
137 - cord
138 - cord-harvest
139 - cord-prov
David K. Bainbridge058c3d62016-09-30 15:03:26 -0700140 - cord-switch
141 - cord-generate
David K. Bainbridgec4e0fc52016-11-14 12:03:35 -0800142 - cord-registry
David K. Bainbridge8b179042016-11-30 15:38:42 -0800143
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