Commit Graph

54 Commits

Author SHA1 Message Date
Ghanshyam Mann 9080d003d9 Retire Tripleo: remove repo content
TripleO project is retiring
- https://review.opendev.org/c/openstack/governance/+/905145

this commit remove the content of this project repo

Change-Id: I4c7d62a3a3ef5601d04375677e1ea07f9cd9eff9
2024-02-24 11:45:13 -08:00
matbu 08e2e1a060 Deprecates tripleo-ansible-inventory and remove tripleo-validation scripts
tripleo-ansible-inventory is broken in Master/Wallaby and need to be revisit
to what tripleo is actually deploying:
* tripleo-deploy directory contains a valid inventory
* tripleo-ansible with the playbook cli-config-download.yaml offers a way to
  regenerate a fresh inventory.

This review also removed the scripts/tripleo-validation.py which is not longer functional
with the current VF CLI.

Change-Id: Ie02259336c763cfa980b59ad64f9e478d05690fb
Closes-Bug: #1936406
Resolves: rhbz#2008426
2022-06-14 13:24:27 +00:00
Gael Chamoulaud (Strider) 5a8cfac7f9
Fix Inventory Generation without Overcloud deployed
The utils.list_plan_and_stack function returns None in case of exceptions
or and empty list if no stacks or no plans have been found in the
environment.

This patch fixes the conditional to allow the tripleo-ansible-inventory
script to generate only the undercloud Inventory when no Overcloud has
been deployed.

Related-bz: rhbz#1987318

Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
Change-Id: If0dc3300fbd8cf245c0477be782110d897344860
2021-07-29 15:45:11 +02:00
ramishra ee6e66649f Use OS_CLOUD environment variable
If OS_CLOUD env variable is set, that should be used.

Change-Id: If2578fcd069ba60e33b375c04ba2912affce53e0
2021-06-08 16:08:41 +05:30
David Vallee Delisle 040fd0486e More detail in arg validation
There's no reason to forbid --list and --static-yaml-inventory
Also, we should return an error if both --list and --host are
defined.

Change-Id: I94393de4a71a92c12f8d427748853d7ff2ce5a02
2021-04-20 22:29:38 -04:00
Mathieu Bultel 6de73491d6 Fix set by merging two list without duplicate
The previous statement result to an empty list, this
fix merge the two list and avoid duplicate

Declare auth_variables dictionary to avoid
reference before assignment issues

Change-Id: Ie28357d692f604c647d0f252a932242024e84f6e
Closes-Bug: #1914084
2021-02-10 15:51:55 +00:00
Mathieu Bultel e9b33aefdc Generate inventory without any overcloud
When no overcloud is deployed, we forced to pass the overcloud
hardcoded value to the inventory.
We should, if no --plan or --stack passed, check if there is
plans or stacks on the environment.
If so, used it, if not then just generate undercloud inventory

Depends-On: https://review.opendev.org/c/openstack/tripleo-common/+/765524
Change-Id: Idf4269a2ae5ce9863e1eda2f824e7a9fc93847d2
2021-01-13 23:04:29 +01:00
Mathieu Bultel e83ae79677 Add os-cloud support for tripleo-ansible-inventory script
Implement the --os-cloud authentication

Change-Id: I0f1a15b36d48d6f771b85f6c9b0adad3017f4bdf
2020-08-20 14:00:27 +02:00
Hervé Beraud 2d565ad8ee 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: I91036721fcb78c8eec234577d3c4f40690fb6eb6
2020-06-02 21:05:42 +02:00
Oliver Walsh afe97a3024 Fix multistack inventory
Switch to new multistack inventory class interface.
Also TRIPLEO_PLAN_NAME did not work for comma seperated list.

Depends-On: Ife14dbe04dd11db44a944f98373f63e01dfbb8d8
Change-Id: I2cc721676005536b14995980f7a042991c92adcc
Related-bug: #1849073
2020-03-20 20:44:46 +00:00
James Slagle c8a490f25b Fix Python 3 incompatibility in tripleo-ansible-inventory
When running under Python 3, the keys() method on a dict returns a
dict_keys object, not a list. The dict_keys object can't be indexed like
a list, so an exception is thrown. This patch switches from using the
keys() method to using list() on the dict instead, which returns a list
of the keys.

