220 Commits

Author SHA1 Message Date
Sergii Golovatiuk
299718997c Replace warn with warning method
There is a following deprecation warning
"DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead"
This patch changes warn to warning method to fix the DeprecationWarning

Change-Id: Id2173c89be889ea2c227e515db0237a1e6674702
Related-Bug: #1838765
2019-08-02 16:11:55 +02:00
Gael Chamoulaud
d7793ce1a5 Add gathering_policy parameter to run_ansible_playbook function
This patch adds a new parameter called 'gathering_policy' (Defaults to
None) to the 'run_ansible_playbook' function. This parameter will
control the default policy of the Ansible fact gathering. Sets to None
by default, it will use the default policy for Ansible (ie. 'implicit').

Change-Id: I0668241a1675dd4e344cc24b6ff2cbb8f93b7a45
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-07-31 08:44:44 +00:00
Gael Chamoulaud
4f55cdf59a Use static inventory YAML file for saving execution time
The validations execution will use now a static inventory file to speed
up things a bit. Note that this file will be removed after execution.

Change-Id: Ibdc3fc7ea9d3dec9531a2ce29ec8a1477c33c780
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-07-31 08:44:17 +00:00
Gael Chamoulaud
17e56a01d5 Add plan parameter to run_ansible_playbook function
This patch adds a new parameter called 'plan' (Defaults to "overcloud")
to the 'run_ansible_playbook' function. It will allow to execute
Validations with Ansible in a different plan or stack that the default
one through the TripleO CLI. Note That it was already possible only
while using Mistral but not for Ansible.

This patch also brings:
- Change the default values of the 'tags' and 'skip_tags' arguments
  to 'None' and fixes their non Pythonic tests.
- Add '--stack' alias to the '--plan' argument for 'validator run'
  command.

Change-Id: I6f8f55963f3f5261ec1497b650e0ca509d31dd32
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-07-31 08:43:10 +00:00
Gael Chamoulaud
d1084193f6 Add --parameters and --create-vars-file arguments to the list subcommand
The 'openstack tripleo validator list' subcommand can now get only the
available parameters for the validations using the new --parameters
argument.

```
$ openstack tripleo validator list \
    --parameters                   \
    [--validation-name <validation_id>[,<validation_id>,...] |
     --group <group>[,<group>,...]]
```

Here is an output example:

```
Waiting for messages on queue 'tripleo' with no timeout.
{
    "undercloud-cpu": {
        "parameters": {
            "min_undercloud_cpu_count": 8
        }
    },
    "undercloud-ram": {
        "parameters": {
            "min_undercloud_ram_gb": 24
        }
    }
}
```

The --create-vars-file allow the operator to generate either a JSON or a
YAML file containing only the parameters of one or multiple validations.
This file will be available to pass as extra vars to the validations
execution.

```
$ openstack tripleo validator list \
    --parameters                   \
    --create-vars-file [json|yaml] /home/stack/myvars \
    [--validation-name <validation_id>[,<validation_id>,...] |
     --group <group>[,<group>,...]]
```

Change-Id: I6e2255c0d490ee8105f0757d02f5d8fba1d4fa20
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-07-23 11:08:54 +02:00
Gael Chamoulaud
35952145a1 Add extra_vars parameter to run_ansible_playbook function
This patch adds a new parameter called 'extra_vars (Defaults to None) to
the 'run_ansible_playbook' function. This parameter will set additional
variables to the 'ansible-playbook' command. It will accept either a
dict or the absolute path of a file (YAML or JSON format).

Change-Id: Ib25ee9593528ad680b14ca09c62addbbd0b773a3
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-07-23 11:08:50 +02:00
Gael Chamoulaud
e0d35b30de Renaming 'Metadata' column by 'Parameters' when listing validations
All the available Ansible variables for each Validations are now
processed as parameters and not as metadata anymore.

Change-Id: I1151923f3f0de7acf505a0beda3b7488c8ed8dec
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-07-17 11:14:44 +02:00
Harald Jensås
317f3cff7d Ensure files are closed, ensure no ResourceWarning on console
Fixes an issue wich cause warnings such as the one below on the
console when using python3.
  ResourceWarning : unclosed file <_io.TextIOWrapper name='FILENAME'

