/
deploy_multinode_devstack.yaml
195 lines (183 loc) · 5.63 KB
/
deploy_multinode_devstack.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
---
# TODO: factor this out into a caching role
- name: ensure local cache dirs
hosts: localhost
tasks:
- block:
- name: ensure local cache
file:
path: '~/.cache/ard'
state: directory
- name: ensure local pip cache
file:
path: '~/.cache/ard/pip'
state: directory
- name: ensure local apt cache
file:
path: '~/.cache/ard/apt'
state: directory
- name: ensure local dnf cache
file:
path: '~/.cache/ard/dnf'
state: directory
- name: ensure local git cache
file:
path: '~/.cache/ard/repos'
state: directory
when: "use_local_cache | default(true) | bool"
tags:
- common
- cache
- name: execute devstack_common on all hosts
import_playbook: devstack_common.yaml
tags:
- common
- name: configure vdpa
import_playbook: vdpa.yaml
tags:
- common
- vdpa
# note that syncing the cache need to happen after the devstack_common
# role has run to ensure rsync is installed on the target hosts.
# when the cacheing is refarctored into push cache and pull cache roles
# we can relax this requriement by having the cache roles ensure its installed.
- name: push remote cache dirs
hosts: all
tags:
- common
- cache
tasks:
- block:
- name: push apt cache
become: yes
when: ansible_facts.os_family == 'Debian'
synchronize:
src: '~/.cache/ard/apt'
dest: /var/cache/
- name: push dnf cache
become: yes
when: ansible_facts.os_family == 'RedHat'
synchronize:
src: '~/.cache/ard/dnf'
dest: /var/cache/
- name: create pip cache
become: yes
ansible.builtin.file:
path: '/opt/pip'
state: directory
mode: '0777'
owner: root
group: root
- name: push pip cache
become: yes
synchronize:
src: '~/.cache/ard/pip'
dest: /opt/
- name: set pip cache permissions
become: yes
ansible.builtin.file:
path: '/opt/pip'
state: directory
mode: '0777'
recurse: yes
owner: root
group: root
- name: enable global pip cache
become: yes
copy:
dest: /etc/pip.conf
content: |
[global]
download-cache=/opt/pip
cache-dir=/opt/pip
- name: find git dirs
shell: "ls ~/.cache/ard/repos/*/.git | awk -F '/' '/.git:/ {print $7}'"
register: repo_names
delegate_to: localhost
run_once: yes
- name: push repos
become_user: stack
become: yes
synchronize:
dest: '/opt/stack/'
src: '~/.cache/ard/repos/{{item}}'
with_items: "{{repo_names.stdout_lines}}"
when: "use_local_cache | default(true) | bool"
- name: "deploy devstack controller"
tags: controller
import_playbook: devstack_controller.yaml
- name: export facts
hosts: all
tasks:
- name: set nodepool facts
set_fact:
nodepool:
private_ipv4: "{{ hostvars[inventory_hostname]['ansible_facts']['default_ipv4']['address'] }}"
public_ipv4: "{{ hostvars[inventory_hostname]['ansible_facts']['default_ipv4']['address'] }}"
zuul:
executor:
log_root: /tmp/zuul_logs
work_root: /tmp/work_root
- name: sync controller data to subnodes
hosts: subnode
roles:
- {
role: sync-devstack-data,
when: "(run_devstack | default(true) | bool) and (controller_services_extra is defined and controller_services_extra['tls-proxy'] is defined and controller_services_extra['tls-proxy'] | bool)"
}
- name: sync ceph configs to subnodes
hosts: subnode
roles:
- { role: sync-controller-ceph-conf-and-keys, when: "enable_ceph | default(false) | bool"}
- name: "deploy devstack compute(s)"
import_playbook: devstack_compute.yaml
- name: Discover hosts
hosts: controller
tasks:
- name: run discover hosts once on controller
become: yes
become_user: stack
run_once: true
when: "run_devstack | default(true) | bool"
shell: ./tools/discover_hosts.sh
args:
chdir: "{{ repos_dir | default('/opt/repos') }}/devstack"
# TODO: factor this out into a caching role
- name: pull remote cache dirs
hosts: controller
tasks:
- block:
- name: pull apt cache
become: yes
when: ansible_facts.os_family == 'Debian'
synchronize:
mode: pull
src: /var/cache/apt
dest: '~/.cache/ard/'
rsync_opts:
- "--exclude=/var/cache/apt/archives/lock"
- name: pull dnf cache
become: yes
when: ansible_facts.os_family == 'RedHat'
synchronize:
mode: pull
src: /var/cache/dnf
dest: '~/.cache/ard/'
- name: pull pip cache
become: yes
synchronize:
mode: pull
src: /opt/pip
dest: '~/.cache/ard'
- name: find git dirs
shell: "ls /opt/stack/*/.git | awk -F '/' '/.git:/ {print $4}' | grep -v requirements"
register: repo_names
- name: pull repos
become_user: stack
become: yes
synchronize:
mode: pull
src: '/opt/stack/{{ item }}'
dest: '~/.cache/ard/repos/'
with_items: "{{repo_names.stdout_lines}}"
when: "use_local_cache | default(true) | bool"