Commit Graph

121 Commits

Author SHA1 Message Date
ramishra 40198b1d86 Remove the leftover module in tripleo_common.actions
This completes all mistral related cleanup. There is
a doc patch in review to cleanup the docs.

Depends-On: https://review.opendev.org/c/openstack/python-tripleoclient/+/792137
Change-Id: Ib333408a95011882e10e15d66908b72884576949
2021-05-19 18:34:06 +05:30
ramishra 50a24d529b Convert AnsiblePlaybookAction to utility
Not used as mistral action as mistral has been
removed from undercloud.

Change-Id: I93b2c82e9451bd68955040f09ec9eb97db7c0098
2021-03-01 17:40:47 +05:30
Alex Schultz 16bc02326b Drop inject_facts_as_vars
This setting stops ansible from converting ansible_fact items into top
level ansible_* vars. This has a huge impact on performance as this is
performed at the end of every task execution.

Depends-On: https://review.opendev.org/c/openstack/tripleo-heat-templates/+/776659
Depends-On: https://review.opendev.org/c/openstack/tripleo-ansible/+/776666
Change-Id: I1a3c0d31cdb4a644cb950ca59c83bfcb051dc39d
2021-02-22 10:59:45 -07:00
Alex Schultz 0e81eb420e Reduce fact gathering
This change updates the default subset to only be the minimum list of
facts for ansible.  In the deployment we need to make sure that we only
collect the minimum amount of facts to perform the tasks at hand rather
than assume we have all the facts.

Depends-On: https://review.opendev.org/c/openstack/tripleo-heat-templates/+/775709
Depends-On: https://review.opendev.org/c/openstack/tripleo-ansible/+/775708
Related-Bug: #1915761
Change-Id: I61affe32dfc9eacbe514893168397c9b291b8713
2021-02-19 07:38:44 -07:00
Sorin Sbarnea 4db1e72654 pylint: fixed conditions
Change-Id: I0e6bcebca55d89bdfb59944bf91f4f9949c95562
2021-01-11 17:14:06 +05:30
Zuul d9c3e3c618 Merge "Lower ansible poll interval time" 2020-10-16 20:06:30 +00:00
Mathieu Bultel d2b373dc1d Add both validations path for inflight validation
The ceph external deploy tasks is using validation modules via
mistral.
We need to setup the correct new path for mistral in order to
get the module. (warn.py)

Change-Id: Ide21daaac9a558561d0943cc0a380952cf7e29b3
Resolves: rhbz#1885828
2020-10-07 12:38:49 +02:00
Alex Schultz d449a9ea07 Lower ansible poll interval time
Currently we set poll interval in ansible to 0.05 which means it'll wait
50ms.  The default is 0.001 which at scale is too cpu intensive.  That
being said, waiting 50ms for each task across all hosts increases
overall execution time. Let's lower it to 0.01 as a middle ground
between the current 0.05 and the 0.001 default.

Change-Id: Ie4268fcc8c1a8031eaf7c33e9c137c198017ee18
2020-10-02 10:27:57 +00:00
Zuul 76121bf896 Merge "Adjust Ansible forks caculations" 2020-09-23 07:35:50 +00:00
Alex Schultz e8e2ca479f Lower default verbosity for ansible
Similar to aef369e7b4d38e4ca7eb158d2878e84a4b93e603 however this only
affects the ansible-playbook execution. By default openstack cli sets
verbosity to 1 so we are always running ansible-playbook with a -v. This
can a consequence on the information returned during execution as we may
get extra result data in the output.

Change-Id: I4e1cb6658172a7da5ae5198ba55d47de33282975
2020-09-15 09:51:07 -06:00
Luke Short 9e9948e7ed Adjust Ansible forks caculations
Using a multiple of 10 can be excessive on resource usage. It has now
been lowered to 4. The default maximum will also no longer exceed 100.

