Skip to content

Commit 3d4c2d3

Browse files
Post service deploy hook for OpenStack Capacity
1 parent 99a3cac commit 3d4c2d3

File tree

6 files changed

+62
-48
lines changed

6 files changed

+62
-48
lines changed

doc/source/configuration/monitoring.rst

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -141,58 +141,41 @@ OpenStack Capacity
141141
==================
142142

143143
OpenStack Capacity allows you to see how much space you have available
144-
in your cloud. StackHPC Kayobe Config includes a playbook for manual
145-
deployment, and it's necessary that some variables are set before
146-
running this playbook.
144+
in your cloud. StackHPC Kayobe Config will deploy OpenStack Capacity
145+
by default on a service deploy, this can be disabled by setting
146+
``stackhpc_enable_os_capacity`` to false.
147147

148-
To successfully deploy OpenStack Capacity, you are required to specify
149-
the OpenStack application credentials in ``kayobe/secrets.yml`` as:
148+
OpenStack Capacity is deployed automatically using a service deploy hook
149+
with the generated kolla-ansible admin credentials, you can override these
150+
by setting the authentication url, username, password, project name and
151+
project domain name in ``stackhpc-monitoring.yml``:
150152

151153
.. code-block:: yaml
152154
153-
secrets_os_capacity_credential_id: <some_credential_id>
154-
secrets_os_capacity_credential_secret: <some_credential_secret>
155+
stackhpc_os_capacity_auth_url: <keystone_auth_url>
156+
stackhpc_os_capacity_username: <openstack_username>
157+
stackhpc_os_capacity_password: <openstack_password_encrypted_with_vault>
158+
stackhpc_os_capacity_project_name: <openstack_project_name>
159+
stackhpc_os_capacity_domain_name: <openstack_project_domain_name>
160+
stackhpc_os_capacity_openstack_region_name: <openstack_region_name>
155161
156-
The Keystone authentication URL and OpenStack region can be changed
157-
from their defaults in ``stackhpc-monitoring.yml`` should you need to
158-
set a different OpenStack region for your cloud. The authentication
159-
URL is set to use ``kolla_internal_fqdn`` by default:
160-
161-
.. code-block:: yaml
162-
163-
stackhpc_os_capacity_auth_url: <some_authentication_url>
164-
stackhpc_os_capacity_openstack_region_name: <some_openstack_region>
165-
166-
Additionally, you are required to enable a conditional flag to allow
167-
HAProxy and Prometheus configuration to be templated during deployment.
168-
169-
.. code-block:: yaml
170-
171-
stackhpc_enable_os_capacity: true
172-
173-
If you are deploying in a cloud with internal TLS, you may be required
162+
Additionally, you should ensure these credentials have the correct permissions
163+
for the exporter. If you are deploying in a cloud with internal TLS, you may be required
174164
to disable certificate verification for the OpenStack Capacity exporter
175165
if your certificate is not signed by a trusted CA.
176166

177167
.. code-block:: yaml
178168
179169
stackhpc_os_capacity_openstack_verify: false
180170
181-
After defining your credentials, you may deploy OpenStack Capacity
182-
using the ``ansible/deploy-os-capacity-exporter.yml`` Ansible playbook
171+
If you've modified your credentials, you will need to re-deploy OpenStack Capacity
172+
using the ``deploy-os-capacity-exporter.yml`` Ansible playbook
183173
via Kayobe.
184174

185175
.. code-block:: console
186176
187177
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/deploy-os-capacity-exporter.yml
188178
189-
It is required that you re-configure the Prometheus, Grafana and HAProxy
190-
services following deployment, to do this run the following Kayobe command.
191-
192-
.. code-block:: console
193-
194-
kayobe overcloud service reconfigure -kt grafana,prometheus,loadbalancer
195-
196179
If you notice ``HaproxyServerDown`` or ``HaproxyBackendDown`` prometheus
197180
alerts after deployment it's likely the os_exporter secrets have not been
198181
set correctly, double check you have entered the correct authentication

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

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,51 @@
11
---
2-
- hosts: monitoring
3-
gather_facts: false
42

3+
- name: Remove legacy os_exporter.cfg file
4+
hosts: network
5+
gather_facts: false
56
tasks:
67
- name: Ensure legacy os_exporter.cfg config file is deleted
78
ansible.builtin.file:
89
path: /etc/kolla/haproxy/services.d/os_exporter.cfg
910
state: absent
10-
delegate_to: network
1111
become: true
12+
when: stackhpc_enable_os_capacity
1213