Change-Id: Ifb1814f2406318c4c42edc21581a6fc6d34eb91e
2019-10-02 15:42:27 -04:00
Mathieu Bultel 5004e64c66 Fix get plan_name default value for inventory script
Since the default value has been updated to return a list
for the plan_name value, if the os.environ.get is None
then the default is a list with a None value: ['None']

We need to set a real None value, in order to set the
default 'overcloud' value.

Change-Id: Ia84e458c4a79f0a606d15e1b2739b48e5bbda21e
2019-09-25 08:32:31 +02:00
Piotr Kopec 53114f36d4 Fix tripleo-ansible-inventory
This [1] introduced support tripleo-ansible-inventory for multiple
stacks/plans and now configs.plan needs to be list/iterable.

[1]: I23fdeaa4950244bf3aec8e8ea71e8a29f763c074

Change-Id: I929a3490d88602eaf62bbe1a559febfc185aa7e9
2019-09-13 15:55:44 +02:00
John Fulton 35f3d60dcf Add multistack support to tripleo-ansible-inventory
If tripleo-ansible-inventory is called with '--stack foo,bar',
then build an inventory for stack foo and stack bar; then
merge the two inventories into one before writing it out to
an inventory file.

An ansible inventory host group will be created for every
item in the cross product of stacks and roles. For example,
central_Controller, edge0_Compute, edge1_Compute, etc.

Change-Id: I23fdeaa4950244bf3aec8e8ea71e8a29f763c074
Depends-On: I522f1acbd39ad36ae1fec896188d3e20e0575566
Implements: blueprint split-control-plane-unified-inventory
2019-09-05 12:17:36 -04:00
Zuul a4ac99c269 Merge "Set undercloud-connection to local by default" 2019-08-29 12:35:45 +00:00
Jose Luis Franco Arza b60bc84644 Pass undercloud_connection in TripleoInventory instantiation.
The parameter undercloud_connection is being available as
an input option in the script, however it was not being passed
into the TripleoInventory object instantiation.

Change-Id: Ife819b1d807946c8e53deaacbb8e4f9361009f6e
Closes-Bug: #1832932
2019-08-28 15:52:30 +02:00
Gael Chamoulaud d253d52f3f Set undercloud-connection to local by default
This patch fixes the right default for the 'undercloud-connection' option
according to the help message.

Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
Co-Authored-By: Jose Luis Franco <jfrancoa@redhat.com>

Change-Id: Ib0eb19ddd2968ab328565dec3171f480327be27f
2019-08-28 15:47:10 +02:00
Jose Luis Franco Arza db30779959 Add undercloud-key-file and ssh_network options.
To enable the execution via ssh into the Undercloud node it's
required to pass also the ansible_ssh_user private key. This
options is part of the tripleo_common inventory.py, but defaults
to None.
This patch allows to pass this parameter in case it's needed.

Also, this patch allows to pass a different value for the host_network
parameter in TripleoInventory instantiation. Setting it by default to
ctlplane.

Change-Id: Id303f356c1b06906aa5aae43b0032bb80a712508
Related-Bug: #1832932
2019-08-26 17:02:20 +02:00
Mathieu Bultel 90a35760e2 Add serial option in tripleo-ansible-inventory script
In order to allow the user to override the serial value
for parallel execution on nodes, this review adds the
--serial option to the tripleo-ansible-inventory script

Depends-On: I6605aec1d42a714f2f2c72b9233bc3bf510177de

Change-Id: Icc4fa67b123c5b51c4797ef32e38c0f26c5bfcfa
2019-05-09 08:18:02 +00:00
Steve Baker 2468a5b267 Add an --undercloud-connection argument
This script isn't only used for local ansible inventories, it is also
called by tripleoclient commands which then pass the generated
inventory into mistral. This means there need to be the option of
making the undercloud connection use ssh, since this is now what
mistral requires.

Change-Id: If4d877dbb144947347afe1de7a06f623d2db3941
Partial-Bug: #1822518
Depends-On: https://review.openstack.org/#/c/648899/
2019-04-03 11:11:19 +13:00
Sergii Golovatiuk 9c6792b344 Remove deprecated inventory option
static-inventory was deprecated in Rocky. This patch removes it from
Stein release.