Closes-Bug: #1836379
Change-Id: I4a80a339b2cc0c3fca992cfc456581a91dbf2eef
2019-07-12 17:44:10 +02:00
Carlos Camacho
27e1e4f833 Allow running validations by name using Ansible by default.
This patch switch over Ansible to run validations by names by
default. The --use-mistral argument will have to be used in order to
execute them through Mistral.

Co-Authored-By: Gaël Chamoulaud <gchamoul@redhat.com>
Change-Id: Ia393f4d776ab2c09439e7772b5596ddbb47e0a5e
2019-07-08 10:49:25 +02:00
Gael Chamoulaud
9de3452cf3 Add log_path_dir parameter
This patch adds a new parameter called 'log_path_dir' (Defaults to None)
to the 'run_ansible_playbook' function. The Ansible log file will be
created in the location of the playbook by default, otherwise in the given
directory path.

Change-Id: I7222a116974458b9149771cb44f7d5f7bc51bc79
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-07-03 15:50:33 +02:00
Gael Chamoulaud
1acbef8a06 Improve validations run outputs through the CLI
When the tripleo.messaging.v1.send workflow fails with the error
'Workflow failed due to message status', the return message is None and
we don't have more information about what's failing. The same happens if
the validation runs well.

This patch improves the output in case of a messaging workflow failure.

Change-Id: I3fbf1a05b706b55fe1ab6d35653aecdaa8d4cc6e
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-07-01 15:21:18 +02:00
Alex Schultz
e1a051d6ac Send terminal erase sequence on tripleo deploy
We're seeing some escape sequences being dropped when we run the
deployment via the undercloud. This causes a user to have to run a reset
after the undercloud installation in order to be able to use their shell
command line again.  We can avoid this if we send an terminal erase line
sequence to trim the rest of the line at the end of the deploy.

Change-Id: Ibb74bfebfaab2cd122abe1bc3cd5bbd2562ccfc5
Closes-Bug: #1833302
2019-06-27 09:33:41 -06:00
Zuul
eaced0d1c7 Merge "nova-less-deploy: stop using glance for ironic-python-agent images" 2019-06-26 08:08:24 +00:00
John Fulton
96d39dc106 Improve handling of empty resource_registry
It's possible that content["resource_registry"] might
not exist or be iterable so wrap the reference to it
with a try/except for a KeyError or TypeError and continue
the deployment without the empty resource_registry instead
of failing.

Change-Id: Ic7d88382a0ff15c24800f12ddbf69f13d6804b28
Closes-Bug: #1833743
2019-06-24 08:30:07 -04:00
Alex Schultz
cb42cfe30f Retry heat stack polling on gateway problems
If the heat api is overloaded or temporarily unavailable, we might get a
503 or 504 from haproxy during the deployment. We should retry polling
for events in this case as to not prematurely exit the deployment.

Change-Id: I947cd0f9bf4a97e46c3d2bf3e9b986f7d38e9357
Closes-Bug: #1833452
2019-06-19 13:56:29 -06:00
Dmitry Tantsur
7ad1b812fc nova-less-deploy: stop using glance for ironic-python-agent images
Ironic can use HTTP links or local files, and we already put the images to
a location accessible inside of ironic containers (for introspection).
This change switches to using file images for IPA. The existing Glance
images are not deleted since some nodes may be using them. Multi-arch
layout of [[PLATFORM-]ARCH/]agent.EXT is reused from the unit tests
of the `image upload` command, assuming that's what people are using.

Change-Id: Ie6fa04112e3348f429dc42b28442f8996ab03f29
Implements: blueprint nova-less-deploy
Depends-On: https://review.opendev.org/#/c/663897/
2019-06-14 17:06:56 +02:00
Mathieu Bultel
5249fbb262 Allow run_update_ansible_action run with Mistral or Ansible
We extend run_update_ansible_action
to allow running the Ansible playbooks with Mistral
or executing directly thru Ansible.

This is needed  in case we need to run
exceptionally a task depending on Mistral
but Mistral is broken. For example, retry
an upgrade operation after having Mistral broken.

