Commit Graph

20 Commits (8cfe4d399ae0a8a3d613be4cc5f29ef4157fd974)

Author SHA1 Message Date
Sagi Shnaidman 86f1746120 Create an action plugin for podman_container module
When we want to create a large set of containers at the same time, an
action plugin can now be used which will call the podman_container
module.

The podman_containers action plugin takes a list of containers with
pre-defined parameters ready to be consumed by the podman_container
module.

The podman_containers module is just useful for Ansible documentation.

The molecule tests will ensure that the action plugin actually works and
creates the 3 containers.

Change-Id: I1e6881f3871a7a125db9374c608ecad0bafcb882
2020-07-31 08:25:30 -04:00
Emilien Macchi 67d78a753c container_systemd: improve debugging if service never starts
If a service never starts, the "status" key won't exist so Ansible
raises with KeyError which is very misleading (we don't even have the
service name).

This make pass the KeyError exception, so we fail at the end of the loop
of attempts with proper Ansible raise and we give the service name.

Change-Id: I74f3d5b51bde1ec33b69b2488174eef9cc4a330d
2020-07-27 08:46:33 -04:00
Emilien Macchi ddf494a16d tripleo_container_manage: start systemd services which would be stopped
If an operator would have disabled or stopped the service, we make sure
that it is again enabled and started when a deployment occurs.

We also add test coverage for it in molecule.

Change-Id: I97a6819574772835eb4a291b63bb05551fe4439a
2020-07-22 09:20:23 -04:00
Emilien Macchi ca8fae62e4 tripleo_container_manage: continue to reduce tasks
1) shutdown: include tasks without a block. this should remove the stat
   and include task; to only have one task that include the shutdown
   playbook if needed.

2) Remove containers_changed tasks. This is not useful to restart a
   container just because its podman_container resource changed.
   when podman_container module applies a change to the container, this
   one is already restarted.

3) Remove all_containers_commands tasks, there aren't needed. Ansible
   output already provides the commands that are run via the
   container_status module.

Change-Id: Ic625bc5dd7bbd964d36eab0a3f81eca31c533716
2020-07-22 02:18:52 +00:00
Zuul 4e0293e4c9 Merge "container_status: "exec" checks status" 2020-07-14 01:40:55 +00:00
Emilien Macchi 3ce9d50a7f container_status: "exec" checks status
Support the checks of "podman exec" commands, and add the commands to
the list of things podman ran.

It reduces the number of tasks as it removes get_commands_exec and
re-use the container_status action plugin.

Change-Id: I4c84b389b595a8fe18ef6d31e896d6b6608b9920
2020-07-13 01:31:30 +00:00
Emilien Macchi 32bc4a4639 container_systemd: improve logging
Change the wording when a container will be added to the list of
containers that will be restarted, so it's not confusing.

Change-Id: Ieb50138b5c1d35fa3c59dd368a58c1af3f61807b
2020-07-13 01:31:01 +00:00
Emilien Macchi af7f083066 Introduce an Action Plugin to manage systemd services for containers
Instead of running a bunch of tasks to manage systemd resources, move
it into an action plugin which should make the execution faster and
easier to debug as well.

Example of task:
- name: Manage container systemd services
  container_systemd:
    container_config:
      - keystone:
          image: quay.io/tripleo/keystone
          restart: always
      - mysql:
          image: quay.io/tripleo/mysql
          stop_grace_period: 25
          restart: always

The output is "restarted" for the list of services that were actually
restarted in systemd.

Note on testing: since that module is consummed by
tripleo_container_manage role, there is no need to create dedicated
molecule tests, we already cover containers with restart policy in that
role's molecule tests. So we'll re-use it.

Co-Authored-By: Alex Schultz <aschultz@redhat.com>
Co-Authored-By: Kevin Carter <kecarter@redhat.com>

Change-Id: I614766bd9b111bda9ddfea0a60b032e1dee09abc
2020-07-07 12:56:07 +00:00
Emilien Macchi 19774d0be4 Introduce an Action Plugin to fetch container infos
Instead of running a bunch of tasks to figure out what container
commands have been run, which ones did not terminate after 5 minutes,
which ones failed or finished with a wrong exit code. We now have an
action plugin that will do it faster and with better logging.

Faster before it reduces the number of tasks.
Better logging is provided, now displaying all errors during a run and
fail at the end.

Supporting check-mode.

Re-using tripleo_container_manage role for molecule testing.

Co-Authored-By: Alex Schultz <aschultz@redhat.com>
Co-Authored-By: Kevin Carter <kecarter@redhat.com>

Change-Id: Ie7f8c9cceaf9540d7d33a9bb5f33258c46185e77
2020-07-03 16:02:49 -04:00
Hervé Beraud c09f624891 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: I088f435bfc0dfeb67b4b2c3400aaa08eb41d7c59
2020-06-02 21:02:57 +02:00
Emilien Macchi 9fefb30c5d tripleo_all_nodes_data: sort enabled_services (idempotency)
Sorting the enabled_services list so we can have idempotent hieradata
where the content doesn't change between Ansible runs of the
tripleo_all_nodes_data action plugin.