Change-Id: I28d66227e0bb79246c00fd53268f856792dcd756
2018-12-03 12:36:26 +01:00
Alex Schultz c914afb265 Add ansible_python_interpreter to the inventory script
In order to be able to specify that we would like to use python2 or
python3 with the generated ansible inventory, the
tripleo-ansible-inventory script should take this as a parameter like it
does for the ansible ssh user.

Depends-On: https://review.openstack.org/#/c/617793/
Change-Id: If70d046b3bdb2b0bd9fcc334e53f72e97b127cd7
Related-Blueprint: python3-support
2018-11-13 13:04:49 -07:00
Sergii Golovatiuk 3cb1465ce4 Correct inline documentation
There is no --static-yaml-format option. The patch corrects documentation to
use --static-yaml-inventory option.

Change-Id: Ie4b3b55f5a5f7612bf389bf9be5443181f27fe0f
2018-10-30 19:09:26 +01:00
Ana Krivokapic a02ca6e6f6 Make inventory fail if Heat engine is down
This change ensures that the inventory script will fail, and not hang,
if the Heat engine is not running.

Change-Id: Ib22a926aca736819cbfbe53fd3c5d53640e462b8
2018-09-12 12:32:46 +00:00
Ana Krivokapic d860d9e335 Refactor service client getters
This change removes duplication of service clients instantiations
throughout the code (especially the lookup plugins). It also
consolidates service client getter functions by placing them all
in the utils module.

Change-Id: Ia8ba252de3cebca9e75266f7bcbba373cc0f5008
2018-08-21 12:29:07 +03:00
Florian Fuchs d96473bb3b Revert "Fail if the Overcloud inventory is empty"
This reverts commit 773bef1c7a.

The reverted commit made the inventory fail if there was no overcloud
deployed. However, the inventory is also used a lot in cases with no
overcloud (many validations for instance).

Change-Id: I19a4e02d25037f54c2449396ea84492b49555fd6
2018-08-02 18:31:14 +02:00
Jose Luis Franco Arza 9bace992f3 Add std_error output to error log in tripleo-ansible-inventory.
The standard output was missing in one of the error logs
inside tripleo-ansible-inventory. This made it pretty
hard to debug when ansible-playbook failed due that
inventory script error.
This patch also formats a little the error message to give
some more info about the issue.

Related-Bug: #1768011
Change-Id: Ib240a4626bedb4d2a2d0b51caf696b3728fb7fb0
2018-05-22 15:35:40 +02:00
Carlos Camacho 773bef1c7a Fail if the Overcloud inventory is empty
If tripleo-ansible-inventory can not retrieve the
inventory, the script should fail and
display an error message for the users to
fix the plan or stack name before continuing.

Change-Id: I76fe01b7f2ec84db8a8aeaa749cb7b961667b3c9
Closes-Bug: 1768011
2018-04-30 20:22:35 +02:00
Zuul 1edb2385ab Merge "Improve exceptions in tripleo-ansible-inventory" 2018-03-07 16:21:46 +00:00
Jill Rouleau d603d97806 Deprecate ini formatted static-inventory
Deprecates static-inventory, as ini formatted inventory no longer works
with role_data values. static-inventory will now return a
static-yaml-inventory file.

Change-Id: I74ae2290f50bac213134e45f1710c1d3c3200b7a
Closes-Bug: 1751855
2018-03-06 10:11:39 -08:00
Jill Rouleau 5d30a5aa8e Improve exceptions in tripleo-ansible-inventory
Adds a debug flag to surface tracebacks on failures.
Also removes .message from exceptions, as this is deprecated in 2.6
and removed in py3.

Change-Id: I7d2cdc37bd134370ff7edcefa3a4589024d5ce9a
Closes-Bug: 1751340
2018-02-26 10:42:56 -07:00
James Slagle 80c842c09d Add help for --plan, add --stack
In order to use tripleo-ansible-inventory with a different stack name,
you had to know to specify that name with --plan.

This commit adds help for the --plan cli arg, and also adds a new
--stack cli arg that has the same effect. --stack is more consistent
with other cli tools in TripleO. If both are specified, --stack will
take precedence.