14+
- name: Deploy os-capacity exporter
15+
hosts: monitoring
16+
gather_facts: false
17+
tasks:
1318
- name: Create os-capacity directory
1419
ansible.builtin.file:
1520
path: /opt/kayobe/os-capacity/
1621
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"
27+
delegate_to: localhost
28+
register: credential
29+
when: stackhpc_enable_os_capacity
30+
31+
- name: Set facts for admin credentials
32+
ansible.builtin.set_fact:
33+
stackhpc_os_capacity_auth_url: "{{ credential.stdout_lines | select('match', '.*OS_AUTH_URL*.') | first | split('=') | last | replace(\"'\",'') }}"
34+
stackhpc_os_capacity_project_name: "{{ credential.stdout_lines | select('match', '.*OS_PROJECT_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
35+
stackhpc_os_capacity_domain_name: "{{ credential.stdout_lines | select('match', '.*OS_PROJECT_DOMAIN_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
36+
stackhpc_os_capacity_openstack_region_name: "{{ credential.stdout_lines | select('match', '.*OS_REGION_NAME*.') | first | split('=') | last | replace(\"'\",'') }}"
37+
stackhpc_os_capacity_username: "{{ credential.stdout_lines | select('match', '.*OS_USERNAME*.') | first | split('=') | last | replace(\"'\",'') }}"
38+
stackhpc_os_capacity_password: "{{ credential.stdout_lines | select('match', '.*OS_PASSWORD*.') | first | split('=') | last | replace(\"'\",'') }}"
39+
when: stackhpc_enable_os_capacity
1740

1841
- name: Template clouds.yml
1942
ansible.builtin.template:
2043
src: templates/os_capacity-clouds.yml.j2
2144
dest: /opt/kayobe/os-capacity/clouds.yaml
45+
when: stackhpc_enable_os_capacity
2246

2347
- name: Ensure os_capacity container is running
24-
docker_container:
48+
community.docker.docker_container:
2549
name: os_capacity
2650
image: ghcr.io/stackhpc/os-capacity:master
2751
env:
@@ -34,3 +58,4 @@
3458
network_mode: host
3559
restart_policy: unless-stopped
3660
become: true
61+
when: stackhpc_enable_os_capacity

etc/kayobe/ansible/templates/os_capacity-clouds.yml.j2

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ clouds:
22
openstack:
33
auth:
44
auth_url: "{{ stackhpc_os_capacity_auth_url }}"
5-
application_credential_id: "{{ secrets_os_capacity_credential_id }}"
6-
application_credential_secret: "{{ secrets_os_capacity_credential_secret }}"
5+
project_name: "{{ stackhpc_os_capacity_project_name }}"
6+
domain_name: "{{ stackhpc_os_capacity_domain_name }}"
7+
username: "{{ stackhpc_os_capacity_username }}"
8+
password: "{{ stackhpc_os_capacity_password }}"
79
region_name: "{{ stackhpc_os_capacity_openstack_region_name }}"
810
interface: "internal"
911
identity_api_version: 3
10-
auth_type: "v3applicationcredential"
12+
auth_type: "password"
1113
{% if not stackhpc_os_capacity_openstack_verify | bool %}
1214
verify: False
1315
{% endif %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/deploy-os-capacity-exporter.yml

etc/kayobe/stackhpc-monitoring.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ alertmanager_low_memory_threshold_gib: 5
1414
# Whether the OpenStack Capacity exporter is enabled.
1515
# Enabling this flag will result in HAProxy configuration and Prometheus scrape
1616
# targets being templated during deployment.
17-
stackhpc_enable_os_capacity: false
18-
19-
# Keystone authentication URL for OpenStack Capacity
20-
stackhpc_os_capacity_auth_url: "http{% if kolla_enable_tls_internal | bool %}s{% endif %}://{{ kolla_internal_fqdn }}:5000"
21-
22-
# OpenStack region for OpenStack Capacity
23-
stackhpc_os_capacity_openstack_region_name: "RegionOne"
17+
stackhpc_enable_os_capacity: true
2418

2519
# Whether TLS certificate verification is enabled for the OpenStack Capacity
2620
# exporter during Keystone authentication.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
features:
3+
- |
4+
Automatic deployment for OpenStack Capacity via a Kayobe service
5+
deploy hook using kolla admin credentials.
6+
upgrade:
7+
- |
8+
OpenStack Capacity no longer uses application credentials. Please
9+
delete any previously generated application credentials.

0 commit comments

Comments
 (0)