Change-Id: I15511b4f36260292e0ea4100b15b8e65a701b38b
2019-06-14 16:47:25 +02:00
Zuul
5bb1ab2906 Merge "Refactor stack output fetching" 2019-05-23 00:30:52 +00:00
Zuul
875bbc74ee Merge "Add ODL deprecation warning in CLI" 2019-05-20 08:26:19 +00:00
Janki Chhatbar
1fee54b9be Add ODL deprecation warning in CLI
ODL is deprecated since Rocky. Add a warning
before deployment asking the user if he wants
to continue with deployment even after
deprecation.

The logic is to check for neutron-opendaylight.yaml
environment file passed to overcloud deploy command.
If yes, ask for user confirmation before starting
deployment.

Change-Id: I1b16aab11591fac610cd4bf49a0927f1ec947146
Closes-Bug: #1827366
2019-05-16 15:23:49 +05:30
Alex Schultz
fd61c26a65 Refactor stack output fetching
We are duplicating the code to fetch a specific value from the stack
outputs. This adds a get_stack_output_item that can be used to fetch
any named stack output and refactors the other functions that did this
same type of action.

Change-Id: I9f45661d432c47f9df962009cc3c6b9182006d1c
2019-05-10 09:58:36 -06:00
Emilien Macchi
c925c3b93b undercloud: resolve undercloud_*_host
The problem we're solving here is that our operators using SSL + FQDN
based endpoints will have failures during the deployment because we
don't lookup the FQDN into IP addresses, needed later in the deployment
for proper binding.

This patch transforms undercloud_*_host parameters into IP addresses:

- We raise if lookup returns nothing.
- We raise if lookup returns more than one IP.
- We support both IPv4 and IPv6.
- We raise if the IP is a loopback.
- We raise if the returned IP is invalid.

Utils changes:

* Introduce utils.is_valid_ip.
  Return True if the IP is either v4 or v6. Return False otherwise.

* Introduce utils.is_loopback.
  Return True if the given host is a loopback. Return False otherwise.

* Introduce utils.get_host_ips.
  Returns a list of IPs for a host to lookup.

* Introduce utils.get_single_ip.
  Translate an hostname or FQDN into an IP address if it is valid IP.
  Return it unchanged if it is an IPv4 or IPv6 address.
  If the host is not reachable, it'll raise an exception.
  By default it excludes the loopbacks but it can be allowed by setting
  allow_loopback = True.

* Use utils.get_single_ip to translate undercloud_admin_host and
  undercloud_public_host to IP addresses.

Related-Bug: #1763776
Change-Id: Ic008cc758493aa95e8aa237d23c2f66c0a930509
2019-05-08 21:08:53 +00:00
Gael Chamoulaud
51a9880702 Get validations playbooks from playbooks directory
With the new validation framework, all the validations have been
migrated into their own Ansible Roles. The validations are now usable
from tripleo-validations/playbooks directory.

Change-Id: Id836ba2d88f04a90c1738bb71f2aeb07211d2620
Implements: blueprint validation-framework
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-05-05 13:24:15 +00:00
Alex Schultz
200d20a71c Update --*-flavor --*-count description
These options now throw a hard error. Let's update the help text to
indicate that they will be removed in the U cycle.

See I94376c5f25c354a9fcdbca11548f7e3eedbd9491

Change-Id: I6826338e028b25230dbf12d4b207e5f4ab7805c8
2019-04-26 18:10:27 +00:00
Zuul
be9b7efdd0 Merge "Use "push" flag for buildah" 2019-04-08 08:35:31 +00:00
Quique Llorente
c0747c0a0b Use "push" flag for buildah
The push=False flag with use with kolla-build.conf is not working if we
use buildah, clear example is the
tripleo-build-containers-centos-7-buildah job, it's suppose to work like
docker one but it's pushing too.

Closes-Bug: #1822752

Change-Id: I01788b3c11ac701b2cf8c151f95ccad7046532de
2019-04-05 13:34:20 +02:00
Steve Baker
73cc43898c Generate inventory for mistral ssh
All of the calls to get_tripleo_ansible_inventory will then pass this
inventory to mistral, so the inventory entry for the undercloud needs
to use ssh as the connection.

