Roles for managing clouds.yaml file
* 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
This commit is contained in:
parent
c1951c379e
commit
73cbf531f5
@ -24,6 +24,9 @@
|
||||
- name: ACL devstack files
|
||||
include_role:
|
||||
name: acl-devstack-files
|
||||
- name: Edit clouds.yaml file
|
||||
include_role:
|
||||
name: tempestconf-workaround-auth-url
|
||||
- name: Generate tempest configuration file
|
||||
include_role:
|
||||
name: generate-tempestconf-file
|
||||
|
@ -30,6 +30,12 @@
|
||||
- name: Prepare keystonerc credentials generated by packstack
|
||||
include_role:
|
||||
name: create-keystonerc-files
|
||||
- name: Create clouds.yaml file
|
||||
include_role:
|
||||
name: create-clouds-yaml-file
|
||||
vars:
|
||||
cloudname: "packstack-admin"
|
||||
source_credentials_commands: "source {{ ansible_user_dir }}/keystonerc_admin"
|
||||
- name: Generate configuration file for python-tempestconf
|
||||
include_role:
|
||||
name: generate-tempestconf-file
|
||||
|
28
roles/create-clouds-yaml-file/README.rst
Normal file
28
roles/create-clouds-yaml-file/README.rst
Normal file
@ -0,0 +1,28 @@
|
||||
Creates clouds.yaml file
|
||||
|
||||
Source credentials and create a clouds.yaml file. If the clouds.yaml
|
||||
file in the defined location exists, it will be overwritten.
|
||||
Note: If there is a file int the location, where clouds_file_path points, called
|
||||
openstack, it will be removed and directory called openstack will be created.
|
||||
|
||||
**Role Variables**
|
||||
|
||||
.. zuul:rolevar:: clouds_file_path
|
||||
:type: string
|
||||
:default: /etc/openstack/clouds.yaml
|
||||
|
||||
A path to the clouds.yaml file.
|
||||
|
||||
.. zuul:rolevar:: source_credentials_commands
|
||||
:type: string
|
||||
:default: None
|
||||
|
||||
A file or command to be sourced for obtaining credentials.
|
||||
|
||||
.. zuul:rolevar:: cloudname
|
||||
:type: string
|
||||
:default: None
|
||||
|
||||
A cloudname under which will be sourced credentials saved
|
||||
in clouds.yaml file
|
||||
|
1
roles/create-clouds-yaml-file/defaults/main.yaml
Normal file
1
roles/create-clouds-yaml-file/defaults/main.yaml
Normal file
@ -0,0 +1 @@
|
||||
clouds_file_path: "/etc/openstack/clouds.yaml"
|
49
roles/create-clouds-yaml-file/tasks/main.yaml
Normal file
49
roles/create-clouds-yaml-file/tasks/main.yaml
Normal file
@ -0,0 +1,49 @@
|
||||
- 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) }}"
|
||||
|
@ -23,30 +23,6 @@
|
||||
virtualenv: "{{ virtualenvs.tempestconf }}"
|
||||
chdir: "{{ tempestconf_src_relative_path }}"
|
||||
|
||||
- name: Cat clouds.yaml file
|
||||
shell: |
|
||||
set -ex
|
||||
cat /etc/openstack/clouds.yaml
|
||||
ignore_errors: True
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: "Workaround for AUTH URL in clouds.yaml"
|
||||
replace:
|
||||
path: /etc/openstack/clouds.yaml
|
||||
regexp: "auth_url:.*"
|
||||
replace: "auth_url: http://{{ ansible_default_ipv4.address }}/identity/v3"
|
||||
become: true
|
||||
ignore_errors: True
|
||||
|
||||
- name: Cat edited clouds.yaml file
|
||||
shell: |
|
||||
set -ex
|
||||
cat /etc/openstack/clouds.yaml
|
||||
ignore_errors: True
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Generate tempest configuration file
|
||||
shell: |
|
||||
set -ex
|
||||
|
14
roles/tempestconf-workaround-auth-url/README.rst
Normal file
14
roles/tempestconf-workaround-auth-url/README.rst
Normal file
@ -0,0 +1,14 @@
|
||||
Workaround clouds.yaml file
|
||||
|
||||
Workaround for AUTH URL in clouds.yaml file.
|
||||
auth_url needs to be edited in devstack environment so that
|
||||
it contains "/v3" as a suffix.
|
||||
|
||||
**Role Variables**
|
||||
|
||||
.. zuul:rolevar:: clouds_file_path
|
||||
:type: string
|
||||
:default: /etc/openstack/clouds.yaml
|
||||
|
||||
A path to the clouds.yaml file.
|
||||
|
1
roles/tempestconf-workaround-auth-url/defaults/main.yaml
Normal file
1
roles/tempestconf-workaround-auth-url/defaults/main.yaml
Normal file
@ -0,0 +1 @@
|
||||
clouds_file_path: "/etc/openstack/clouds.yaml"
|
23
roles/tempestconf-workaround-auth-url/tasks/main.yaml
Normal file
23
roles/tempestconf-workaround-auth-url/tasks/main.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
- name: Cat clouds.yaml file
|
||||
shell: |
|
||||
set -ex
|
||||
cat {{ clouds_file_path }}
|
||||
ignore_errors: True
|
||||
args:
|
||||
executable: /bin/bash
|
||||
|
||||
- name: Workaround for AUTH URL in clouds.yaml
|
||||
replace:
|
||||
path: "{{ clouds_file_path }}"
|
||||
regexp: "auth_url:.*"
|
||||
replace: "auth_url: http://{{ ansible_default_ipv4.address }}/identity/v3"
|
||||
become: true
|
||||
ignore_errors: True
|
||||
|
||||
- name: Cat edited clouds.yaml file
|
||||
shell: |
|
||||
set -ex
|
||||
cat {{ clouds_file_path }}
|
||||
ignore_errors: True
|
||||
args:
|
||||
executable: /bin/bash
|
Loading…
Reference in New Issue
Block a user