Change-Id: I57345d5b100efce143fa940b56c81f5e6bc6c390
Signed-off-by: Luke Short <ekultails@gmail.com>
2020-09-10 15:58:13 -04:00
Alex Schultz 781233af1a Fix config parser warning
/usr/lib/python3.6/site-packages/tripleo_common/actions/ansible.py:154:
DeprecationWarning: This method will be removed in future versions.  Use
'parser.read_file()' instead.
  config.readfp(sio_cfg)

Change-Id: Ibd33a26feae03e4f0d46370346b7a950d1f6b02c
2020-08-19 13:55:48 -06:00
Emilien Macchi 76bc13e3bf ansible: limit_hosts now takes precedence over blacklisted_hostnames
From now, limit_hosts will take precedence over the blacklisted_hostnames.
And therefore Ansible won't be run with two --limit if both limit hosts
and blacklisted hostnames are in use. When we want to run Ansible on
specific hosts, we will ignore the blacklisted nodes and assume we know
what we do. In the case of the scale-down scenario, the unreachable nodes
are ignored.

Note: adding unit tests coverage for both parameters.

Change-Id: I2e9fc7b9e9005fce7d956f1b936054e540b39849
Closes-Bug: #1857298
2020-07-15 14:11:20 -04:00
Emilien Macchi c1dad1ced1 Add tripleo_states to default callback whitelist
tripleo_states will be a useful callback to print out informations about
a deployment state (e.g. if a node failed but was ignored because of
max_failed_percentage).

Depends-On: https://review.opendev.org/735962
Change-Id: I82f4945bf1178fad1ff511c994518008f308d12e
2020-07-07 11:32:50 +00:00
Alex Schultz ed3fdb7764 Fix stdout_callback
We switched to tripleo_dense but the default ansible.cfg that is created
still has tripleo.

Change-Id: I1fcf0aa3212d037db7c4d9baed18959ed6a0cc81
2020-06-22 15:09:32 +00:00
Zuul c3db8fa9e9 Merge "Remove AnsibleGenerateInventoryAction mistal action" 2020-06-15 16:07:58 +00:00
Rabi Mishra b471d2cdcc Remove AnsibleGenerateInventoryAction mistal action
Not used anymore.

Change-Id: If5053530eeadd277db091d60bc9095aa7f05d67f
2020-06-09 11:50:21 +05:30
Zuul ed7049ee84 Merge "Switch to tripleo_dense" 2020-05-30 09:17:24 +00:00
Zuul fe8ab8cb92 Merge "Switch to tripleo stdout callback" 2020-05-29 06:36:08 +00:00
Zuul 1e3c4044cc Merge "Change generate_ansible_inventory() arguments" 2020-05-27 09:43:31 +00:00
Rabi Mishra d0c60a280f Change generate_ansible_inventory() arguments
Mistral context.security auth attributes are not same as the
keystone auth plugins. Use the attributes directly in
generate_ansible_inventory() function.

This will help us to move to using ansible module.

Change-Id: I83856119ea53e39d1891c3f7d94a4d5645da0046
2020-05-21 19:52:52 +05:30
Alex Schultz 0186702a41 Switch to tripleo_dense
Change-Id: Iff8eec43bd73bc6486f56e741e740869d1b8acbb
Depends-On: https://review.opendev.org/#/c/726479/
2020-05-08 15:59:40 -06:00
Alex Schultz b3c87dda23 Switch to tripleo stdout callback
In order to improve the UX and prevent confusion during the async status
output, we need to write a custom callback to change the text.

See See also https://github.com/ansible/ansible/issues/63926

Change-Id: Ie3021ddfe1b4ca304cfd34a46fd4e4c7e9c62e9f
Depends-On: https://review.opendev.org/#/c/725665/
2020-05-05 12:53:55 -06:00
Alex Schultz ffb1ac86a4 Switch fact caching connection
For the jsonfile plugin, the path should be a local directory. This
directory needs to be readable by any user that would execute the
playbook. Since /var/lib/mistral may not be world readable, we should
use something in the user's home dir instead.  This changes it to
~/.ansible/fact_cache