Change-Id: I8f54265dbadf21da6badd690f5cb123b549cf48c
2020-04-08 10:11:10 -04:00
Luke Short e0d073b936 tripleo_all_nodes_data: Append server node IP to the list.
This is the proper way to add another element to a list. Otherwise
the plugin would fail if a string was trying to be concatenated to
a list.

Change-Id: Ieba3396bbe89e2ad1de7ad842b31f3ad092ff36f
Closes-Bug: #1871228
2020-04-06 17:26:37 -04:00
James Slagle 918452da7f Add action plugin for all_nodes data
This patch adds an action plugin to render the all_nodes group_vars for
the overcloud. This plugin will produce the same json structure as the
all_nodes.j2 template in the tripleo-heiradata role. Once
deploy_steps_playbook.yaml is migrated over to use the new action
plugin, the all_nodes.j2 template can be removed.

At scale, the template was taking an unusual amount of time to render.
Switching to native python with the action plugin results in improved
performance. In a 150 node environment, using the action plugin dropped
the render time from 7 minutes to 30 seconds.

Using an action plugin will also allow more easier unit testing (to be
forthcoming), and also add the opportunity to use debug statements to
show errors.

Change-Id: I92113589b98d7c1f9c05e1ea0938a03d95b7dd15
2020-01-24 11:57:46 -05:00
Zuul 3de7b0fbba Merge "Change drop action" 2019-12-21 02:26:41 +00:00
Oliver Walsh 8dc6d50b16 Add role/playbook to manage nova image cache
Adds a tripleo-nova-image-cache role to manage the nova local image cache on
remote compute nodes.
For multi-site/stack deployments the image can be downloaded once and
distributed to the remaining nodes in the stack to minimise WAN traffic.

Also adds a playbook to run the role using the single/multi-stack inventory
and the overcloudrc environment variables.

Change-Id: Ib5aaa22f6cf307181d8f34cf89f9f24619b43004
Implements: blueprint tripleo-nova-cache-mgmt
2019-12-19 16:19:06 +00:00
Kevin Carter 8f11437b1c
Change drop action
The new firewall rule action plugin was setting the rule state as absent
when using the drop "action", this change updates that so we're adding
drop rules and appending them to the rule chain.

Change-Id: I5105c007d890ec98b34eafba3ab410bf9ba4f089
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2019-12-18 08:43:10 -06:00
Kevin Carter 38c75fb83e
Update firewall role to use an action plugin
This change updates our firewall role so that its using an action plugin
to invoke the iptables module. This is being done to speed up rule creation
and maintenance.

Tests have been updated to ensure we're capturing all of the logic within
the action plugin accordingly.

Depends-On: Ie9b6fd5792efb270ae577b08d6a2d5b78dabe5e7
Closes-Bug: #1856094
Change-Id: I3e4c6586796753b5d1cb9aa6a7c3eee6ecc235fb
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2019-12-16 16:55:13 -06:00
Kevin Carter e25e9c8bc3
Add plugin documentation
This change adds documentation for all of the plugins currently
found in the tripleo-ansible repo. This will provide for much
greater visability into what we're providing and will allow
users and developers to better understand how to consume
the available resources.

Change-Id: I2f5813095cbadd999bc68235278a9da1f883e01e
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2019-07-09 20:33:27 -05:00
Kevin Carter 12d9d8dd61
Import action plugin from tripleo-common
The package action plugin has been imported from tripleo common.
This plugin acts as a shim allowing tripleo to control package
installations within ansible using a global variable.

The action plugin will now have tests to ensure that it is
functioning as expected within ansible.

* The default scenario will run the test role normally ensuring
  that the plugin does not interfer with normal operations.
* The negative scenario will run the test role with the global
  option `tripleo_enable_package_install` set to false. This will
  ensure that no package is installed.
* The positive scenario will run the test role with the global
  option `tripleo_enable_package_install` set to true, which
  will ensure the expect package is installed.

All three scenarios have been added as jobs which run when
this role or plugin has been changed.

Because this job will run three different molecule scenarios
a change has been made to the pytest setup which will allow
us to pass in command line arguments to the job function.
This update will allow us to now set the command line option
`--scenario` when running tests. This new argument has been
documented in the `contributing.rst` file.

Change-Id: I096d6332f8231620e39ead557e7c9598adad66dd
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2019-06-17 11:00:54 -05:00
Kevin Carter d7163861f2 Update project structure
This change updates the project structure to reflect the documented
ansible best practice when creating projects [0].

* setup.cfg has been updated to ensure this package installs all of the
  libs and playbooks into the correct on system locations.

With this change we should be able to begin collecting content throughout
the tripleo ecosystem.

[0] - https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#directory-layout

Change-Id: If3ca66befee3f82f462a8fc00984698e26cc7e9b
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2019-06-05 14:27:22 +00:00