From 03e9c6b69e73af9746bdeec23d9f12fe1bedf833 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Mon, 22 Jan 2024 10:29:43 +0000 Subject: [PATCH] Add user defined hooks that can run extra playbooks This patch adds variables which when can be used to extend openstack ansible by calling additional user defined playbooks at the start and end of the main setup-* playbooks. Change-Id: Ic55dd6447f603d91beaeea28beb04e4c1393d6af --- playbooks/hook-dummy.yml | 3 +++ playbooks/setup-hosts.yml | 6 ++++++ playbooks/setup-infrastructure.yml | 6 ++++++ playbooks/setup-openstack.yml | 6 ++++++ releasenotes/notes/hook-playbooks-b71dbdd7835af2aa.yaml | 8 ++++++++ 5 files changed, 29 insertions(+) create mode 100644 playbooks/hook-dummy.yml create mode 100644 releasenotes/notes/hook-playbooks-b71dbdd7835af2aa.yaml diff --git a/playbooks/hook-dummy.yml b/playbooks/hook-dummy.yml new file mode 100644 index 0000000000..a5816056f6 --- /dev/null +++ b/playbooks/hook-dummy.yml @@ -0,0 +1,3 @@ +- name: Placeholder hook + hosts: localhost + gather_facts: false diff --git a/playbooks/setup-hosts.yml b/playbooks/setup-hosts.yml index b124a872b3..9b415071d8 100644 --- a/playbooks/setup-hosts.yml +++ b/playbooks/setup-hosts.yml @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Importing pre hook playbook + import_playbook: "{{ pre_setup_hosts_hook | default('hook-dummy.yml') }}" + - name: Importing certificate-authority playbook import_playbook: certificate-authority.yml @@ -30,3 +33,6 @@ - name: Importing security-hardening playbook import_playbook: security-hardening.yml + +- name: Importing post hook playbook + import_playbook: "{{ post_setup_hosts_hook | default('hook-dummy.yml') }}" diff --git a/playbooks/setup-infrastructure.yml b/playbooks/setup-infrastructure.yml index ef39c6f719..e1bddff40b 100644 --- a/playbooks/setup-infrastructure.yml +++ b/playbooks/setup-infrastructure.yml @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Importing pre hook playbook + import_playbook: "{{ pre_setup_infrastructure_hook | default('hook-dummy.yml') }}" + - name: Importing unbound-install playbook import_playbook: unbound-install.yml @@ -52,3 +55,6 @@ - name: Importing infra-journal-remote playbook import_playbook: infra-journal-remote.yml when: journald_remote_enabled | default (false) | bool + +- name: Importing post hook playbook + import_playbook: "{{ post_setup_infrastructure_hook | default('hook-dummy.yml') }}" diff --git a/playbooks/setup-openstack.yml b/playbooks/setup-openstack.yml index 065a9bdc80..06bf85630a 100644 --- a/playbooks/setup-openstack.yml +++ b/playbooks/setup-openstack.yml @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Importing pre hook playbook + import_playbook: "{{ pre_setup_openstack_hook | default('hook-dummy.yml') }}" + - name: Importing os-keystone-install playbook import_playbook: os-keystone-install.yml @@ -110,3 +113,6 @@ - name: Importing os-rally-install playbook import_playbook: os-rally-install.yml + +- name: Importing post hook playbook + import_playbook: "{{ post_setup_openstack_hook | default('hook-dummy.yml') }}" diff --git a/releasenotes/notes/hook-playbooks-b71dbdd7835af2aa.yaml b/releasenotes/notes/hook-playbooks-b71dbdd7835af2aa.yaml new file mode 100644 index 0000000000..b250d3dde2 --- /dev/null +++ b/releasenotes/notes/hook-playbooks-b71dbdd7835af2aa.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + New variables are added to allow a user defined playbooks to be specified + that run pre and post the existing code in setup-hosts, setup-infrastructure + and setup-openstack. OpenStack-Ansible deployments may be extended and + have additional user defined functions added using these hooks, which + will have full access to the OSA inventory and host variables.