Change-Id: I8fa7127cf9ebb51ce4f090670ec2a45bcfcf77e8
Closes-Bug: #1873480
2020-05-04 04:24:17 +00:00
Rabi Mishra 3952924859 Refactor ansible inventory generation
- Removes the incorrect swift_url lookup
- Removes the usage of session object
- Removes os_auth_token for undercloud
- Moves the code to inventory module for it to be used in ansible
module

Change-Id: I3cdce51764a27a389e008832ed366b6346c4f0e0
2020-04-28 19:13:15 +05:30
Luke Short df7c32c707 Only add non-empty blacklisted hostnames.
This addresses an issue in CI where 'Controller!' is being passed as
the --limit host in the job:
tripleo-ci-centos-8-scenario000-multinode-oooq-container-updates

Change-Id: I0056fdbe3d9807e6baf4a1645a632ab9eb1b2668
2020-04-13 09:44:45 -04:00
Emilien Macchi 36d0f5c3bd Set scp_if_ssh to True in ansible.cfg
To avoid the warning "sftp transfer mechanism failed" during Ansible
run (also reported here:
https://github.com/ansible/ansible/issues/22127); let's set scp_if_ssh
to True.

The default is False; which means it'll first try sftp (which fails
since we use pipeline) and fallback on scp. To avoid the warning, let's
set it to True directly, so we use scp.

Change-Id: I637d850d0de75e60835d229b36b85e699b037543
Closes-Bug: #1869735
2020-03-30 10:53:03 -04:00
Zuul f1c78097c3 Merge "config-download timeout should KILL the process." 2020-03-24 08:47:46 +00:00
Kevin Carter 0ce64425f0
Add mistral workflow module path to mistral ansible config
This change extends the module path found within the the `package_update`
workflow so that we can ensure proper access to modules when ansible commands
are run from within the mistral container.

Change-Id: Id912a0786451825f48822b209400f0f72758dfc8
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2020-03-23 11:44:39 -05:00
Luke Short 7be36f3051 config-download timeout should KILL the process.
The timeout command defaults to using TERM which does
not always ensure that it will end soon enough. The
ansible-playbook command should end as soon as possible.

Change-Id: I0f97772434040f04f9495239b9a432c1ac062555
Closes-Bug: #1867968
Signed-off-by: Luke Short <ekultails@gmail.com>
2020-03-18 14:05:20 -04:00
Sai Sindhur Malleni ffff7887d4 Set PROFILE_TASKS_TASK_OUTPUT_LIMIT
Currently it is set to 0 by default which results in a summary not
being printed at the end of the ansible playbook run. It would
greatly benefit operators if we printed out the top 50 time consuming
tasks at the end of the playbook run.

Change-Id: I140fe66091d4e7a710f04da15cc93b7e6bf5742c
Signed-off-by: Sai Sindhur Malleni <smalleni@redhat.com>
2020-02-07 12:03:09 -05:00
Kevin Carter 8ab0901ad7 Tune ansible configuration for better performance
This change will update our ansible configuration to ensure we're getting the best
possible performance when running ansible playbooks via mistral.

- sets the ansible option internal_poll_interval so that we lower overall cpu
  consumption.
- sets the ssh option PreferredAuthentications so that we're only offering
  pubkeys when connecting to remote hosts which, in most cases, will save us
  from attempting a PTR lookup.

Change-Id: I421183abd0982f9f57f8719d72fd2cbf2e3d4d04
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2020-01-29 15:05:34 +00:00
Zuul cecfdade60 Merge "Add config_download_args to the deployment workflow." 2020-01-28 13:38:11 +00:00
Luke Short 07833ad572 Add config_download_args to the deployment workflow.
This will allow additional arguments to be passed directly
to the ansible-playbook command.

