- name: get cloud variables shell: | for key in $( set | awk '{FS="="} /^OS_/ {print $1}' ); do unset $key ; done {{ source_credentials_commands }} echo -n "clouds: \ { {{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) }}" - name: Cat the created clouds.yaml file become: yes shell: | set -ex cat {{ clouds_file_path }}