Skip to content

Commit 77dce90

Browse files
committed
fix: test if admin-openrc.sh exists before deploying os-capacity
During service deploys using Kayobe Automation this playbook will fail as the `admin-openrc.sh` file is not generated during the deployment process. This in turn causes the workflow to be reported as a failure even though the service deployment succeeded.
1 parent 32bb55c commit 77dce90

File tree

1 file changed

+53
-51
lines changed

1 file changed

+53
-51
lines changed

etc/kayobe/ansible/deploy-os-capacity-exporter.yml

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,59 +15,61 @@
1515
tags: os_capacity
1616
gather_facts: false
1717
tasks:
18-
- name: Create os-capacity directory
19-
ansible.builtin.file:
20-
path: /opt/kayobe/os-capacity/
21-
state: directory
22-
when: stackhpc_enable_os_capacity
23-
24-
- name: Read admin-openrc credential file
25-
ansible.builtin.command:
26-
cmd: "cat {{ lookup('ansible.builtin.env', 'KOLLA_CONFIG_PATH') }}/admin-openrc.sh"
18+
- name: Check if admin-openrc.sh exists
19+
ansible.builtin.stat:
20+
path: "{{ lookup('ansible.builtin.env', 'KOLLA_CONFIG_PATH') }}/admin-openrc.sh"
2721
delegate_to: localhost
28-
register: credential
29-
when: stackhpc_enable_os_capacity
30-
changed_when: false
22+
register: openrc_file_stat
23+
run_once: true
3124

32-
- name: Set facts for admin credentials
33-
ansible.builtin.set_fact:
34-
stackhpc_os_capacity_auth_url: "{{ credential.stdout_lines | select('match', '.*OS_AUTH_URL*.') | first | split('=') | last | replace(\"'\",'') }}"
35-
stackhpc_os_capacity_project_name: "{{ credential.stdout_lines | select('match', '.*OS_PROJECT_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
36-
stackhpc_os_capacity_domain_name: "{{ credential.stdout_lines | select('match', '.*OS_PROJECT_DOMAIN_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
37-
stackhpc_os_capacity_openstack_region_name: "{{ credential.stdout_lines | select('match', '.*OS_REGION_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
38-
stackhpc_os_capacity_username: "{{ credential.stdout_lines | select('match', '.*OS_USERNAME*.') | first | split('=') | last | replace(\"'\",'') }}"
39-
stackhpc_os_capacity_password: "{{ credential.stdout_lines | select('match', '.*OS_PASSWORD*.') | first | split('=') | last | replace(\"'\",'') }}"
40-
when: stackhpc_enable_os_capacity
25+
- block:
26+
- name: Create os-capacity directory
27+
ansible.builtin.file:
28+
path: /opt/kayobe/os-capacity/
29+
state: directory
4130

42-
- name: Template clouds.yml
43-
ansible.builtin.template:
44-
src: templates/os_capacity-clouds.yml.j2
45-
dest: /opt/kayobe/os-capacity/clouds.yaml
46-
when: stackhpc_enable_os_capacity
47-
register: clouds_yaml_result
31+
- name: Read admin-openrc credential file
32+
ansible.builtin.command:
33+
cmd: "cat {{ lookup('ansible.builtin.env', 'KOLLA_CONFIG_PATH') }}/admin-openrc.sh"
34+
delegate_to: localhost
35+
register: credential
36+
changed_when: false
4837

49-
- name: Copy CA certificate to OpenStack Capacity nodes
50-
ansible.builtin.copy:
51-
src: "{{ stackhpc_os_capacity_openstack_cacert }}"
52-
dest: /opt/kayobe/os-capacity/cacert.pem
53-
when:
54-
- stackhpc_enable_os_capacity
55-
- stackhpc_os_capacity_openstack_cacert | length > 0
56-
register: cacert_result
38+
- name: Set facts for admin credentials
39+
ansible.builtin.set_fact:
40+
stackhpc_os_capacity_auth_url: "{{ credential.stdout_lines | select('match', '.*OS_AUTH_URL*.') | first | split('=') | last | replace(\"'\",'') }}"
41+
stackhpc_os_capacity_project_name: "{{ credential.stdout_lines | select('match', '.*OS_PROJECT_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
42+
stackhpc_os_capacity_domain_name: "{{ credential.stdout_lines | select('match', '.*OS_PROJECT_DOMAIN_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
43+
stackhpc_os_capacity_openstack_region_name: "{{ credential.stdout_lines | select('match', '.*OS_REGION_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
44+
stackhpc_os_capacity_username: "{{ credential.stdout_lines | select('match', '.*OS_USERNAME*.') | first | split('=') | last | replace(\"'\",'') }}"
45+
stackhpc_os_capacity_password: "{{ credential.stdout_lines | select('match', '.*OS_PASSWORD*.') | first | split('=') | last | replace(\"'\",'') }}"
5746

58-
- name: Ensure os_capacity container is running
59-
community.docker.docker_container:
60-
name: os_capacity
61-
image: ghcr.io/stackhpc/os-capacity:master
62-
env:
63-
OS_CLOUD: openstack
64-
OS_CLIENT_CONFIG_FILE: /etc/openstack/clouds.yaml
65-
mounts:
66-
- type: bind
67-
source: /opt/kayobe/os-capacity/
68-
target: /etc/openstack/
69-
network_mode: host
70-
restart: "{{ clouds_yaml_result is changed or cacert_result is changed }}"
71-
restart_policy: unless-stopped
72-
become: true
73-
when: stackhpc_enable_os_capacity
47+
- name: Template clouds.yml
48+
ansible.builtin.template:
49+
src: templates/os_capacity-clouds.yml.j2
50+
dest: /opt/kayobe/os-capacity/clouds.yaml
51+
register: clouds_yaml_result
52+
53+
- name: Copy CA certificate to OpenStack Capacity nodes
54+
ansible.builtin.copy:
55+
src: "{{ stackhpc_os_capacity_openstack_cacert }}"
56+
dest: /opt/kayobe/os-capacity/cacert.pem
57+
when: stackhpc_os_capacity_openstack_cacert | length > 0
58+
register: cacert_result
59+
60+
- name: Ensure os_capacity container is running
61+
community.docker.docker_container:
62+
name: os_capacity
63+
image: ghcr.io/stackhpc/os-capacity:master
64+
env:
65+
OS_CLOUD: openstack
66+
OS_CLIENT_CONFIG_FILE: /etc/openstack/clouds.yaml
67+
mounts:
68+
- type: bind
69+
source: /opt/kayobe/os-capacity/
70+
target: /etc/openstack/
71+
network_mode: host
72+
restart: "{{ clouds_yaml_result is changed or cacert_result is changed }}"
73+
restart_policy: unless-stopped
74+
become: true
75+
when: stackhpc_enable_os_capacity and openrc_file_stat.stat.exists

0 commit comments

Comments
 (0)