Change-Id: I68ad49f103af79ab4b82b499b8620af9470f1ef9
Closes-Bug: #1822518
Depends-On: https://review.openstack.org/#/c/649459/
2019-04-03 11:13:17 +13:00
Steve Baker
c138a49609 Fix confirmation prompt for overcloud delete
In python-3 the confirmation prompt isn't displayed without a flush on
stdout. This change fixes that.

This change also prevents a stacktrace from being printed when a
CommandError is raised, which is a much friendlier way of displaying
that user inputed caused a command to fail.

Change-Id: Ibab5abf6ab57793ca988b36d3411767f82e7e756
Closes-Bug: #1821672
2019-03-26 16:54:15 +13:00
Zuul
8684f64075 Merge "Refactor reading kolla config in image builder" 2019-03-18 19:49:22 +00:00
Kamil Sambor
94bed0ece2 Refactor reading kolla config in image builder
Now we read config file(s) only once

Change-Id: I46893e83cb1d354a17d14ceaf264071823eeb0a3
2019-03-17 15:42:55 +01:00
Zuul
dbce4e9e64 Merge "Force list when returning map(replaced_list_value, template_part)" 2019-03-17 13:39:18 +00:00
Bogdan Dobrelya
f388fceeef Force list when returning map(replaced_list_value, template_part)
As suggested by Jiri in this review adding a list() around
'map(replaced_list_value, template_part)' fixes the py3 issue
for me.

Closes-bug: #1819737
Change-Id: I1241985eac1aa7e092a11db5a443da0055ff0141
2019-03-16 21:04:21 +00:00
Alex Schultz
93bff99379 Fix timezone lookup
Unfortunately strftime does not always return a timezone that matches up
with what is available via zoneinfo on the file system. So instead of
using that, this patch creates a function to use timedatectl on the host
itself to determine what the current timezone is configured to.

Change-Id: I0d64cb0a534b48f1aa747655f7b7d997c74d77bc
Closes-Bug: #1820081
2019-03-15 20:00:41 +00:00
Zuul
0622fbaf5f Merge "Remove overcloudrc.v3 generation" 2019-03-13 00:24:29 +00:00
Juan Antonio Osorio Robles
3b7e70af2e Remove overcloudrc.v3 generation
We've been deploying with keystone v3 for some releases now, so it's
time to get rid of this file; given that it's the same content as
overcloudrc.

Change-Id: I137e08213ef7f0f49510e2ebc905e351fb25b85a
Closes-Bug: #1733640
2019-03-05 15:39:14 +02:00
Carlos Camacho
6f6d6332bb Add new CLI option openstack tripleo validate list
This submission starts with the integration of the current supported
Mistral workflows for running the validations.

This submission integrates the listing of all current installed validations.

Change-Id: Ic4a396598dcfdb55a0858bea95e9a2fcfc7b46e6
Implements: blueprint validation-framework
Depends-On: I294ab0016fda9587b405ef08dba3212b8e46a816
2019-03-05 09:27:19 +01:00
Zuul
5cb3c13395 Merge "Add support of extra variables." 2019-03-04 12:37:02 +00:00
Zuul
49998bd335 Merge "Check that the networks are defined on update" 2019-02-28 17:51:22 +00:00
Natal Ngétal
15712e4f43 Add support of extra variables.
Parses extra variables link ansible would.

Depends-on: I3ee6180f8bfb9d08bb6ea149f87d6c15271b9d4c
Change-Id: I802ce9e342d528614db88f0c00be5893fcac7a24
2019-02-28 10:03:57 +01:00
Emilien Macchi
2a6f876bd7 Fix ansible-playbook-3 symlink
The symlink needs to be created with sudo because if validations are
enabled, the call to run ansible-playbook-3 is before the "sudo tripleo deploy
command".

This patch moves the symlink into a function, that will be called before
the preflight if enabled and during the tripleo deploy/upgrade command,
which should cover standalone deployment and upgrade.

