-
Notifications
You must be signed in to change notification settings - Fork 0
/
clouds.yml
35 lines (32 loc) · 1.39 KB
/
clouds.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
---
- set_fact:
cloudname: "{{ (auth_file_path|basename == 'stackrc') |ternary('undercloud','overcloud') }}"
- name: get cloud variables
shell: |
for key in $( set | awk '{FS="="} /^OS_/ {print $1}' ); do unset $key ; done
source {{ auth_file_path }}
echo -n "{{cloudname}}: \
{'auth': \
{ 'auth_url': '$OS_AUTH_URL', \
'username': '$OS_USERNAME', \
'password': '$OS_PASSWORD', \
$(if [ -n "$OS_USER_DOMAIN_NAME" ]; then echo "'user_domain_name': '${OS_USER_DOMAIN_NAME}',"; fi) \
$(if [ -n "$OS_PROJECT_DOMAIN_NAME" ]; then echo "'project_domain_name': '${OS_PROJECT_DOMAIN_NAME}',"; fi) \
'project_name': '${OS_PROJECT_NAME:-$OS_TENANT_NAME}' \
} $(if [ -n "$OS_IDENTITY_API_VERSION" ]; then echo ",'identity_api_version': '${OS_IDENTITY_API_VERSION}'"; fi) }"
register: cloud_details
- name: create clouds.yaml if doesn't exist
blockinfile:
content: 'clouds:'
dest: "~/clouds.yaml"
marker: "#{mark} HEADER"
create: yes
delegate_to: "{{ groups.shade | first }}"
- name: insert cloud parameters
blockinfile:
dest: "~/clouds.yaml"
block: |5
{{ cloud_details.stdout|from_yaml|to_nice_yaml(indent=4) }}
insertbefore: "#END {{ cloudname }} SECTION"
marker: "#{mark} {{ cloudname }} PARAMETERS"
delegate_to: "{{ groups.shade | first }}"