Skip to content

Commit 7c8e6ef

Browse files
vkhitrinVadim Khitrin
authored andcommitted
openastack_tasks: Fix Undercloud Clouds (Wallaby)
For Wallaby based releases, `stackrc` uses `OS_CLOUD` to point to the undercloud endpoint. This patch fixes clouds generation for Wallaby release. Change-Id: I59c8e441498b6ba78925e4c1a673738fac1aef7b (cherry picked from commit 71e0669)
1 parent 5258431 commit 7c8e6ef

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

roles/post_install/openstack_tasks/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ resource_state: present
2828
### All "clouds" configuration resides within the "~/.config/openstack/clouds.yaml" file.
2929
### A different cloud name could be set on each resource.
3030
### As a result multiple users resources could be created at a single playbook run.
31+
tripleo_default_clouds_file: "{{ ansible_user_dir }}/.config/openstack/clouds.yaml"
3132
cloud_name: overcloud
3233

3334
users:

roles/post_install/openstack_tasks/tasks/clouds.yml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,26 @@
6262
when: not item['stat']['exists']
6363
loop: "{{ stacksrc_files_stat['results'] }}"
6464

65-
- name: Generate Clouds Dictionary
65+
- name: Generate Clouds Dictionary (Undercloud < 17)
6666
set_fact:
67-
clouds_dict: "{{ undercloud_rc | combine(stacks_rc) }}"
67+
clouds_dict: |
68+
{%- if undercloud_version | int < 17 -%}
69+
{{ undercloud_rc | combine(stacks_rc) }}
70+
{%- else -%}
71+
{{ stacks_rc }}
72+
{%- endif -%}
73+
# when: undercloud_version | int < 17
74+
75+
- name: Save TripleO Generated Undercloud Cloud Definition (Undercloud >= 17)
76+
block:
77+
- name: Read TripleO Generated clouds.yaml
78+
ansible.builtin.slurp:
79+
src: "{{ tripleo_default_clouds_file }}"
80+
register: tripleo_default_clouds_content
81+
- name: Derive Undercloud Configuration
82+
ansible.builtin.set_fact:
83+
tripleo_undercloud_cloud_details: "{ 'undercloud': {{ (tripleo_default_clouds_content['content'] | b64decode | from_yaml)['clouds']['undercloud'] }} }"
84+
when: undercloud_version | int >= 17
6885

6986
- name: Add users to clouds.yaml
7087
vars:
@@ -121,9 +138,18 @@
121138
when: "item.rc != 1"
122139
loop: "{{ cloud_details.results | flatten(levels=1) }}"
123140

141+
- name: Insert Default Undercloud >= 17
142+
blockinfile:
143+
dest: "{{ clouds_yaml_file_path }}"
144+
block: |1
145+
{{ tripleo_undercloud_cloud_details | to_nice_yaml(indent=4) }}
146+
insertbefore: "#END UNDERCLOUD SECTION"
147+
marker: "#{mark} UNDERCLOUD PARAMETERS"
148+
when: undercloud_version | int >= 17
149+
124150
- name: Override TripleO Generated File With User File
125151
ansible.builtin.copy:
126152
src: "{{ clouds_yaml_file_path }}"
127-
dest: "{{ ansible_user_dir }}/.config/openstack/clouds.yaml"
153+
dest: "{{ tripleo_default_clouds_file }}"
128154
remote_src: true
129155
when: force_tripleo_clouds_override

roles/post_install/openstack_tasks/tasks/users_clouds.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@
3636
set_fact:
3737
clouds_dict: "{{ clouds_dict | combine({item['name']: stackrc_file | dirname +'/'+ item['name'] + '_rc'}) }}"
3838
loop: "{{ users }}"
39-
when: item.name != 'admin'
39+
when:
40+
- item.name != 'admin'

0 commit comments

Comments
 (0)