Change-Id: I1ce9b3df6c937cd796728d4fc5921fcf1023e5db
2019-02-27 16:12:26 -05:00
Alex Schultz
1a71c441fa Check that the networks are defined on update
Check defined networks in the resource registry of the stack against the
networks defined in the environment files. If the environment provided
doesn't have the networks defined, it's likely they were improperly
dropped which can lead to deployment issues. This is a light check that
only checks for the existance of the networks but not the contents of
those networks. This handles the case where a user forgets to include
the network-isolation configuration on a subsequent update to the cloud.
This does not prevent a user from changing the contents of the networks
to something that breaks their deployment.

Partial-Bug: #1817631
Change-Id: Ia97a2367770e37bf8c55f2fd04c9a9efde914a67
2019-02-27 09:52:54 -07:00
Emilien Macchi
48525b19bc container image build: introduce --use-buildah
Support Buildah instead of Docker by calling:
  $ openstack container image build --use-buildah

And it will build TripleO containers with Buildah and not Docker.

Co-Authored-By: Alex Schultz <aschultz@redhat.com>
Change-Id: I7608136cb213bdca81348a0c3c751b488f48d712
2019-02-25 19:35:10 -05:00
Alex Schultz
281e019676 Check proxy env vars
If a user is using http_proxy or https_proxy but is not excluding
localhost from being proxied via the no_proxy var it can lead to a
failure when we try and talk to the heat api. This change adds a check
that is used for both the standalone tripleo deploy command and
the undercloud install to ensure the end user does not hit this
condition.

Change-Id: I507d81278097bc3b5e23d53ae35aa26657541bfc
Closes-Bug: #1815814
2019-02-20 12:23:47 -07:00
Alex Schultz
63f4175e76 Run hostname check for standalone
Run a hostname preflight check when running the standalone as this can
cause issues with rabbit/mysql/pacemaker/puppet. The standalone check is
not run when an undercloud is being deployed or if output only is
specified. The undercloud has a different set of preflight checks run
prior to deployment so we do not need to rerun the hostname check when
the undercloud is being deployed.

Depends-On: https://review.openstack.org/#/c/634836/
Change-Id: I4de51d792f004575e0e802a1d340478d6ae9f848
Closes-Bug: #1814564
2019-02-13 16:23:36 -07:00
Dan Prince
471b0d271a Drop unused utils.py roles functions
Now that config download moved to tripleo-common these are
no longer used.

Change-Id: I51a2e4e6d8c73ba0d67ded9caad6ab24b955be65
2019-01-30 07:08:25 -05:00
Mathieu Bultel
252219cc37 Add verbosity level to the ansible update/upgrade run
The tripleo-common allow us to provide a verbosity level
but its not possible to pass it with the cli.
This review catch the --debug option passed to the cli
and provide it to package_update workflow

Change-Id: Ib1fc8f6aab9a0b1a26945d441185b5c8ccb6e7dd
2019-01-18 09:47:18 +01:00
Zuul
4130ffc84f Merge "Use a single queue for update/upgrade" 2019-01-18 04:11:58 +00:00
Cédric Jeanneret
c163a42668 Pass the python interpreter to the play command directly
Ansible doesn't take into account any 'ANSIBLE_PYTHON_INTERPRETER' env
var, as per this comment[1] back in 2016.

We hence have to pass it as an extra variable directly in the command.

This patch corrects I0600218163269409ae35ca34ffdfedb57926424e in
order to ensure we do pass the python interpreter value correctly.

[1] https://github.com/ansible/ansible/issues/6345#issuecomment-181981760

Change-Id: I48c8c532b23b9422406168cecdc9aebfe8f45651
Blueprint: python-3
2019-01-17 12:58:47 +01:00
Mathieu Bultel
c0a57210b9 Use a single queue for update/upgrade
Use a single queue for update and upgrade ansible run to avoid
race while consuming both messages from the web wocket

Change-Id: I8b04c2a39d35f530467ddb5f2c4305c08cbc44f1
Closes-Bug: #1804812
2019-01-15 21:33:38 +01:00
Emilien Macchi
f104636b58 utils: pass python interpreter to run_ansible_playbook
It's required to run TripleO Validation playbooks with Python3 on the
Undercloud.

blueprint python-3

Change-Id: I0600218163269409ae35ca34ffdfedb57926424e
2019-01-15 17:21:50 +01:00