Skip to content

Commit 5f54d97

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 5f54d97

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
3123

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
24+
- block:
25+
- name: Create os-capacity directory
26+
ansible.builtin.file:
27+
path: /opt/kayobe/os-capacity/
28+
state: directory
4129

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
30+
- name: Read admin-openrc credential file
31+
ansible.builtin.command:
32+
cmd: "cat {{ lookup('ansible.builtin.env', 'KOLLA_CONFIG_PATH') }}/admin-openrc.sh"
33+
delegate_to: localhost
34+
register: credential
35+
changed_when: false
4836

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
37+
- name: Set facts for admin credentials
38+
ansible.builtin.set_fact:
39+
stackhpc_os_capacity_auth_url: "{{ credential.stdout_lines | select('match', '.*OS_AUTH_URL*.') | first | split('=') | last | replace(\"'\",'') }}"
40+
stackhpc_os_capacity_project_name: "{{ credential.stdout_lines | select('match', '.*OS_PROJECT_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
41+
stackhpc_os_capacity_domain_name: "{{ credential.stdout_lines | select('match', '.*OS_PROJECT_DOMAIN_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
42+
stackhpc_os_capacity_openstack_region_name: "{{ credential.stdout_lines | select('match', '.*OS_REGION_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
43+
stackhpc_os_capacity_username: "{{ credential.stdout_lines | select('match', '.*OS_USERNAME*.') | first | split('=') | last | replace(\"'\",'') }}"
44+
stackhpc_os_capacity_password: "{{ credential.stdout_lines | select('match', '.*OS_PASSWORD*.') | first | split('=') | last | replace(\"'\",'') }}"
45+
46+
- name: Template clouds.yml
47+
ansible.builtin.template:
48+
src: templates/os_capacity-clouds.yml.j2
49+
dest: /opt/kayobe/os-capacity/clouds.yaml
50+
register: clouds_yaml_result
51+
52+
- name: Copy CA certificate to OpenStack Capacity nodes
53+
ansible.builtin.copy:
54+
src: "{{ stackhpc_os_capacity_openstack_cacert }}"
55+
dest: /opt/kayobe/os-capacity/cacert.pem
56+
when: stackhpc_os_capacity_openstack_cacert | length > 0
57+
register: cacert_result
58+
59+
- name: Ensure os_capacity container is running
60+
community.docker.docker_container:
61+
name: os_capacity
62+
image: ghcr.io/stackhpc/os-capacity:master
63+
env:
64+
OS_CLOUD: openstack
65+
OS_CLIENT_CONFIG_FILE: /etc/openstack/clouds.yaml
66+
mounts:
67+
- type: bind
68+
source: /opt/kayobe/os-capacity/
69+
target: /etc/openstack/
70+
network_mode: host
71+
restart: "{{ clouds_yaml_result is changed or cacert_result is changed }}"
72+
restart_policy: unless-stopped
73+
become: true
74+
when: stackhpc_enable_os_capacity and openrc_file_stat.stat.exists
5775

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

0 commit comments

Comments
 (0)