Change-Id: I0637f5c2b149017ae5630c3a93e46c45d7662786
Signed-off-by: Luke Short <ekultails@gmail.com>
2020-01-27 11:41:50 -05:00
Luke Short 87d45ac42c Dynamically set the number of Ansible forks.
Because our usage of Ansible is CPU-bound, the recommended
value is 10 x CPU_CORES.

Change-Id: If6d2b22e20c66e5ebdef952746c8aba7c2d54537
Signed-off-by: Luke Short <ekultails@gmail.com>
2020-01-17 16:53:34 -05:00
Luke Short bbca58f2dd Enforce 0600 permissions on an existing SSH private key file.
Change-Id: If5d79f75037e252276a76bf010874e374df67e87
Closes-Bug: #1859244
Signed-off-by: Luke Short <ekultails@gmail.com>
2020-01-12 20:00:03 -05:00
Dougal Matthews ac478f3cee Remove the tripleo.ansible action
This action has never been used in TripleO and was only included for
historical reasons. Originally the Ansible actions were intended to be
moved to the Mistral project and were generic. However, that work has
stalled and over time the Ansible actions in TripleO have become more
TripleO specific. We have been diligently updating both actions, while
only using one. Removing the one we don't use will make things a little
simpler for everyone.

Change-Id: I1a008aa88cea4366203c102443552bc07644d54d
2020-01-06 12:32:48 +00:00
Zuul a89ef816ae Merge "Default to 50 Ansible forks." 2020-01-03 20:44:43 +00:00
Jose Luis Franco Arza 6b4f47dd42 Change the python interpreter discovery mode.
Current default mode for the python interpreter discover inansible 2.8 is
auto_legacy. This patch changes the mode to auto, the biggest difference
respecting auto_legacy is 'If no entry is found, or the listed Python is
not present on the target host, searches a list of common Python interpreter
paths and uses the first one found' [0].
Currently, it has been observed some issues with the
discovered_python_interpreter fact not getting updated on specific scenarios
(for example, when upgrading the node from RHEL7 to RHEL8). This change is
expected to improve this situation.

[0] - https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#
Related-Bug: #1856313
Change-Id: Iaef4839bb15ec398537b5c57a441c8e28a552bc0
2019-12-17 15:26:57 +01:00
Emilien Macchi 9e8f79ccf3 actions/ansible: catch errors when cleaning the work directory
If an error happens during the cleaning of the work directory, we now
catch the error and return the error to Mistral.

Change-Id: Id037525650c9976cd88a8ba2a02b206ec03855aa
2019-12-16 22:11:22 -05:00
Luke Short 0fa8f221d2 Default to 50 Ansible forks.
During the initial Overcloud deployment, tasks will be ran on 50
hosts at a time now instead of 25. This allows for a faster
deployment of a large number of Overcloud nodes.

Change-Id: Idf0351dbc05bb63ae180e61beb9e7f933dc6fa31
Signed-off-by: Luke Short <ekultails@gmail.com>
2019-12-16 10:55:47 -05:00
Cédric Jeanneret 33417a43aa Remove workdir only if it's a temporary one
Up to now, in some cases, you might see the "persistent" workdir being
removed, for instance after a scale-down run.

This patch intends to drop only temporary workdirs, so that we shouldn't
see the /var/lib/mistral/<stackname> disapearing.

Change-Id: I4516648c9281becffe8f31b76db22da84caf3ca8
Co-Authored-By: "Dougal Matthews <dougal@redhat.com>"
Closes-Bug: #1856061
2019-12-13 09:19:28 +00:00
Luke Short d504caff6c Use the Mistral directory for storing the Ansible fact cache.
This aligns with how TripleO currently stores all Ansible data
in /var/lib/mistral/. Our documentation already recommends
running setfacl on that directory if an end-user wants to
access the files there.

