Commit Graph

350 Commits

Author SHA1 Message Date
Zuul ef56cab84b Merge "Support saving baremetal compute inspection data" 2024-04-02 11:32:28 +00:00
Jakub Darmach dbcc3f4ae3 Use new collections in Kayobe
Refactored the code to switch the distribution source of the roles
to new collections for the roles that have already been migrated into
collections.

Updated:

 - requirements
 - role invocations
 - documentation
 - release notes
 - minor whitespace fixes

Change-Id: I8dbb88aa2061b3afcab07caeb30f45b3a5c939af
2024-03-27 15:07:08 +00:00
Matt Crees c04b6ddf1b Support saving baremetal compute inspection data
Add the command ``kayobe baremetal introspection data save`` to save the
hardware introspection data gathered by ``kayobe baremetal compute
inspect``. This mirrors the functionality of ``kayobe overcloud
introspection data save``, but for use with the baremetal compute
Ironic, rather than Bifrost.

Change-Id: I654f7d6e923c442a8aa08f536cc2b82c5e5b69d1
2024-03-14 14:03:42 +00:00
Zuul 684a440bae Merge "Make hooks environment-aware" 2024-03-01 14:28:02 +00:00
Zuul f2b658ecb6 Merge "Generate KA config before ``kolla ansible run``" 2024-02-16 19:36:21 +00:00
Pierre Riteau 4337e78eea Add missing space in help output
Change-Id: I6834aa6a19a73efe807402fa767b9ceaf1170a20
2024-02-13 19:26:54 +00:00
Matt Crees bc98c494ae Generate KA config before ``kolla ansible run``
Supports calling custom Kolla Ansible commands directly after a
``kayobe control host bootstrap``.

Change-Id: I19f188cc002f8578618003e90c0a4a154b806e49
2024-02-02 13:25:58 +00:00
Mark Goddard 0055d384a6 Make hooks environment-aware
Previously it was only possible to define custom playbook hooks in the
base configuration, and not in environments. This could be limiting in
cases where different environments require different hooks.

With this change it is now possible to define hooks both in the base
configuration and in environments.

Change-Id: Ic003c18402177318ac1aa4c2d851263893bd4e9f
2023-12-21 14:45:30 +00:00
Mark Goddard 96d0daa7e6 Use assertIsInstance() instead of assertTrue(isinstance())
pep8 complained about it.