Change-Id: I64b2c66eb2d37f0f231895c0cec3f8415de9f342
2018-02-09 14:44:12 -05:00
Steven Hardy 3d732165e1 Adjust TripleoInventory arguments, don't pass config object
Instead pass the individual named parameters, which is clearer
and easier for tests, particularly now that some of these are
optional.

Change-Id: Ic49cccdcd900e0ca97d1f6c4675e865e6357363d
2018-01-03 17:55:06 +00:00
Steven Hardy cb18c3c30a Add --static-yaml-inventory option to tripleo-ansible-inventory
This allows dumping a static inventory in yaml format, which makes
representing vars containing complex data types, e.g lists/maps easier
than with ini format (which only supports string values).

This also makes use of the tripleo-common class that now supports
writing a yaml format static inventory, so we deprecate the old code
and CLI option for later removal.

Change-Id: I38b9e17ef7981c22850b17d7bb8396c8db3a1b0a
2018-01-03 16:57:52 +00:00
Steven Hardy ac39a918f8 Move tripleo ansible inventory code to tripleo-common
This moves the main code/class to tripleo-common, as there is a need
to use this in tripleoclient (which already depends on tripleo-common)

Note we don't move the tripleo-ansible-inventory at this time, since
it's not needed for the tripleoclient use-case and it will require
packaging changes.

Depends-On: I03f609b8ff9f36c95a8382aa1705147d99cb973b
Change-Id: Idd6e8f69788e857bc5a81dae344fb41d5be68846
2017-12-19 09:50:17 +00:00
Bogdan Dobrelya fde797ca14 Add env var for custom ssh user
W/o an env var, a dynamic inventory can't be invoked for a custom
user. Ansible uses the same ANSIBLE_SSH_USER so the value will
be aligned to both.

Related-bug: #1734298

Change-Id: Ieddbb4c87d88888f78d494ff670db907bce4fd78
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
2017-11-24 18:08:07 +01:00
James Slagle ff37e696c3 Specify vars after children sections
Changes how the vars and children sections are ordered in the generated
static inventory by tripleo-ansible-inventory. Due to a change in
ansible 2.4, having them in the opposite order caused no hosts to match
the inventory.

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

Change-Id: I2aa1a04ea8a963b9c613008c12b1efffd365ceaf
implements: blueprint ansible-config-download
Closes-Bug: #1729058
2017-10-31 14:36:21 -04:00
Sofer Athlan-Guyot ddc025d472 Make sure to keep case when for host definition in host inventory.
Config parser remove capitalization information when it writes the
configuration file.  Make sure to keep by removing any transformation.

Change-Id: I7f46e4b7bdac5110d111537a044473c362d059f6
Closes-Bug: #1712190
2017-08-21 22:24:53 +02:00
Michele Baldessari 8a2022e8a5 Do not output empty variables in inventory
Currently tripleo-ansible-inventory --static can create an invalid
inventory file:
The offending line appears to be:
[undercloud]
localhost
^ here

Attempted to read "/home/stack/validations_static_inventory" as ini file: /home/stack/validations_static_inventory:11: Expected key=value, got: cacert

The broken snippet can be:
...
ansible_connection = local
cacert
undercloud_swift_url = https://192.168.24.2:13808/v1/AUTH_ab355edddba843deafef01bf520e8648
...

We need to make sure that keys that have a 'None' dictionary do not
break the inventory file.

Change-Id: I009c7b52a4d1dabc3ceaad14a828f90ff3845b94
Closes-Bug: #1701239
2017-08-21 21:17:06 +02:00
James Slagle 3e9bc95b20 Configurable ansible_ssh_user for tripleo-ansible-inventory
The ansible_ssh_user in the generated inventory by
tripleo-ansible-inventory is now configurable instead
of hardcoded to heat-admin. The default is still heat-admin.

Change-Id: I137d303e0a5555a0c9e138b548560637c619b492
Closes-Bug: #1710240
2017-08-11 11:24:24 -04:00
Florian Fuchs 748c46357b Retreive AdminPassword from heat instead of mistral
The overcloud admin password is currently retreived from the mistral
environment. Since this value can also be retreived via heat and the
mistral environment isn't used anywhere else, this change removes the
mistral dependency.