Change-Id: I29d0a353cd0a0d28f36460a8e81003378884a5bd
Closes-Bug: #1850916
Signed-off-by: Luke Short <ekultails@gmail.com>
2019-11-12 15:45:13 -05:00
James Slagle efe21cdecb Revert "Set display_skipped_host to no"
display_skipped_hosts=no has the unfortunate side effect of not showing
the running task name until the task has returned. The reason is b/c the
task name won't be shown at all if all hosts are skipped, but that won't
be known until the task returns.

For long running tasks, this can be quite misleading as the running task
name is not seen until it returns. This makes debugging difficult, and users
don't know what task is actually running until it's completed.

There is an option to show the task name as soon as it starts executing,
but it was not added until ansible-2.9:
https://github.com/ansible/ansible/pull/53819

See also https://github.com/ansible/ansible/issues/51042

This reverts commit 403535c572.

Change-Id: Ia9e291d476d3143b194ce06002a0c1745cf3ef94
2019-11-05 16:45:11 -05:00
Jesse Pretorius (odyssey4me) bbc0d767bb Implement Ansible fact cache for Mistral executor
Most of the playbooks executed by Mistral gather facts which, by default,
are stored in memory until the conclusion of the playbook execution. This
means that for every new playbook run the facts for each host are gathered
again. Fact gathering can take a long time, especially when the target host
has a lot of devices, which is often the case for compute hosts (many
network devices and many storage devices) and for controller hosts (many
network devices).

To optimise fact gathering, we set the default behaviour for Mistral's
Ansible execution to store gathered facts using the jsonfile format in a
temporary location, and we tell it to use smart gathering so that it will
only gather new facts when a new playbook executes.

The validations are run using the 'validations' user, it cannot share the
same fact cache because the /var/tmp/ansible_fact_cache folder will be owned
by the 'mistral' user, and is therefore not writable by the 'validations'
user. We therefore set the validations to use a different path.

This should cut down the deployment time a bit, which saves a little time in
CI and saves a lot of time in production environments.

Related: rhbz#1749406
Change-Id: Ie7adf41cef0fafde646f840b2bf3e01ba42a17d5
2019-10-02 15:37:18 +01:00
Alex Schultz 403535c572 Set display_skipped_host to no
This will suppress the tasks if they aren't actually run.

Change-Id: I299fef52f5b69b5482c24fe1cb283e9dd859445d
2019-09-20 09:42:21 -06:00
Alex Schultz bbd92d6723 Add profile_tasks to ansible runs
Adding profile_tasks to the default ansible.cfg so we get task timing in
the output.

https://docs.ansible.com/ansible/latest/plugins/callback/profile_tasks.html

Change-Id: I6e5ff1f59e8179133099f3b9e405d66aab24be78
2019-09-20 09:35:03 -06:00
James Slagle c7d44bc2ca Honor trash_output when not using queue
Previously, trash_output was not honored if a queue was not being used
to post messages.

This patch changes the behavior so that trash_output will be honored
even if a queue is not being used, and all stdout/stderr will be
discarded.

Change-Id: I4fccfa0cb2a5382a52d63598f66dae446ff29c25
Closes-Bug: #1842102
2019-09-03 16:49:56 -04:00
Saravanan KR a41e5b3f59 Add filter plugins path to the ansible.cfg
Custom filter plugins are required for certain roles (like
tripleo-ovs-dpdk), adding the path to the generated ansible.cfg
file.

Change-Id: Ic2144aac86df5498062a039562b79f01def7da49
2019-08-21 18:45:33 +05:30
Kevin Carter 2d541ba56f
Add tripleo-ansible directory namespace
The tripleo-ansible project will now install it's contents into a
namespaced directory. This was done to ensure we can smoothly
transition to using tripleo-ansible without having to worry about
conflicting files. To ensure our services are able to access this
namespace the configuration PATH has been updated to include the
new namespace.

Depends-On: Iedbf9d1034ee3396d6cb064c64169c21ebcf3e18
Change-Id: I128646937b02902f92c22259e97c9e6024769234
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2019-06-19 15:58:22 -05:00