This repository has been archived by the owner on Feb 29, 2024. It is now read-only.
/
main.yml
181 lines (164 loc) · 5.73 KB
/
main.yml
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
---
- name: Gather ansible distribution
setup:
gather_subset: "!min,distribution"
when: ansible_distribution is not defined
- name: Cache tempest network cidr
set_fact:
tempest_cidr: "{{ undercloud_network_cidr }}"
when: use_os_tempest is defined
# tasks file for all_in_one
- name: Set hostname
hostname:
name: "{{ standalone_hostname }}"
become: true
# standalone params
- name: Create the standalone params
template:
src: "{{ standalone_config }}"
dest: "{{ working_dir}}/standalone_parameters.yaml"
mode: 0755
- name: Create container parameters script
template:
src: "{{ standalone_container_prep_script }}"
dest: "{{ working_dir }}/standalone-container-prep.sh"
mode: "0755"
- name: Run container prepare
shell: >
set -o pipefail &&
{{ working_dir }}/standalone-container-prep.sh 2>&1 {{ timestamper_cmd }} > {{ working_dir }}/{{ standalone_container_prep_log }}
# update the registry to rdo or docker.io
- name: update registry if needed in container-prepare-parameters.yaml
when:
- docker_registry_host != '' and docker_registry_namespace != ''
vars:
yaml_file: "{{ working_dir }}/containers-prepare-parameters.yaml"
container_image_prep_updates:
set:
namespace: "{{ docker_registry_host }}/{{ docker_registry_namespace }}"
initial_dict: |
{{ lookup('file', yaml_file) | from_yaml }}
merged_dict:
parameter_defaults:
ContainerImagePrepare:
- |
{{ initial_dict.parameter_defaults.ContainerImagePrepare |
combine(container_image_prep_updates, recursive=true) }}
copy:
content: "{{ merged_dict | to_nice_yaml }}"
dest: "{{ yaml_file }}"
backup: true
# update the container tag to match dlrn hash
- name: update container tag if needed in container-prepare-parameters.yaml
when:
- container_build_id != ''
vars:
yaml_file: "{{ working_dir }}/containers-prepare-parameters.yaml"
container_image_prep_updates:
set:
tag: "{{ container_build_id }}"
initial_dict: |
{{ lookup('file', yaml_file) | from_yaml }}
merged_dict:
parameter_defaults:
ContainerImagePrepare:
- |
{{ initial_dict.parameter_defaults.ContainerImagePrepare |
combine(container_image_prep_updates, recursive=true) }}
copy:
content: "{{ merged_dict | to_nice_yaml }}"
dest: "{{ yaml_file }}"
backup: true
# in extra-common/defaults
# docker_prep_prefix: "{{ ansible_distribution | lower }}-binary-"
- name: update container name_prefix for the appropriate distro
vars:
yaml_file: "{{ working_dir }}/containers-prepare-parameters.yaml"
container_image_prep_updates:
set:
name_prefix: "{{ docker_prep_prefix }}"
initial_dict: |
{{ lookup('file', yaml_file) | from_yaml }}
merged_dict:
parameter_defaults:
ContainerImagePrepare:
- |
{{ initial_dict.parameter_defaults.ContainerImagePrepare |
combine(container_image_prep_updates, recursive=true) }}
copy:
content: "{{ merged_dict | to_nice_yaml }}"
dest: "{{ yaml_file }}"
backup: true
# update params for container update
- name: Add updates to container-prepare-parameters.yaml
when:
- standalone_container_prep_updates
vars:
yaml_file: "{{ working_dir }}/containers-prepare-parameters.yaml"
container_image_prep_updates:
- push_destination: "{{ local_docker_registry_host }}:8787"
tag_from_label: null
modify_role: tripleo-modify-image
modify_append_tag: "{{ update_containers_append_tag }}"
modify_only_with_labels:
- kolla_version
modify_vars:
tasks_from: yum_update.yml
yum_repos_dir_path: /etc/yum.repos.d
update_repo: "{{ standalone_container_prep_update_repo }}"
initial_dict: |
{{ lookup('file', yaml_file) | from_yaml }}
merged_dict:
parameter_defaults:
DockerInsecureRegistryAddress:
- "{{ local_docker_registry_host }}:8787"
ContainerImagePrepare:
- |
{{ initial_dict.parameter_defaults.ContainerImagePrepare |
combine(container_image_prep_updates, recursive=true) }}
copy:
content: "{{ merged_dict | to_nice_yaml }}"
dest: "{{ yaml_file }}"
backup: true
- name: Create the deploy command for standalone
template:
src: "{{ standalone_deploy_script }}"
dest: "{{ working_dir}}/standalone.sh"
mode: 0755
- name: Run dstat on the standalone prior to standalone deploy
include_role:
name: validate-perf
- name: Deploy the standalone
shell: >
set -o pipefail &&
{{ working_dir }}/standalone.sh 2>&1 {{ timestamper_cmd }} > {{ working_dir }}/{{ standalone_deploy_log }}
- when: standalone_ansible_lint|default(false)|bool
vars:
quickstart_venv: "{{ lookup('env','OPT_WORKDIR') }}"
block:
- name: Install ansible-lint
pip:
name: ansible-lint
state: latest
virtualenv: "{{ quickstart_venv }}"
- name: List playbooks
shell: "find $(ls -rtd {{ working_dir }}/undercloud-ansible-* | tail -1)/ -name '*playbook*.yaml'"
register: playbooks
# We ignore (for now) the lint (rc==2), only catch syntax error
# (rc==1).
- name: Lint playbooks
shell: >
source {{ quickstart_venv }}/bin/activate;
exec 1>>{{ working_dir }}/{{standalone_ansible_lint_log}};
exec 2>&1;
echo LINTING {{item}};
ansible-lint -v {{item}};
rc=$?;
echo DONE rc=$rc;
exit $rc
register: lint_result
environment:
ANSIBLE_LIBRARY: |
/usr/share/ansible-modules/:{{lookup('env', 'ANSIBLE_LIBRARY')}}
with_items: "{{ playbooks.stdout_lines }}"
failed_when: lint_result.rc == 1