Change-Id: I09061b8a9769d737115b7677599e8796503f0725
2023-12-20 17:09:09 +00:00
Mark Goddard 78702d0e30 Fix configuration dump with inline encrypted variables
If inline Ansible vault encryption is used to define an encrypted
variable in kayobe-config, running 'kayobe configuration dump -l <host>'
fails with the following:

  Failed to decode config dump YAML file /tmp/tmp_fg1bv_j/localhost.yml:
  ConstructorError(None, None, "could not determine a constructor for
  the tag '!vault'", <yaml.error.Mark object at 0x7f1e5c7404c0>)

This change fixes the error by using the Ansible YAML loader which
supports the vault tag. Any vault encrypted variables are sanitised in
the dump output. Note that variables in vault encrypted files are not
sanitised.

Change-Id: I4830500d3c927b0689b6f0bca32c28137916420b
Closes-Bug: #2031390
2023-11-30 10:55:46 +01:00
Zuul 63f9aa4ef1 Merge "Generate local Kolla Ansible config in check mode" 2023-11-08 18:26:14 +00:00
Zuul 9836fa7e6c Merge "Bump hacking version" 2023-11-01 20:04:11 +00:00
Pierre Riteau ee63b3253d Fix MTU of NetworkManager bridge VLAN interfaces
We are seeing an issue on Rocky Linux 9 where VLAN interfaces on bridges
have their MTU set to MTU-1 after rebooting. This is likely related to
how MTU is set by NetworkManager for bridges: it first sets the MTU to
MTU-1 before setting it to the correct value [1].

We can work around this issue by not explicitly setting the MTU
configuration on the VLAN interface if it is the same as the parent
bridge. It will be automatically inherited from the parent.

[1] 864872e9a8

Closes-Bug: #2039947
Change-Id: I23366f4de7842e7c2fe40e431fac76f26e9892de
2023-10-20 14:51:37 +02:00
Zuul 4e2a0d2e8d Merge "Fix last return value in _get_base_path" 2023-10-17 13:28:52 +00:00
Michal Nasiadka 672d6fa24a bifrost: Populate bifrost host vars on deprovision
Closes-Bug: #2038889
Change-Id: I4609494d009c6e1f97d833a9a11529d107b3216f
2023-10-17 09:29:31 +02:00
Pierre Riteau 7f536e7594 Bump hacking version
Change-Id: Ie443038dfd9ac63a5945d6b4e9e0eb724f11df44
2023-10-16 10:15:29 +02:00
Pierre Riteau 8b465eae49 Use importlib.metadata instead of importlib_metadata
The importlib.metadata library is part of the Python standard library
since Python 3.8.

Change-Id: Iecf1d469caaa777c5b253eb0e44dc00692197ef7
2023-10-04 11:13:23 +02:00
Pierre Riteau cfaf571794 Work around mocking issues on stable branches
Backports of I9dd5b97dec93c0e5393a1e7d9640f85003651b56 to stable
branches are failing CI checks because several unit tests mock
os.path.exists and would need to be updated. This does not affect master
because test code changed in I4d9f96ec4cf3c6cd0d28dfe5ddb239d863498a72.

Work around this issue by replacing os.path.exists by os.path.isfile. It
is a better check anyway since we are reading the file.

Change-Id: Ic53efd03cecbd53ad3e3b64b664e084f4e25be0e
Related-Bug: #2020135
2023-09-29 07:11:43 +02:00
Pierre Riteau 810e021d8b Fix last return value in _get_base_path
The return value was set to the following path which is not valid:

    kayobe/kayobe/utils.py/..

The intent must have been to use dirname to produce:

    kayobe/kayobe/..

Change-Id: I9d7d71d42026f3c12da6de9c5ca55dc647554fd0
2023-09-25 18:43:07 +02:00
Pierre Riteau 1847ad3f17 Fix data file path detection with new pip
Using an editable installation of Kayobe fails on Rocky Linux 9 or
Ubuntu with an error such as:

    ERROR! The requirements file '/home/rocky/kayobe/kayobe/requirements.yml' does not exist.
    Failed to install Ansible roles from /home/rocky/kayobe/kayobe/utils.py/../requirements.yml via Ansible Galaxy: returncode 1
    Control host bootstrap failed - likely Ansible Galaxy flakiness. Sleeping 5 seconds before retrying

This is caused by recent changes to how pip manages editable
installations. The egg-link file that Kayobe was using to find the
source path does not exist anymore. Instead, there is a direct_url.json
file under the kayobe dist-info directory that can be parsed.

Change-Id: I9dd5b97dec93c0e5393a1e7d9640f85003651b56
Closes-Bug: #2020135
2023-09-21 18:29:23 +02:00
Zuul cf5feb71e2 Merge "Kayobe environment dependencies" 2023-09-01 18:12:25 +00:00
Zuul a5882071f7 Merge "Use merge_configs and merge_yaml to generate Kolla custom config" 2023-09-01 18:12:17 +00:00
Bartosz Bezak f1fd127c34 Add STP option for bridge interfaces
For Rocky Linux 9, Kayobe will now disable STP on a bridge by default,
to preserve compatibility with network scripts, as Network Manager
enables STP on all bridges by default.
Enabling STP can lead to port down event if BPDU guard is enabled
on the switch.

Closes-Bug: #2028775

Change-Id: I35eaa92f4243af00697306aa801e5a733885ce4f
2023-08-18 09:44:09 +00:00
Will Szumski 0ae9e8d489 Kayobe environment dependencies
Allows you to combine multiple environments by declaring any dependencies.

Story: 2002009
Task: 42911
Change-Id: I4d9f96ec4cf3c6cd0d28dfe5ddb239d863498a72
2023-05-30 20:20:41 +01:00
Mark Goddard 428ef10fa4 Use merge_configs and merge_yaml to generate Kolla custom config
This patch adds new functionality - merging base & environment specific
kolla config. This allows you to place common settings in the base
configuration and only keep environment specific settings in the
environment directories.

Change-Id: Id4588f4529a4522e68e22ce58711cb927fa68a9d
Story: 2002009
Task: 42903
2023-05-30 16:47:14 +00:00
Will Szumski c75a32e72f Pass through kolla inventories as is
Previously, we only supported passing through group_vars. Passing
through the inventory as is allows you to use other features of ansible
inventory such as host vars. It also simplifies the logic of merging
multiple inventories as we can just pass the inventory to ansible and
let ansible take care of the rest. This is useful for the multiple
environments feature.

Change-Id: I28f5d73d414d405d67f5fc92ab371aa2e28a4ce3
Story: 2002009
Task: 42910
Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/802863
2023-05-30 18:42:24 +02:00
Zuul 7f4ba45191 Merge "Limit interface names to 15 characters" 2023-05-25 17:15:35 +00:00
Maksim Malchuk 9b58320f6b Show an error when *_bridge_ports is not a list
Closes-Bug: #2020378
Change-Id: I000ae473bb759e19b48ecefdbf5d5dc19c833088
Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
2023-05-22 23:42:34 +00:00
Zuul 0f2262266a Merge "Fix maximum width of the DIB Multiline-YAML" 2023-04-19 16:29:44 +00:00
Mark Goddard 2c0f705e7a Generate local Kolla Ansible config in check mode
If running a command in check mode such as

    kayobe overcloud service deploy --check

Kayobe does not generate the local configuration for Kolla Ansible. This
can lead to an inaccurate result when comparing with the remote
configuration, if there are changes in kayobe-config.

For example:

* Run kayobe overcloud service deploy
* Change a file in etc/kayobe/kolla
* Run kayobe overcloud service deploy --check --diff

We would expect that the changed file results in a diff against the
remote config. However there is no diff displayed.

This change fixes the issue by always generating the local Kolla Ansible
config, even in check mode.

Change-Id: Ic1dd075076ea186b0928bba1a235605c0cd2ec71
Story: 2010526
Task: 47132
2023-04-19 17:01:09 +01:00
Zuul cb50b0cbc0 Merge "Stop using kolla-ansible bootstrap-servers" 2023-04-18 15:49:59 +00:00
Maksim Malchuk 5cf750c313 Fix maximum width of the DIB Multiline-YAML
The dib_env_vars variable in the Bifrost's dib.yml file can contain
the DIB_BLOCK_DEVICE_CONFIG environment variable which is always the
Multiline-YAML data. By default, the format of the data is not
preserved while the configuration is merged and saved for the
bifrost-deploy container.

This is because Ansible uses the PyYAML library which has a default
80 symbol string length limit. The official Ansible documentation [1]
recommends using to_yaml or to_nice_yaml filters with width parameter.
This change adds the same ability to the merge_yaml Ansible plugin.

1. https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#formatting-data-yaml-and-json

The related change for the diskimage-builder to solve the issue with
incorrect data provided by Kolla-Ansible is also provided:
I3b74ede69eb064ad813a9108ec68a228e549e8bb

The related change for Kolla-Ansible is also provided:
Id79445c0311916ac6c1beb3986e14f652ee5a63c

Closes-Bug: #2014981
Related-Bug: #2014980
Change-Id: I339042d9ce405f59aba936dd98df7d89a88bb41e
Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
2023-04-13 13:59:15 +03:00
Maksim Malchuk 46000d4e05 Fix merge action plugins verbose output
This change fixes the output 'module_args' information of the plugins
'merge_configs' and 'merge_yaml' when Ansible is executed in maximum
verbose mode. Now all the plugin options are displayed instead of
standard 'copy' plugin options only.

Change-Id: Ie2d9a0501fe29bfd854eb31258f282b197855948
Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
2023-04-02 00:39:02 +03:00
Mark Goddard c9f8d80ba6 Stop using kolla-ansible bootstrap-servers
The 'kayobe * host configure' commands no longer use the 'kolla-ansible
bootstrap-servers' command, and associated 'baremetal' role in Kolla
Ansible. The functionality provided by the 'baremetal' role has been
extracted into the openstack.kolla Ansible collection, and split
into separate roles. This allows Kayobe to use it directly, and only the
necessary parts.

This change improves failure handling in these Kayobe commands, and aims
to reduce confusion over which '--limit' and '--tags' arguments to
provide.  This ensures that if a host fails during a host configuration
command, other hosts are able to continue to completion. Previously, if
any host failed during the Kayobe playbooks, the 'kolla-ansible
bootstrap-servers' command would not run. This is useful at scale, where
host failures occur more frequently.

This change has implications for configuration of Kayobe, since some
variables that were previously in Kolla Ansible are now in Kayobe.

Several parts of the baremetal role have been split out and used here:

* apparmor-libvirt: disable AppArmor rules for libvirt on Ubuntu.
* docker: Docker installation & configuration. The docker role in
  openstack.kolla combines functionality from kolla-ansible and kayobe.
* etc-hosts: it proved difficult to generalise this, so we have some
  almost duplicated the code from kolla-ansible here. Requires delegated
  fact gathering for the case when --limit is used.
* firewall: support to disable UFW, for feature parity.
* kolla-packages: miscellaneous package installs & removals.

The addition of the stack user to the docker group has been moved to the
user bootstrapping playbook, and the docker SDK installation has been
moved to the virtualenv setup playbook.

Depends-On: https://review.opendev.org/c/openstack/ansible-collection-kolla/+/829587

Story: 2009854
Task: 44505

Change-Id: I61a61ca59652b13687c2247d5881012b51f666a7
2023-03-30 13:52:54 +00:00
Zuul be0a819623 Merge "Ubuntu: Fix networkd config for multiple VLANs without MTU" 2023-02-16 17:33:52 +00:00
Erik Berg b9b90a5d5f
Limit interface names to 15 characters
If you give your bridge a long enough name, eg. `br-external`. The
extra characters added to the veth pairs can make the interface name
go beyond the 15 character limit. We can solve this by truncating the
name of the bridge used in the veth names.

Change-Id: I5b890e24195d033897a597a0a93a1cacfb2030d2
2023-01-11 13:16:36 +01:00
Matt Crees 4af5fd172b Add command to run config validation
Adds the command ``kayobe overcloud service configuration validate`` to
run the ``oslo-config-validator`` on all hosts via Kolla-Ansible. The
output directory of the results is specified with the flag
``--output-dir``.

Change-Id: I5d5d16eeabe69e8659e33722165928df096b3559
2023-01-10 16:08:25 +00:00
Zuul f23ce83a12 Merge "Support configuring VLANs with systemd-networkd syntax" 2023-01-03 13:08:12 +00:00
Mark Goddard 73df27677c Use environment variables for plugin paths
Kayobe provides various roles and plugins in the ansible directory.
These are accessible to Kayobe playbooks in the same directory.

In some cases it can be useful to use these items from Kayobe custom
playbooks, however they cannot since they reside in a different
directory. Typically we work around this by symlinking to the relevant
directory from the directory containing the custom playbook. This is not
an elegant workaround, and has assumptions about the relative paths of
the Kayobe configuration and virtual environment in which Kayobe is
installed.

This change adds the Kayobe role, collection, and plugin paths to the
relevant Ansible lookup paths using environment variables. This allows
custom playbooks to use these items. Also added to the lookup paths are
roles, collections and plugins in Kayobe configuration in the
etc/kayobe/ansible/ directory. This removes the limitation of playbooks
needing to reside in the same directory as those items in order to use
them.

We import the Ansible configuration settings module directly, since it
avoids replicating the configuration logic.

Story: 2010280
Task: 46234

Change-Id: I2fb2b4d7ed937e0184a62b0f119659569448f8df
2022-12-14 22:52:41 +01:00
Michal Nasiadka 65587cb279 Bump up Ansible supported versions to 5.x/6.x
This change bumps up the maximum supported Ansible version to 6.x
(ansible-core 2.13.x) and minimum to 5.x. This synchronises Kayobe with
Kolla Ansible.

Shebang has been removed from modules due to [1].

os_openstacksdk_version has been added as openstack cloud modules don't
support versions greater than 0.99.

[1]: https://github.com/ansible/ansible/pull/76677

Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/867546
Change-Id: Ibb00f6d079442a8509411ae8a71d74fd7bd8cccd
2022-12-14 14:55:33 +00:00
Pierre Riteau f6660bbff8 Remove support for Monasca and its dependencies
This follows removal of support from Kolla Ansible. This also removes
support for configuring Grafana with overcloud post configure.

Change-Id: I8102fafb00db178f1ae6801d37c43a39033cbfe6
2022-12-13 14:32:33 +01:00
Alex-Welsh ce74a98b1d Add --add-known-hosts to control host bootstrap
Provide the option to add hosts to the SSH known hosts file when running
control host bootstrap.

Story: 2001670
Task: 6716
Change-Id: I512a343f875ee95194ab4fa98872e349f5a6dc7b
2022-11-09 11:26:15 +00:00
Zuul 42b9341c6c Merge "Add support for ANSIBLE_VAULT_PASSWORD_FILE" 2022-10-20 14:22:52 +00:00
Zuul 64a76166b0 Merge "Fix comment in OvercloudPostConfigure" 2022-10-13 21:38:11 +00:00
Zuul 1120958133 Merge "Update comments for host configure commands" 2022-10-13 21:38:09 +00:00
Alex-Welsh 4661cf7410 Add support for ANSIBLE_VAULT_PASSWORD_FILE
Story: 2006766
Task: 37281

Change-Id: I53fac9ac5cfb17729bf854bd9e16373dc9c2efe2
2022-10-13 22:08:15 +02:00
Pierre Riteau 642486d821 Fix comment in OvercloudPostConfigure
Change-Id: I56a25a82ad696122a37ffb1a347d72f0722b5757
2022-10-07 16:07:20 +02:00
Pierre Riteau cd46e1524c Update comments for host configure commands
Change-Id: I249ec3e3417db31d1f0d880ac9b101f88cac2fe5
2022-10-07 16:03:55 +02:00
Alex-Welsh d7069283fd added option to skip hooks
adds the argument --skip-hooks/-sh which will stop the execution of
hooked ansible playbooks. Either a pattern can be specified to match
against or hook execution can be stopped altogether with "all"

Story: 2009241
Task: 43390

Change-Id: I4f2176aa056fec62e31d07140e3d05779480a93d
2022-10-04 14:40:31 +01:00
Pierre Riteau 6d7b8812ae Support configuring VLANs with systemd-networkd syntax
This allows operators to configure arbitrarily named VLAN interfaces
using systemd-networkd.

Story: 2010266
Task: 46178

Change-Id: I666d7011bde0050ebc509b427c1d4f5a66b6231a
2022-09-09 17:57:11 +02:00