4 | 6 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,40 @@ |
0 |
+Reads the OS_* variables set by devstack through openrc |
|
1 |
+for the specified user and project and exports them as |
|
2 |
+the os_env_vars fact. |
|
3 |
+ |
|
4 |
+**WARNING**: this role is meant to be used as porting aid |
|
5 |
+for the non-unified python-<service>client jobs which |
|
6 |
+are already around, as those clients do not use clouds.yaml |
|
7 |
+as openstackclient does. |
|
8 |
+When those clients and their jobs are deprecated and removed, |
|
9 |
+or anyway when the new code is able to read from clouds.yaml |
|
10 |
+directly, this role should be removed as well. |
|
11 |
+ |
|
12 |
+ |
|
13 |
+**Role Variables** |
|
14 |
+ |
|
15 |
+.. zuul:rolevar:: devstack_base_dir |
|
16 |
+ :default: /opt/stack |
|
17 |
+ |
|
18 |
+ The devstack base directory. |
|
19 |
+ |
|
20 |
+.. zuul:rolevar:: openrc_file |
|
21 |
+ :default: {{ devstack_base_dir }}/devstack/openrc |
|
22 |
+ |
|
23 |
+ The location of the generated openrc file. |
|
24 |
+ |
|
25 |
+.. zuul:rolevar:: openrc_user |
|
26 |
+ :default: admin |
|
27 |
+ |
|
28 |
+ The user whose credentials should be retrieved. |
|
29 |
+ |
|
30 |
+.. zuul:rolevar:: openrc_project |
|
31 |
+ :default: admin |
|
32 |
+ |
|
33 |
+ The project (which openrc_user is part of) whose |
|
34 |
+ access data should be retrieved. |
|
35 |
+ |
|
36 |
+.. zuul:rolevar:: openrc_enable_export |
|
37 |
+ :default: false |
|
38 |
+ |
|
39 |
+ Set it to true to export os_env_vars. |
0 | 5 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,14 @@ |
0 |
+- when: openrc_enable_export |
|
1 |
+ block: |
|
2 |
+ - name: Extract the OS_ environment variables |
|
3 |
+ shell: |
|
4 |
+ cmd: | |
|
5 |
+ source {{ openrc_file }} {{ openrc_user }} {{ openrc_project }} &>/dev/null |
|
6 |
+ env | awk -F= 'BEGIN {print "---" } /^OS_/ { print " "$1": \""$2"\""} ' |
|
7 |
+ args: |
|
8 |
+ executable: "/bin/bash" |
|
9 |
+ register: env_os |
|
10 |
+ |
|
11 |
+ - name: Save the OS_ environment variables as a fact |
|
12 |
+ set_fact: |
|
13 |
+ os_env_vars: "{{ env_os.stdout|from_yaml }}" |