Change-Id: I38233ea71f81e547fed756fbdddf244db594da2f
2017-05-12 10:27:38 +00:00
Juan Antonio Osorio Robles 834d014e89 Add ability to write static inventory
In some cases it might be useful to just have a static inventory,
since bigger deployments might take a long time to process each
time. This enables the option --static-inventory to the
tripleo-ansible-inventory script, which does just this.

Related-Bug: #1689789
Change-Id: I96a6b1bc17035b116a85e4e560452321123551dc
2017-05-11 06:57:36 +00:00
Juan Antonio Osorio Robles b9993635c1 Pass printing responsibility to dynamic inventory script
The class object now just returns the dict, and the responsibility
of printing the json object is now part of the dynamic inventory
script. This separation was done so in a further commit, more options
can be passed to this script.

Related-Bug: #1689789
Change-Id: I51dfd8618b88bcd2d28dbc799dbb4820c6055705
2017-05-11 06:56:19 +00:00
Florian Fuchs 9461adfa24 Show all roles in inventory
This patch updates the tripleo-ansible-inventory to show all roles in
the host list, not just compute and controller nodes.

The retrieval of IPs and stack outputs is slightly refactored: Instead of
retrieving them from Nova, the host IPs are now read from the stacks new
RoleNetIpMap output. The stack outputs are fetched from heat via a new
`StackOutputs` class that ensures outputs are only fetched when needed.

Closes-Bug: #1685544
Closes-Bug: #1689789
Change-Id: Ic8a19f15dd45b383a3f3d403653e3eaef2c1865b
2017-05-10 13:12:39 +00:00
Juan Antonio Osorio Robles c27d91d8cf Use OS_PROJECT_NAME and fallback to TENANT for inventory script
Using keystone v3, the name of the environment for getting the tenant
changes from PROJECT to TENANT, so it should be reflected in the dynamic
inventory script, else it'll fail.

Change-Id: I755868c4a276806f3568468bebee4dfb3bcf7c7f
2017-05-10 09:18:15 +03:00
Florian Fuchs 9463eb3dfc Add lookup plugin for tripleo heat templates
This patch adds a lookup plugin for tripleo heat templates
that playbooks can use as: "{{ lookup('tht') }}"

The lookup will return a list of tuples, each tuple
containing the path and the contents of the file.

To implement this the auth token as well as the plan
name have been added to the inventory.

Change-Id: I8ab1563dc887e51339e669592011f2115cfe5e4c
2017-04-18 15:49:05 +00:00
Florian Fuchs b669bcbf45 Fix token auth in ansible inventory script
The token authentication in the inventory script currently uses the
`user_domain_id` parameter, which is supposed to be used with password
authentication only.

This patch removed the param.

Change-Id: I5ec5aa386eb267283cc187cf1d4206827e6b3191
Closes-Bug: #1678029
2017-03-31 12:27:09 +02:00
Juan Antonio Osorio Robles 280cc0112a Use generic keystone plugins instead of version-specific
This allows us to use versionless endpoints.

Change-Id: Id378fdad6196a72034ddcc107a643770c4349a22
2017-03-14 12:24:09 +02:00
Martin André f6a8d3d9cd Migrate from keystoneclient to keystoneauth
Since novaclient 7.0.0, the tripleo-ansible-inventory silently ignores
a novaclient error and skips all overcloud nodes in its output.

Switching to keystoneauth solves the issue in a clean fashion.

Change-Id: I2019ceebda8bf6bf2e1f01bba9e1d5c143c8738d
Closes-Bug: #1666662
2017-03-07 13:23:23 +01:00
Tomas Sedovic 8927704efa Don't rely on overcloudrc
We were reading overcloudrc for the openstack-endpoints validation.
However, the name of tha file may differ if the deployment plan is
called something else than "overcloud" and more importantly, the GUI
deployments don't create the file on the undercloud at all.

This updates the Ansible inventory to read the admin password and
keystone url for the specified plan if available and the validation to
use those values instead of relying on overcloudrc.

Change-Id: I9ff26016c43888267968ef2588f686f7de95bda3
Closes-Bug: #1643808
2016-12-01 16:47:25 +01:00