Allow to provide custom handler names

Introduce variables that allow to customize handler names that are
being used. This is especially useful when role is included multiple
times within same playbook.

Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-rabbitmq_server/+/876436
Needed-By: https://review.opendev.org/c/openstack/openstack-ansible/+/871189/
Change-Id: I66ad04a5dbbce29c052895649792fa8a49e40a57
This commit is contained in:
Dmitriy Rabotyagov 2023-02-28 18:15:01 +01:00 committed by Jonathan Rosser
parent 18ba3e50ea
commit 95aaaf1337
6 changed files with 22 additions and 8 deletions

View File

@ -150,3 +150,8 @@ pki_search_install_certificates_pattern: "pki_install_certificates_"
# method used to create the certificates
pki_method: standalone
# Handlers naming
pki_handler_ca_changed: "ca cert changed"
pki_handler_cert_changed: "cert changed"
pki_handler_cert_installed: "cert installed"

View File

@ -1,3 +1,4 @@
---
# Copyright 2021, BBC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -13,16 +14,16 @@
# limitations under the License.
# when the created CA certificates are changed
- name: ca cert changed
- name: "{{ pki_handler_ca_changed }}"
meta: noop
when: false
# when the created server certificates are changed
- name: cert changed
- name: "{{ pki_handler_cert_changed }}"
meta: noop
when: false
# when a certificate is installed onto a server
- name: cert installed
- name: "{{ pki_handler_cert_installed }}"
meta: noop
when: false
when: false

View File

@ -0,0 +1,8 @@
---
features:
- |
Added variables ``pki_handler_ca_changed``, ``pki_handler_cert_changed``
and ``pki_handler_cert_installed`` that control name of meta handlers which
role triggers when included. This might be useful if multiple roles that
leverage the pki role are inlcuded withing same playbook and you want to
have better control over handler execution.

View File

@ -78,4 +78,4 @@
mode: "{{ install.item.mode | default('0644') }}"
ignore_errors: "{{ ansible_check_mode }}"
notify:
- cert installed
- "{{ pki_handler_cert_installed }}"

View File

@ -109,7 +109,7 @@
- ca.provider == 'selfsigned'
- ca_csr is changed
notify:
- ca cert changed
- "{{ pki_handler_ca_changed }}"
- name: Sign the intermediate CA CSR for {{ ca.name }}
vars:
@ -127,7 +127,7 @@
- ca.provider == 'ownca'
- ca_csr is changed
notify:
- ca cert changed
- "{{ pki_handler_ca_changed }}"
- name: Symlink the certificate name to the most recently generated
file:

View File

@ -65,7 +65,7 @@
- cert.provider == 'ownca'
- cert_csr is changed
notify:
- cert changed
- "{{ pki_handler_cert_changed }}"
ignore_errors: "{{ ansible_check_mode }}"
- name: Get certificate info for {{ cert.name }}