
* Decouple few tasks from generate-tempestconf-file-cloud role to a new role named edit-clouds-yaml-file in order to be able to use this logic multiple times. * Add a new role, which creates clouds.yaml file - usefull when a module requires an authentication and an environment doesn't have one (f.e. packstack) Change-Id: I133529857c2b095c2183aa544dc0e45a48b9f34c
50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
- name: get cloud variables
|
|
shell: |
|
|
for key in $( set | awk '{FS="="} /^OS_/ {print $1}' ); do unset $key ; done
|
|
{{ source_credentials_commands }}
|
|
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
|
|
args:
|
|
executable: /bin/bash
|
|
|
|
- debug:
|
|
msg: "{{ cloud_details }}"
|
|
|
|
- name: Remove the file if it exists
|
|
become: yes
|
|
file:
|
|
path: "{{ clouds_file_path | dirname}}"
|
|
state: absent
|
|
|
|
- name: Create directory for clouds.yaml
|
|
become: yes
|
|
file:
|
|
path: "{{ clouds_file_path | dirname}}"
|
|
state: directory
|
|
mode: 0755
|
|
|
|
- name: Create clouds.yaml
|
|
become: yes
|
|
copy:
|
|
content: ""
|
|
dest: "{{ clouds_file_path }}"
|
|
force: yes
|
|
mode: 0666
|
|
|
|
- name: Insert cloud parameters
|
|
become: yes
|
|
lineinfile:
|
|
path: "{{ clouds_file_path }}"
|
|
line: "{{ item }}"
|
|
with_items:
|
|
- "{{ cloud_details.stdout|from_yaml|to_nice_yaml(indent=4) }}"
|
|
|