From 4d68d23f51b06a340546f4b48597c74250434160 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Sun, 25 Dec 2022 13:31:43 +0100 Subject: [PATCH] Allow to manage extra services, mounts and networks We do mainatain set of systemd roles, that allow to easily provision extra services, mounts or even networks and used quite widely across roles. This way we can ease lives of deployers and need of maintaining external playbooks and roles that will do basically same. Feature for a way to create/manage internal networking was also asked for quite a while amoung users. Systemd-service role can also be used to define post/pre hooks for configured networks and systemd_mount can be usefull to setup a shared filesystems for image or volume conversion directories to avoid running out of diskspace on controllers. Change-Id: Ia13f7747696db5b7b7640df7532c6d55627bdd01 --- defaults/main.yml | 12 ++++- ...nstack_hosts_systemd-4f47056a732820bd.yaml | 23 ++++++++++ tasks/main.yml | 10 +++++ tasks/openstack_hosts_systemd.yml | 44 +++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/openstack_hosts_systemd-4f47056a732820bd.yaml create mode 100644 tasks/openstack_hosts_systemd.yml diff --git a/defaults/main.yml b/defaults/main.yml index 23d724c3..9fd6a656 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -192,4 +192,14 @@ openstack_hosts_package_manager_extra_conf: '' openstack_hosts_apt_pinned_packages: - package: "src:ceph" origin: "ubuntu-cloud.archive.canonical.com" - priority: 400 \ No newline at end of file + priority: 400 + +# Define extra systemd services/networks/mounts +openstack_hosts_systemd_mounts: [] +# Systemd networks can be configured only on bare metal hosts +# systemd-networkd role won't run inside containers. +openstack_hosts_systemd_networkd_devices: [] +openstack_hosts_systemd_networkd_networks: [] +openstack_hosts_systemd_networkd_prefix: openstack-net +openstack_hosts_systemd_services: [] +openstack_hosts_systemd_slice: "openstack-hosts" diff --git a/releasenotes/notes/openstack_hosts_systemd-4f47056a732820bd.yaml b/releasenotes/notes/openstack_hosts_systemd-4f47056a732820bd.yaml new file mode 100644 index 00000000..88483623 --- /dev/null +++ b/releasenotes/notes/openstack_hosts_systemd-4f47056a732820bd.yaml @@ -0,0 +1,23 @@ +--- +prelude: > + It is now possible to create and manage third-party services, + mount points and networks on hosts managed by OpenStack-Ansible. + This also inlcudes networks, that are required for OpenStack-Ansible + installation, like br-mgmt or br-storage. + In order to configure specific resources on selected set of hosts, + usage of group_vars or host_vars is appreciated. +features: + - | + Added new varaibles that allow users to configure extra systemd + services, networks or mounts on openstack hosts. While services and + mounts can be configured on any targeted hosts, networks will be created + only on bare metal nodes. In order to configure extra networks in + containers please reffer to ``openstack_user_config.yml`` documentation. + A list of new variables that were added: + + * openstack_hosts_systemd_mounts + * openstack_hosts_systemd_networkd_devices + * openstack_hosts_systemd_networkd_networks + * openstack_hosts_systemd_networkd_prefix + * openstack_hosts_systemd_services + * openstack_hosts_systemd_slice diff --git a/tasks/main.yml b/tasks/main.yml index 7d550d04..b6d468c7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -163,3 +163,13 @@ tags: - openstack_hosts-config when: ansible_facts['hostname'] != 'aio1' + +- include_tasks: openstack_hosts_systemd.yml + args: + apply: + tags: + - openstack_hosts-config + - openstack_hosts-systemd + when: openstack_hosts_systemd_networkd_devices or openstack_hosts_systemd_networkd_networks or openstack_hosts_systemd_services or openstack_hosts_systemd_mounts + tags: + - always diff --git a/tasks/openstack_hosts_systemd.yml b/tasks/openstack_hosts_systemd.yml new file mode 100644 index 00000000..2a027355 --- /dev/null +++ b/tasks/openstack_hosts_systemd.yml @@ -0,0 +1,44 @@ +--- +# Copyright 2022, Cleura AB. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Run the systemd-networkd role + include_role: + name: systemd_networkd + vars: + systemd_networkd_prefix: "{{ openstack_hosts_systemd_networkd_prefix }}" + systemd_run_networkd: true + systemd_netdevs: "{{ openstack_hosts_systemd_networkd_devices }}" + systemd_networks: "{{ openstack_hosts_systemd_networkd_networks }}" + when: + - openstack_hosts_systemd_networkd_devices + - openstack_hosts_systemd_networkd_networks + - is_metal + +- name: Run the systemd-service role + include_role: + name: systemd_service + vars: + systemd_slice_name: "{{ openstack_hosts_systemd_slice }}" + systemd_services: "{{ openstack_hosts_systemd_services }}" + when: + - openstack_hosts_systemd_services + +- name: Run the systemd mount role + include_role: + name: systemd_mount + vars: + systemd_mounts: "{{ openstack_hosts_systemd_mounts }}" + when: + - openstack_hosts_systemd_mounts