269 Commits
1.4.0 ... 1.9.0

Author SHA1 Message Date
Jakob Meng
ce60e71bde Release 1.9.0 version
Change-Id: I50bfae762f4e3f0f5de41db749942b8bdb51f5fd
Signed-off-by: Jakob Meng <code@jakobmeng.de>
2022-08-25 10:49:00 +02:00
Jakob Meng
b579d03968 Fixed code violating Flake8 rule E275
assert [1] is a Python keyword hence Flake8 raised an error:
"E275 missing whitespace after keyword" [2].

[1] https://docs.python.org/3/reference/lexical_analysis.html#keywords
[2] https://www.flake8rules.com/rules/E275.html

Change-Id: I76bbe10b850c38a3fbb38c4a2f5ee17ca5b91b4e
(cherry picked from commit 1bf22feb2d)
2022-08-01 15:03:32 +00:00
Jakob Meng
8743f24c4b Refactored TripleO jobs
Added a note that we do not have to build the RPM of the Ansible
OpenStack collection from source because TripleO Quickstart installs
the collection from job.required-projects [1]. The latter shadows the
RPM release which is installed later by TripleO because it has a
higher precedence in ansible.cfg [2][3].

Changed the job hierarchy to base jobs tripleo-ci-centos-8-\
standalone-build and tripleo-ci-centos-9-standalone-build. This reduces
the number of variables we have to define. In particular, variables
containers_base_image, build_container_images and featureset will be
inherited from parent jobs. The CentOS9 jobs are no longer based on
the CentOS8 job which prevents issues with job variant collections
due to our branched repository.

Added more Ansible modules to files which trigger TripleO jobs,
because Ansible role os_tempest [4] requires those modules and is
called in TripleO jobs. Modules which have been added include:
* openstack.cloud.compute_flavor
* openstack.cloud.image
* openstack.cloud.network
* openstack.cloud.router
* openstack.cloud.subnet

Dropped tripleo-ci-centos-9-standalone-osa from check jobs because the
master branch of TripleO C9 will have the OpenStack SDK 1.x.x release
series only which requires the master branch of the Ansible OpenStack
collection. The only RDO branches with openstacksdk <0.99.0 which will
be maintained longterm are C8 Train, C8 Wallaby and C9 Wallaby.

Dropped TripleO job based on C8 Train from check and periodic and moved
it to experimental. It is unlikely that C8 Train will receive updates
for Ansible OpenStack collection.

[1] cb1595223b/quickstart.sh (L123)
[2] cb1595223b/ansible.cfg (L19)
[3] cb1595223b/quickstart.sh (L595)
[4] https://opendev.org/openstack/openstack-ansible-os_tempest.git

Change-Id: Ibde318678a3e44fdc297a6f29761eb0c7d77cbc9
(cherry picked from commit fc2dda1d86)
2022-07-19 10:28:23 +02:00
Arx Cruz
7a9837dfb5 Backport improvements to endpoint module
- Adds endpoint tests
- Update docs

Change-Id: Ibd647d0c2cd2f90310f381e56088e7e8e93f76fc
(cherry picked from commit 452404ee87)
2022-07-12 10:33:50 +02:00
Arx Cruz
26b53e78b2 Backport improvements to catalog_service
- Adds tests
- Update docs
- Add option aliases

This patch do the following:

* Update catalog_service to use new openstacksdk
* Add catalog_service role to test catalog_service module

Change-Id: I6778f5e91cb0ead63cede28af0111d7ffbbf3ab1
(cherry picked from commit 7c7e61d36b)
2022-07-07 11:35:40 +00:00
Arx Cruz
b8c2310963 Backport improvements to role_assignment
- Refactor module

Change-Id: I09258e18d50acb57501ea1b47d9422dad857607e
(cherry picked from commit 8d5195fdf2)
2022-07-07 06:43:33 +00:00
anbanerj
915a78d7af Backport improvements to keypair_info
- Updates docs
- Improves test coverage

Change-Id: I09c75717a620272904b023179c726a19c4bca000
(cherry picked from commit 595f7d1093)
2022-07-06 15:19:50 +02:00
Dmitriy Rabotyagov
60c39d495f Make publish_collection more universal
With this change we replace zuul.projects with zuul.project that will
imply any project which will run the job. Also we read galaxy.yml as
vars file to predict packed collection naming for futher upload.

Change-Id: I66e27f3026689ad719384203fe66d65f5bca46ce
Needed-By: https://review.opendev.org/c/openstack/ansible-config_template/+/846391
(cherry picked from commit 8f27184f30)
2022-06-27 07:11:54 +00:00
Jakob Meng
2052a47324 Applied workaround in CI for issue #78017 in ansible-core
Module ansible.builtin.user in ansible-core 2.13.0 and 2.13.1 is
affected by #78017 [1] which results in an exception being raised
in ci/roles/keypair/tasks/main.yml [2]. Until this issue is fixed,
we will exclude the broken versions 2.13.0 and 2.13.1 in
requirements.txt [3].

[1] https://github.com/ansible/ansible/issues/78017
[2] 802e46d554/ci/roles/keypair/tasks/main.yml (L72)
[3] https://opendev.org/openstack/ansible-collections-openstack/src/branch/master/tests/requirements.txt

Change-Id: I61bec4e62ecbcf357f3c1279a7373049077cb8d4
Signed-off-by: Jakob Meng <code@jakobmeng.de>
(cherry picked from commit c6c1c6a070)
2022-06-26 14:31:18 +00:00
Zuul
3ecd3b6e64 Merge "Backport improvements to recordset module" into stable/1.0.0 2022-06-17 01:20:56 +00:00
Rafael Castillo
c4a296c07c Backport improvements to recordset module
- General refactoring of module
- Move recordset specific tests from the dns role to new recordset role
- Adds additional tests to recordset role

Note that this is not a clean cherry pick due to sdk changes

Change-Id: If8fda40780050d271c9d869d8959ef569644fd88
(cherry picked from commit 97b05533f1)
2022-06-16 13:41:44 -07:00
Rafael Castillo
6b58d28a4e Backport enhancements to host_aggregate module
- Update the module to return an aggregate object
- Adds a role to test the module

Note that this is not a clean cherry pick as it excludes changes related
to new sdk compatibility.

Change-Id: I6a98ba8466863b41fc996855fd12cf9f3097abe0
(cherry picked from commit 4ea2c5b50d)
2022-06-02 12:45:01 +02:00
Jakob Meng
620956c61d Changed our DevStack based Zuul CI jobs to voting
Keep jobs with devel branch of Ansible non-voting to prevent
Ansible from blocking our Zuul CI gates.

Change-Id: Iba427d1852e56aaafc394c8265d3d1f28ca9574b
2022-06-01 20:50:10 +02:00
Jakob Meng
970fb2489c Warn users about us breaking backward compatibility
Change-Id: I7a2867329f65af6330abccb1954bf49b92cd8721
(cherry picked from commit dee39a71b6)
2022-05-27 14:54:28 +02:00
Jakob Meng
8cc678acc1 Use bifrost's stable/yoga branch for jobs with OpenStack SDK 0.x.x
Bifrost's master branch installs the latest OpenStack SDK from PyPI
which currently is the first release candidate (0.99.0) of the
upcoming first major release of OpenStack SDK 1.0.0. Jobs on our
stable/1.0.0 branch are compatible with older releases of OpenStack SDK
only. This patch does checkout stable/yoga branch of Bifrost which
installs a sufficiently old release of OpenStack SDK due to
opendev.org/openstack/requirements/upper-constraints.txt.

Change-Id: I49a7b50aee45197d9309d959ff49e763f370619b
2022-05-27 09:38:18 +02:00
Jakob Meng
75558c5c2e Lowered maximum OpenStack SDK version to 0.98.999
Alongside OpenStack SDK 1.0.0 we will release a new collection version
2.0.0 which is compatible to OpenStack SDK 1.x.x series only. Code in
branch stable/1.0.0 will remain compatible to OpenStack SDK 0.x.x
series only. Release candidates for the first major release of
OpenStackSDK 1.x.x will be numbered using 0.99.x versions.

At Ansible OpenStack modules PTG on 2022-04-07 it was decided to raise
an error if one is using a incompatible releases of the OpenStack SDK
with our collection. We decided against showing warnings only because
they can be missed easily and functionality  will be broken but
probably hardly detectable when using the wrong SDK.

This patch caps the maximum required SDK versions to 0.98.999, so
that an error will be raised when users try to use our collection with
an incompatible SDK release, e.g. use code from our stable/1.0.0 branch
with a OpenStack SDK 0.99.x or 1.x.x release.

Change-Id: Ic077f7a906698025edf20acf22c7a5c6caa8734a
2022-05-24 14:47:34 +02:00
Jakob Meng
b4bde6af5c Updated pip constraints for release candidates of OpenStackSDK's first major release
A release candidate for the first major release of OpenStackSDK 1.x.x
has been published with version number 0.99.0. Release candidates will
be numbered using 0.99.x versions.

Ref.: https://meetings.opendev.org/irclogs/%23openstack-release/%23openstack-release.2022-05-19.log.html

Change-Id: I51a5b803f6646d3b1c5e198072cb3da19925fc3f
(cherry picked from commit c7ae7a5f98)
2022-05-24 10:36:23 +02:00
Jakob Meng
b935f21f44 Changed TripleO jobs to use correct release files
Commit bc27851617 [1] in opendev.org/openstack/tripleo-ci changed the
release filename for periodic jobs to promotion-testing-hash-*.yml [2]
instead of using e.g. train.yml for OpenStack Train based releases [3].
Due to this change, container images were not pulled from the local
image registry but from trunk.registry.rdoproject.org instead [2]. This
caused our periodic jobs to fail during container image build because
when using a local registry a different namespace prefix "openstack"
(instead of *-binary such as centos-binary) is used which is not valid
on trunk.registry.rdoproject.org.

As a workaround, we force TripleO jobs to run as check jobs, no matter
what pipeline they run in [4].

Thanks to Sandeep Yadav <sandyada@redhat.com> for discovering the root
cause of this issue and providing a workaround!

Ref.:
[1] bc27851617
[2] https://github.com/openstack/tripleo-quickstart/blob/master/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-train.yml#L7
[3] https://github.com/openstack/tripleo-quickstart/blob/master/config/release/tripleo-ci/CentOS-8/train.yml
[4] https://opendev.org/openstack/tripleo-ci/src/branch/master/roles/ci-common-vars/vars/main.yaml#L24

Change-Id: Ib7d8fc9e6781e43e04f0a9feee261b9f3f29e1fe
(cherry picked from commit 4db7a6238b)
2022-05-11 13:24:29 +00:00
Jakob Meng
3c047406dc Backported changes to identity_group_info from master branch
Added ci integration tests and updated return value documentation.
Reverted function calls which would break backward compatibility
with previous collection releases.

Change-Id: I24e64c9455618952ee612d7413882f0ac022189f
(cherry picked from commit a6805cd019)
2022-05-11 10:43:20 +02:00
Jakob Meng
be8965c7fc Removed Zuul CI job for OpenStack Queens
Change-Id: I2884a74fe5f8ae6b4f141bba935e432a09c94c52
2022-05-11 06:53:04 +00:00
Jan Horstmann
acf64a1f72 Set owner in image module
Previously the owner field was not set by module
`cloud.openstack.image`, although it is specified as a module parameter.
The usual approach in `ansible-collections-openstack` is to accept both
names and IDs when referencing openstack resources.
Therefore this commit follows the approach taken by
`python-openstackclient` in [1] and introduces a `project` and a
`project_domain` parameter to identify projects by name or ID and
assign the ID to the `owner` attribute of the image.
The `owner` parameter is left as an alias to `project` in the module.

Story: 2009983
Task: 45012

[1]
cf2de9af79

Change-Id: I3654587df8e40d554aac5126df307961f335332c
2022-05-10 13:47:33 +02:00
anbanerj
a4894337d4 Backported changes to image_info from master branch
Added ci integration tests, updated return value documentation and
refactored to simplify code. Reverted changes such as function calls
and return values which would break backward compatibility with
previous collection releases.

Change-Id: Ibf934568f069c305747fc24fbb22ce3fc095286c
(cherry picked from commit c1a9794207)
2022-05-10 10:00:48 +02:00
Jakob Meng
0b0a80796f Backported changes to identity_role_info from master branch
Added ci integration tests, updated return value documentation and
refactored to simplify code.

Change-Id: If8a1145a31d685d41367383930e6fd08d64c6ae8
(cherry picked from commit 1d22a94a90)
2022-05-09 17:05:18 +02:00
Jakob Meng
c63ff6fbc8 Backported changes to identity_domain_info from master branch
Added ci integration tests and updated return value documentation.
Reverted function calls which would break backward compatibility
with previous collection releases.

Change-Id: Ic7915fd3334266783ea5e9d442ef304fa734ca00
(cherry picked from commit b31fdf8320)
2022-05-09 13:25:27 +02:00
Jakob Meng
4f8f6ffaf4 Backported changes to identity_user from master branch
Renamed ci integration tests to match module name, updated return
value documentation and refactored to simplify code. The module will
no longer fail if no password is supplied since it is perfectly fine
to create a user with an password. Reverted function calls which
would break backward compatibility with previous collection
releases.

Change-Id: I97ee9b626f269abde3be7b2b9211d2bb5b7b3c26
(cherry picked from commit fd1b9fc0d2)
2022-05-06 14:28:34 +02:00
Jakob Meng
0204bbeede Backported changes to identity_user_info from master branch
Added ci integration tests and updated return value documentation.
Reverted function calls which would break backward compatibility
with previous collection releases.

Change-Id: I99e98a529ce74ff2ca77a67d09f188228e6a0e37
(cherry picked from commit 2df07f3523)
2022-05-05 13:14:09 +02:00
Jakob Meng
5626a8d4c9 Removed job definitions for master branch
Previously, all job definitions where shared across each .zuul.yaml in
both branches. When a job definition was changed in one branch, Zuul CI
could pick the job definition from the other branch, which was not
intended.

The problem arises when mixing explicit job.branches matchers with
implicit branch matching, when defining same jobs on multiple branches.
Zuul CI expects that jobs to be defined in one or the other branch, not
both at the same time. One should only use job.branches matchers from
single-branched projects, e.g. trusted config repos. When defining jobs
in branched repositories one selects which job definition to use by the
branch associated with the triggering event instead.
Each trigger has a branch associated with it, whether it is the branch
targeted by the change being proposed, the branch to which a commit
merged, a branch attached to a timer trigger etc. This branch name is
searched across involved projects in order to determine what job
definition should be used.

The job.branches directive is rarely applied to a job which will be
copied to multiple branches. When you have multiple copies of a job
with the job.branches attribute, Zuul CI could pick any of the job
definitions which might not be the one you expected.
The job.branches attribute is useful in single branch config
repositories where a specific job definition has to be applied to a
specific branch of the repository. Another definition of the job
will exist in another branch of the config repository.

This patch removes job definitions which are specific to other
branches, except for parent jobs which are shared across branches.

Signed-off-by: Jakob Meng <code@jakobmeng.de>
Change-Id: Idb12d9eef9116a19b1323b2ce45ef672ae4a4f5e
2022-05-04 15:21:35 +02:00
Rafael Castillo
a3bb143f34 Sychronize updates to identity_role from master branch
Rename ci role to match the module name. Reverted function calls
which would break backward compatibility with previous collection
releases.

Change-Id: Ie59da441d39fe2d0e49430662d853bc9628181e0
(cherry picked from commit cc1b5ecae8)
2022-05-04 09:21:32 +02:00
Jakob Meng
9c16ee4df3 Fixed return values in compute_service_info module again
OpenStack SDK 0.53 added parameters is_forced_down and updated_at
in openstack/compute/v2/service.py, hence our compute_service_info
module will return different values depending on which release of
the OpenStack SDK is used.

Ref.: 5450c45253

Change-Id: I4b055266555cb91681d0ab6edcaa850e061f3afb
(cherry picked from commit 4a7330364e)
2022-05-03 07:41:08 +00:00
Jakob Meng
a70a4c3424 Fixed return value disable{d,s}_reason in compute_service_info module
OpenStack SDK 0.53 renamed parameter disables_reason to disabled_reason
in openstack/compute/v2/service.py, hence our compute_service_info
module will return different values depending on which release of
the OpenStack SDK is used.

Ref.: 5450c45253

Change-Id: I1c0f787f7f67c92f92dd106fc8d55580461e4aa3
(cherry picked from commit cf5007d478)
2022-05-02 12:30:33 +00:00
Jakob Meng
708ed756ca Temporarily run passing tests in our Zuul CI jobs only
With merging the code for 1.0.0 of OpenStack SDK into the master branch
several of our modules and CI tests broke. To be able to merge patches
we had to set most of our jobs to non-voting, so atm we do not have a
good code coverage in Zuul CI.

This patch temporarily skips broken tests so that we can set our jobs
back to voting and get some basic code coverage from CI. Follow up
patches which fix modules are supposed to readd skipped tests on
occasion.

Change-Id: Ice42d0bdc12c24227a323ad9c5d3fd33870975c4
(cherry picked from commit c10cc9dd8c)
2022-04-28 13:46:06 +00:00
Jakob Meng
c83884e5c8 Changed our Zuul CI *-octavia job to non-voting
Our *-octavia jobs pull OpenStack SDK from PyPI and PyPI is still
serving the 0.x.x series of the SDK because 1.0.0 has not been
released yet. A recent commit bb25330ddc [1][2] broke compatibility
to older SDK releases prior to 1.0.0 and since then our *-octavia
job on our master branch is failing.

Ref.:
[1] https://review.opendev.org/c/openstack/ansible-collections-openstack/+/839033
[2] bb25330ddc

Change-Id: I4bacc358cca08a71694c590202066c8565a96f02
(cherry picked from commit 3ead86904a)
2022-04-28 11:17:05 +00:00
Jakob Meng
655ed21ffa Restricted galaxy-importer script to Python 3.6+
Ansible Galaxy content importer is using format strings [1] which
are supported since Python 3.6. Our Zuul CI job for OpenStack Queens
uses Ubuntu 16.04 LTS (Xenial Xerus) as its base image which has
Python 3.5 only.

Ref.:
[1] b7140d6b3b/galaxy_importer/main.py (L117)

Change-Id: I5d3b2f71937a0e4ab9a8d49df10744f7d95a7de2
(cherry picked from commit 9f60f0f26d)
2022-04-28 08:34:57 +00:00
Jakob Meng
e64211213a Constrain filters in compute_service_info to SDK >= 0.53.0
Older releases of OpenStack SDK do not support filtering services.

Change-Id: I613c76b8f794ea2024939e07250a50edc5b9e49a
(cherry picked from commit e85a0b809a)
2022-04-28 05:49:47 +00:00
Jakob Meng
39676b664a Removed object tags from ci role server
Tag object was introduced to server role in commit c8a5be6b30 [1] to
allow skipping server tests when volumes are not available.

Whenever tag object is specified, Ansible will run those three tasks
in role server. But as our server module has not been ported to
OpenStack SDK 1.0.0 series it will fail even if someone only wants to
test our object ci role.

This patch removes all occurrences of the object tag in the ci server
role. Since it is not used anywhere in our code it will not break ci.

Ref.:
[1] c8a5be6b30

Change-Id: I222fac499c9a3cb16c4581fb4347170a4d97f833
(cherry picked from commit bba1da17c9)
2022-04-27 18:12:01 +00:00
Jakob Meng
220f2b7dca Added support for specifying a maximum version of the OpenStack SDK
Alongside OpenStack SDK 1.0.0 we will release a new collection version
2.0.0 which is compatible to OpenStack SDK 1.x.x series only. Code in
branch stable/1.0.0 will remain compatible to OpenStack SDK 0.x.x
series only.

At Ansible OpenStack modules PTG on 2022-04-07 it was decided to raise
an error if one is using a incompatible releases of the OpenStack SDK
with our collection. We decided against showing warnings only because
they can be missed easily and functionality  will be broken but
probably hardly detectable when using the wrong SDK.

This patch implements the code to raise errors when users are trying
to use our collection with an incompatible SDK release, e.g. use code
from our stable/1.0.0 branch with a OpenStack SDK 1.x.x release.

It does not yet change the minimum and maximum required SDK versions
because OpenStack SDK 1.0.0 has not yet been released to PyPI and
SDK's master branch still does not return a 1.x.x version number.

Change-Id: I1052d21cf8f108dbc99619cd4c4072488645b855
(cherry picked from commit bc6622e0e7)
2022-04-27 09:45:55 +00:00
Jakob Meng
0af7a252bd Use Rocky release of Heat in Queens job
The oldest branch in Heat repository is stable/rocky. Previously,
Zuul CI would use the master branch of Heat since it could not find
stable/queens branch but master branch has incompatibilities with
our Queens job.

Change-Id: Iaeca759cad641d4923fc63489fd65f57d9f1345a
(cherry picked from commit e869564e3c)
2022-04-27 08:12:10 +00:00
Arx Cruz
e8f9457893 Move dns zone info to use proxy layer
Make it compatible with new SDK.
Although this one was already using self.con.dns.zones to retrieve the
zones, it wasn't using the to_dict(computed=False) and was still
removing the location (which is obsolate when you use to_dict.

Change-Id: Ie2a5b772acc0c8c8338f6f1da877564a077e3b7a
(cherry picked from commit 0c6e8bed69)
2022-04-26 15:07:46 +02:00
Jakob Meng
29831685d8 Follow up to bump of minimum required OpenStack SDK release to SDK 0.36.0 (Train)
Commit 879270aa47 [1] bumped the required minimum SDK release
but missed to update two locations in code and docs.

Ref.:
[1] 879270aa47

Change-Id: I725a26b07484619f6f2c460e974821f81d60b153
(cherry picked from commit 5a43bdb873)
2022-04-26 11:53:05 +02:00
Jesper Schmitz Mouridsen
82311440b5 Support description in sg-rule creation
Change-Id: I7800a91682b143b29c30e97661e057c6c41f4663
Signed-off-by: Jesper Schmitz Mouridsen <jesper@schmitz.computer>
(cherry picked from commit ecf4897a55)
2022-04-26 11:50:23 +02:00
Jakob Meng
57012cbaa3 Drop username from return values of identity_user_info
Users would have a non-null username only with Identity API v2 which
was available in Keystone of OpenStack Pike. Identity API v2 has been
removed since OpenStack Queens [1].

Function search_users() from OpenStack SDK still returns the username
attribute because of [2][3] but it will always be None since
Keystone's API does not return username since OpenStack Pike.

[1] https://docs.openstack.org/releasenotes/keystone/queens.html
[2] 975cabbdd8/openstack/cloud/_utils.py (L246)
[3] 76b081efe4

Change-Id: I2054dd55662698dabd0f2b3565c31dcd3bf24e5a
(cherry picked from commit 5fc8fca06b)
2022-04-21 10:36:46 +00:00
Jakob Meng
5b453c62d1 Dropped broken linter job openstack-tox-linters-ansible-2.9
Running older linter releases while we have a more up to date
Ansible 2.12 based linter does not provide value and thus wastes
ci resources. Our Ansible 2.9 based linter is broken atm and since
it is EOL soon anyway we drop this job. We still have a linter job
based on the last stable release and one based on Ansible's
devel branch.

Our tox environment for Ansible 2.9 will be dropped in a later
patch once all Ansible 2.9 based jobs have been removed.

Change-Id: I9cd3f729b06516bbd9a3c7985b65fcf294c8bdd7
(cherry picked from commit f09cccdb9e)
2022-04-21 09:34:20 +00:00
Jakob Meng
8e1f1d6475 Temporarily set job openstack-tox-linters-ansible-2.9 to non-voting
Python module rstcheck which is used by ansible-test deprecated
Python versions prior 3.7 in version 3.5.0 and removed support
in 4.0.0 [1]. Ubuntu 18.04 LTS (Bionic Beaver) comes with Python
3.6 by default, so rstcheck prints a FutureWarning which confuses
ansible-test:

  Run command: ***/python -m rstcheck --report warning
  --ignore-substitutions _,br,release,today,version
  docs/openstack_guidelines.rst
  Traceback (most recent call last):
    File "***/ansible-test", line 28, in <module>
      main()
    File "***/ansible-test", line 24, in main
      cli_main()
    File "***/ansible_test/_internal/cli.py", line 130, in main
      args.func(config)
    File "***/ansible_test/_internal/sanity/__init__.py", line 193,
    in command_sanity
      result = test.test(args, sanity_targets, version)
    File "***/ansible_test/_internal/sanity/rstcheck.py", line 80,
    in test
      results = parse_to_list_of_dict(pattern, stderr)
    File "***/ansible_test/_internal/util.py", line 799, in
    parse_to_list_of_dict
      raise Exception('Pattern "%s" did not match values:\n%s' %
      (pattern, '\n'.join(unmatched)))
  Exception: Pattern "^(?P<path>[^:]*):(?P<line>[0-9]+):
  \((?P<level>INFO|WARNING|ERROR|SEVERE)/[0-4]\) (?P<message>.*)$"
  did not match values:
  ***/rstcheck.py:51: FutureWarning: Python versions prior 3.7 are
  deprecated. Please update your python version.
    FutureWarning
  ERROR: Command "/usr/bin/env ANSIBLE_TEST_CONTENT_ROOT=***/
  ansible_collections/openstack/cloud LC_ALL=en_US.UTF-8 ***/python3.6
  ***/ansible-test sanity -v --python 3.6 --skip-test
  metaclass-boilerplate --skip-test future-import-boilerplate plugins/
  docs/ meta/ scripts/ --metadata ***.json --truncate 0 --redact
  --color no --requirements" returned exit status 1.

We cannot constrain the version of rstcheck which ansible-test installs
into its Python virtual environment. This has to be fixed in Ansible
itself, a pull request against Ansible 2.9 has been opened [2].

Ref.:
[1] https://github.com/myint/rstcheck/blob/master/README.rst
[2] https://github.com/ansible/ansible/pull/77568

As a workaround we temporarily set our Ubuntu 18.04 based linter job
openstack-tox-linters-ansible-2.9 to non-voting and remove it from
check dependencies and as a gate job.

Thanks to Arx Cruz and Jesper Schmitz Mouridsen for pointing out this
issue and its root cause ☺️

Change-Id: Ic6f2febc5a40a29534ac4c7f41f714865099086a
(cherry picked from commit 2bf82c2669)
2022-04-20 07:04:58 +00:00
Arx Cruz
4b9e2295e0 Fix logic in routers_info
The list of fixed ips on the routers info was wrong, adding only the
last one instead of the all of them.

Change-Id: I0bb352ea1845d25cff3aeae507aa55ba473b0a45
2022-04-12 18:47:13 +00:00
Sagi Shnaidman
5bb8312171 Release 1.8.0 version
Change-Id: Id5dbee79e2df9a0bd0185d649cbcbf5c0e288178
2022-04-08 12:30:59 +03:00
Jakob Meng
b3ac841442 Dropped deprecated return values in floating_ip_info and assert remaining fields
Attributes such as location and tenant_id are computed by OpenStack
SDK. We do not return these fields in floating_ip_info because e.g.
tenant_id has been marked as deprecated and is a copy of the
project_id field.

Ref.: 70a06d9990

Added an assertion to CI which checks that all advertised fields
are returned by floating_ip_info. This helps with detecting breaking
changes in future updates.

Change-Id: I62e4681cd57f82054f68efe1dc59be2cca118135
2022-04-06 07:58:46 +00:00
Arx Cruz
37c52c321d Changed compute_flavor_info module to use OpenStack SDK's proxy layer
We still return computed values here to keep backward compatibility.

Change-Id: Idad13228efe55b2dd35224cc37c61657590f9b8e
2022-04-05 13:46:15 +02:00
Arx Cruz
6edc70f965 Updated return value docs of compute_service_info module
We still return computed values here to keep backward compatibility.

Change-Id: I11af9486a6a284d1756380548fca22435c43765a
2022-04-04 11:33:06 +02:00
Jakob Meng
cc8cd08c03 Fixed Ansible branch in base job openstack-tox-linters-ansible
Ansible's git repository has no master branch but a devel and several
stable-* branches instead.

Change-Id: I43844c8a1cefceb7337e5a6ff1e8b8df451efb26
2022-04-04 10:28:25 +02:00
Ümit Seren
b572bf8ae9 Add subnet pool module
Change-Id: Ib8b5481a1e257490f2a9ff62659a70ea2e920304
2022-03-31 20:05:11 +00:00
Gaudenz Steinlin
b3e0d610ea Add 'all_projects' to server_action module
This allows to execute actions on servers outside of the current auth
scoped project if the user has permission to do so.

Change-Id: Ifb3f40973a76ad8c57bcbcbcb8e73c917681096b
2022-03-31 12:18:09 +00:00
Jakob Meng
291e8b8640 Refactored tox requirements for different Ansible releases
Sorted pip requirements file to improve readability.

Moved pip requirements for tests into tests subdirectory and dropped
'pip-' prefix to shorten filenames and conform with common naming
scheme for pip requirements files.

Added constrains on OpenStack SDK 1.*.* to job ansible-collections-\
openstack-functional-devstack-releases on master branch because only
stable/1.0.0 branch is compatible to the OpenStack SDK 0.*.* series.

Changed job ansible-collections-openstack-functional-devstack-releases
on master branch to non-voting because OpenStack SDK 1.*.* has not
been released to PyPI yet, so tests on master branch are expected to
fail once we introduce breaking changes from stable/1.0.0 branch.

Change-Id: I6b6bb8c6900f7c8341bbf3f9a24999fbf693ba4b
2022-03-31 10:19:50 +02:00
Sagi Shnaidman
f70a50e363 Fix ansible-lint issues for newest version
Change-Id: I8238b5d5e49c2a4a8ed3228de23349092c9e1220
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-03-29 18:51:01 +00:00
Jakob Meng
befcc4353d Reenabled check-import.sh which tests imports to Ansible Galaxy
Reverted commit 1f3417cdef [1] which disabled check-import.sh script.
Python module galaxy_importer will return a non-zero return value on
errors since commit 4f5fd0f29c [2].

Use galaxy-importer 0.3.1 for Ansible 2.9 and galaxy-importer 0.3.2
for later Ansible releases because galaxy-importer moved from ansible
2.9 to ansible-core 2.11 in 0.3.2 [3].

Ref.:
[1] 1f3417cdef
[2] 4f5fd0f29c
[3] 9893354783

Change-Id: I898149727d80cd7effe6a04ca77a13ef1774e781
2022-03-29 15:20:17 +02:00
Jakob Meng
8a91352a38 Added job variants for stable/1.0.0 branch to Zuul CI config
Releases of OpenStack SDK on PyPI will soon switch to the 1.*.* series
which our stable/1.0.0 branch is incompatible with. Previously, in
commit 0f532d10f3, several jobs have been changed to run on master
branch only.

This patch adds siblings jobs for our stable/1.0.0 branch which
pull the latest SDK releases of the 0.*.* series from PyPI instead.

Ref.: 0f532d10f3

Change-Id: Iefc6acfa4c25eb5d9ab062a3bfa655be2188cb77
2022-03-29 09:29:51 +02:00
Jakob Meng
1d7fd25ac0 Set Zuul CI job for OpenStack Train to voting
Job *-train-ansible-2.11 failed since commit 031475d42e because that
patch caused most jobs to install the latest Python packages of
OpenStack SDK and other requirements from PyPI to tox' virtualenv
instead of respecting the override-checkout keywords and using
releases of OpenStack Train. Commit 87858ab976 and its follow ups
has fixed this issue.

Ref.:
031475d42e
87858ab976

Change-Id: Ib12e6195db9bb232735ea5a785ccc88bc749ea17
2022-03-28 13:44:36 +02:00
Jakob Meng
44fa06cba1 Fixed job hierarchy for Zuul CI
Added a parent job *-functional-devstack-base which defines basic job
attributes such as job.required-projects. It does not restrict branches
because else Zuul would not find a matching parent job variant during
job freeze when child jobs are on other branches. It does not define
attributes job.override-checkout and job.required-projects.override-\
checkout because else Zuul would use this branch when matching variants
for parent jobs during job freeze.

Jobs *-devstack-{xena,wallaby,train}-ansible-2.{11,12} have been
changed to inherit from *-devstack-base instead of *-devstack-ansible-\
2.{11,12}. The latter do not run for branch stable/1.0.0 which caused
Zuul to dismiss the *-devstack-{xena,wallaby,train}-ansible-2.{11,12}
when collecting parent job variants during job freeze:
The previous parent jobs *-devstack-ansible-2.{11,12} set job.branches
to master so Zuul cannot match that job when it collects job variants
and thus would ignore the child jobs.

Likewise, jobs *-devstack-{xena,wallaby,train}-ansible-2.{11,12} cannot
inherit from any parent job which sets job.required-projects.override-\
checkout on openstack/devstack because Zuul would use that git ref
instead of stable branch defined below to checkout projects of parent
devstack jobs when collecting variants for parent jobs.

Added a warning to the beginning of .zuul.yaml to keep this file in
sync between branches to avoid issues e.g. with job scheduling. Zuul CI
will search in master branch first when collecting job variants during
job freeze which can have unwanted side effects. For example, when
parent job *-base has been changed in stable/1.0.0 branch, Zuul could
still use *-base variants from master branch during job freeze on child
jobs such as *-ussuri-ansible-2.11 etc.

Change-Id: I3ca4ed5795c45a5565a374f04a1ddb29816bf114
2022-03-28 10:50:22 +02:00
Jakob Meng
26bc8a0666 Synchronized galaxy.yml and galaxy.yml.in files
Change-Id: Ic93a0d1f93e2d86358085c7442ad73d52b9a55ba
2022-03-25 16:01:40 +01:00
Jakob Meng
19d0562551 Fixed branch matching for parent jobs when on stable/1.0.0 branch
When a patch is submitted against a branch, Zuul CI will collect job
variants for each ci job and all its parent jobs. If both job.\
override-checkout and job.required-projects.override-checkout
attributes are not defined, then Zuul will for each (parent) job match
the current branch of the patch against all branches of the project in
which the job is defined. If no such branch exist in a project, then no
job variant matches and this job will be ignored [1].
For example, if a patch is submitted for our stable/1.0.0 branch, then
Zuul CI will try to match 'stable/1.0.0' against all branches in the
projects where job ansible-collections-openstack-functional-devstack
and its parent job openstacksdk-functional-devstack are defined. The
first is defined in openstack/ansible-collections-openstack/.zuul.yaml,
so a match for stable/1.0.0 will be found. But openstacksdk-functional-\
devstack is defined in openstack/openstacksdk/.zuul.yaml which has no
branch stable/1.0.0 defined. So Zuul will not schedule job ansible-\
collections-openstack-functional-devstack at all.

The solution is twofold. First, the base jobs such as ansible-\
collections-openstack-functional-devstack have to be changed to always
checkout existing branches in projects which define (parent) jobs.
Using job.override-checkout might have unintended sideeffects because
it will checkout the specified branch for all required projects which
also includes the project which the patch was submitted for. Instead
we set job.required-projects.override-checkout for all projects which
define parent jobs. For example, in ansible-collections-openstack-\
functional-devstack we set job.required-projects.override-checkout to
master for opendev.org/openstack/devstack which defines parent job
openstack-functional-devstack.

In child jobs which (re)define job.override-checkout, we have to change
job.required-projects.override-checkout for all projects which define
parent jobs to the value of job.override-checkout. If we fail to update
job.required-projects.override-checkout then Zuul will checkout the
branch which was defined in the base jobs because job.\
required-projects.override-checkout has higher precedence than job.\
override-checkout.

Setting attribute project.<pipeline>.debug to true helps with debugging
these job scheduling issues. "If this is set to true, Zuul will include
debugging information in reports it makes about items in the pipeline.
This should not normally be set, but in situations were it is difficult
to determine why Zuul did or did not run a certain job, the additional
information this provides may help" [2].

Note, once job scheduling has been completed, Zuul will use a different
algorithm to checkout projects which are listed in job.\
required-projects [3][4]. It will fallback to a default branch if no
matching branch can be found in projects [5].

Ref.:
[1] https://opendev.org/zuul/zuul/src/branch/master/zuul/model.py#L6996
[2] https://zuul-ci.org/docs/zuul/latest/config/project.html#attr-project.%3Cpipeline%3E.debug
[3] https://zuul-ci.org/docs/zuul/latest/job-content.html#git-repositories
[4] https://opendev.org/zuul/zuul/src/branch/master/zuul/executor/server.py#L1648
[5] https://zuul-ci.org/docs/zuul/latest/config/project.html#attr-project.default-branch

Change-Id: I31f9607ab7e2e2ae8534429da7f5e5f235560c56
2022-03-24 14:33:27 +00:00
Jakob Meng
07c3ed0c17 Changed jobs against master branch of OpenStack SDK to non-voting
Our collection has not been ported to the new OpenStack SDK 1.* yet.
Until the migration has been completed successfully, we have to set
all jobs which use the master branch of the SDK to non-voting.

Change-Id: I8fbf568ab87360bf34125dbf1d939c075d3764ae
(cherry picked from commit 5b53433348)
2022-03-24 12:57:29 +00:00
Jakob Meng
8708167b5f Run jobs for older OpenStack releases on stable/1.0.0 branch only
OpenStack SDK 0.* releases, from OpenStack Zed and earlier, are only
supported by our stable/1.0.0 branch. Our master branch does not
support old SDK releases anymore, so we restrict Zuul CI jobs
which run older OpenStack releases to patches against our
stable/1.0.0 branch.

Change-Id: I45bf5f90ba2265ab3b9faab77b75babf693b52bb
2022-03-24 11:10:16 +01:00
Kevin Carter
a9565779b5 Fixed job hierarchy in Zuul CI configuration
Reparented ansible-collections-openstack-functional-devstack-{xena,\
wallaby,train}-ansible-2.{11,12} jobs from ansible-collections-\
openstack-functional-devstack-ansible-devel to corresponding ansible-\
collections-openstack-functional-devstack-ansible-2.{9,11,12} jobs
because the previous inheritance hierarchy had no benefits.

The new hierarchy has been straightened, i.e. redundant voting
overrides have been removed and jobs now properly inherit variables
such as tox_envlist and required projects such as github.com/ansible/\
ansible for the specified ansible releases.

Change-Id: I33addad110f4f15ec56dfea0fd18954c55d24b82
Signed-off-by: Kevin Carter <kecarter@redhat.com>
Signed-off-by: Jakob Meng <code@jakobmeng.de>
2022-03-24 10:43:02 +01:00
Jakob Meng
5c2069c47d Run tripleo*{train,wallaby}-osa jobs on stable/1.0.0 branch only
Our master branch is compatible to OpenStack SDK 1.* releases only,
while our stable/1.0.0 branch works with OpenStack SDK 0.* releases
only. Users of train or wallaby branches of TripleO will use packages
which are provided by RDO and we will pin them to our stable/1.0.0
anyway. Using OpenStack SDK 1.* from PyPI with TripleO train/wallaby
is not supported.

Change-Id: Ia6bcd3809e2a63ec9c11db4eeeca837839c9c0a9
2022-03-22 14:08:19 +01:00
Jakob Meng
583df2a8a9 Dropped inherited variable tox_install_siblings
Change-Id: I9f67c404d1b0ae23daf527b373f196ab17efc9a3
2022-03-22 12:11:33 +01:00
Jakob Meng
0f532d10f3 Run *-releases job on master branch only
Latest releases of OpenStack SDK will soon be 1.* versioned which
our stable/1.0.0 branch is incompatible with. We will have to add
a siblings job for *-releases later which pulls the latest release
of the 0.* series of the OpenStack SDK and runs on commits for our
stable/1.0.0 branch.

Change-Id: I77f6730e8c9e5840be460795a17c9d48aeecccd0
2022-03-22 11:40:56 +01:00
Jakob Meng
87858ab976 Fixed python packages in tox virtualenvs
Reverted commit 031475d42e which changed tox_install_siblings to
false in base job ansible-collections-openstack-functional-devstack.
This caused most jobs to install the latest Python packages of
OpenStack SDK and other requirements from PyPI to tox' virtualenv
instead of respecting the override-checkout keywords.

Ref.: 031475d42e

Change-Id: Ide693ef95c613454e1cfb2ee1880793a49f6524e
2022-03-22 11:25:51 +01:00
Jakob Meng
09c3e4bdc9 Run *-octavia job on master branch only
Latest releases of OpenStack SDK will soon be 1.* versioned which
our stable/1.0.0 branch is incompatible with. We will have to add
a siblings job for octavia later which pulls the latest release
of the 0.* series of the OpenStack SDK and runs on commits for our
stable/1.0.0 branch.

Change-Id: I8cfc7cf609d10ff96a03ae7f1f407ee0ec2da20c
2022-03-22 10:54:33 +01:00
Jakob Meng
ebffbe4fe8 Disable jobs against master branch of OpenStack SDK on stable/1.0.0 branch
Run Zuul jobs which test against the master branch of OpenStack SDK
only for commits on our master branch because branch stable/1.0.0 is
compatible only to OpenStack SDK 0.* releases.

Change-Id: I35849df166f3f36f4e3e2870ccd8d5fe9e33e50f
2022-03-22 09:11:40 +01:00
anbanerj
cbcfce2e23 Remove old, unsupported parameters from documentation in image_info module
This patch removes "deleted" and "deleted_at" from the doc in image_info module.
These params were never returned since image_info started using openstacksdk.

Change-Id: Id5aa9164bacf7808fd21235bd7327569344295ab
2022-03-18 10:57:44 +00:00
Will Szumski
406558dae9 Handle aggregate host list set to None
A freshly created host aggregate can have the host list set to None,
consequently you'd hit:

```
failed: [localhost] (item={'name': 'gpu', 'hosts': [], 'metadata': {'type': 'gpu'}}) => {"ansible_loop_var": "item", "changed": false, "item": {"hosts": [], "metadata": {"type": "gpu"}, "name": "gpu"}, "module_stderr": "Traceback (most recent call last):\n  File \"/var/lib/home/stackhpc/.ansible/tmp/ansible-tmp-1642696576.6728637-1456290-187052400642084/Ansiba
llZ_host_aggregate.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/var/lib/home/stackhpc/.ansible/tmp/ansible-tmp-1642696576.6728637-1456290-187052400642084/AnsiballZ_host_aggregate.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/var/lib/home/stackhpc/.ansible/tmp/ansible-tmp-1642696576.672
8637-1456290-187052400642084/AnsiballZ_host_aggregate.py\", line 41, in invoke_module\n    run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, p
kg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_os_nova_host_aggregate_payload_qwjtdtjj/ansible_os_nova_host_aggregate_payload.zip/ansible_collections/openstack/cloud/plugins/modules/host_aggregate.py\", line 214, in <module>\n  File \"/tmp/ansible_os_nova_host_aggregate
_payload_qwjtdtjj/ansible_os_nova_host_aggregate_payload.zip/ansible_collections/openstack/cloud/plugins/modules/host_aggregate.py\", line 210, in main\n  File \"/tmp/ansible_os_nova_host_aggregate_payload_qwjtdtjj/ansible_os_nova_host_aggregate_payload.zip/ansible_collections/openstack/cloud/plugins/module_utils/openstack.py\", line 407, in __call__\n  File \
"/tmp/ansible_os_nova_host_aggregate_payload_qwjtdtjj/ansible_os_nova_host_aggregate_payload.zip/ansible_collections/openstack/cloud/plugins/modules/host_aggregate.py\", line 176, in run\n  File \"/tmp/ansible_os_nova_host_aggregate_payload_qwjtdtjj/ansible_os_nova_host_aggregate_payload.zip/ansible_collections/openstack/cloud/plugins/modules/host_aggregate.py
\", line 138, in _update_hosts\nTypeError: 'NoneType' object is not iterable\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
```

I've not investigated which API and library combinations elict this
behaviour, but it does seem to occur. We can safely handle this
possibility in backwards compatible way.

It is possible to workaround this issue by invoking the module a second
time.

Change-Id: Ie14391f18c0f65833d00a4b4f6b1b314a0903d2b
2022-03-18 07:59:56 +00:00
Zuul
c8d89f81a5 Merge "Fix assertion after stack deletion" into stable/1.0.0 2022-03-14 13:40:30 +00:00
Jakob Meng
c0e1f56894 Fix assertion after stack deletion
After a stack has been removed with module stack, a call to module
stack_info might still return this stack with its status set to
'DELETE_COMPLETE' and its status_reason defined as 'Stack DELETE
completed successfully'.

Change-Id: Ice843c403669b4a4e1b12ec73db1fb00d1405980
2022-03-14 10:03:17 +00:00
Jan Weiher
a031968f80 Router: Remove unneeded 'filter' parameter
Change-Id: If46916e3480fced3be919c6d39b82a6c64321065
2022-03-14 08:31:31 +00:00
Jakob Meng
2e78559cc1 Bumped minimum required OpenStack SDK release to SDK 0.36.0 (Train)
For example, to_dict's computed parameter is available since
SDK 0.18 (Stein) only.

Overview on OpenStack SDK versions in various distributions:
* ArchLinux has SDK 0.59.0
* CentOS 7 has SDK 0.36 (Train)
* CentOS 8 has SDK 0.36 (Train), SDK 0.46 (Ussuri),
  SDK 0.50 (Victoria) and SDK 0.55 (Wallaby)
* Debian 10 (Buster) has SDK 0.17.2 and Ansible 2.7.7 which
  does not support Ansible collections anyway. Debian's
  buster-backports repository has Ansible 2.9.16 but backports
  are provided on an as-is basis, with risk of incompatibilities.
* Debian 11 (Bullseye) has SDK 0.50.0
* Ubuntu 18.04 LTS has SDK 0.11.3 which is not supported by
  this collection since the lowest supported version so far
  is 0.13
* Ubuntu 20.04 LTS has SDK 0.46.0
* Red Hat OpenStack (RHOSP) 16.0-16.2 have SDK 0.36 (Train)

Change-Id: I45d3c05c2ec983993aacc7414213b394b59f5552
2022-03-10 13:17:08 +00:00
Jakob Meng
bf939a4ce0 Release 1.7.2 version
Primary reason for this new release is to fix the mess we did yesterday
when we accidentially merged release 1.7.1 and all changes from the
stable branch into the master branch. This release 1.7.2 does not really
change anything except fixing the guidelines.

Change-Id: I1ad23bd36746a180f8851df294df4e01213bdf2f
2022-03-10 11:43:44 +01:00
Jakob Meng
24d6f36602 Release 1.7.1 version
Change-Id: I958ba6890a54c59e0ccdb9249d959c745acfb8e9
(cherry picked from commit b640e6207c)
2022-03-10 08:47:36 +00:00
Sagi Shnaidman
dd9cdde3d8 Fix docs for openstack fragment
Change-Id: I7fef01dbd11137e26d3ff0bd0088dc405559b272
2022-03-09 20:33:32 +00:00
Zuul
da4a68c188 Merge "Remove new SDK job from stable/1.0.0 CI" into stable/1.0.0 2022-03-09 17:45:08 +00:00
Zuul
a7a190f3c0 Merge "Fix inventory plugin doc for new ansible" into stable/1.0.0 2022-03-09 17:45:07 +00:00
Sagi Shnaidman
ce73c9db34 Remove new SDK job from stable/1.0.0 CI
Change-Id: I04b45ec3dea19f3223929237cdbae702886a9982
2022-03-09 18:54:28 +02:00
Jan Weiher
0e102b1411 [LB] Add support for setting monitor_address
Change-Id: I4897c6343813519859bd19fa162829fe2a6dc573
(cherry picked from commit 37a51ec6ad)
2022-03-09 14:06:29 +00:00
Sagi Shnaidman
9f58d54721 Fix inventory plugin doc for new ansible
Change-Id: I8bd8767d2ac0117e03c9b23882494d45847b15cf
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
(cherry picked from commit 3c7a8f39a2)
2022-03-09 14:06:03 +00:00
Sagi Shnaidman
79d7827d17 Run jobs on stable branch
Disable temporarly train job since it fails.
Change-Id: I012b03fd8c9158a2280691f00304e5f013f045f6
2022-02-23 23:07:02 +02:00
Piotr Parczewski
ba9aa9967f Fix os_quota docs
Change-Id: Ic2717669d0e9e8bb48bb7ed81fd5f5f55928fa55
2022-02-16 14:48:52 +02:00
Sagi Shnaidman
617e8fb552 Release 1.7.0 version
Change-Id: Ic09e1bb4b072c79de8af6036afae5f99f63042c0
2022-02-15 12:56:31 +02:00
Sagi Shnaidman
5abf89d805 Add CentOS 9 wallaby and master
Change-Id: I7cf0014ea51cb42daa039d435fe65a58de35f4ff
2022-02-15 11:50:59 +02:00
Sagi Shnaidman
0599d05103 Add CentOS 9 tripleo job
Change-Id: Id7e6836e228ae9874e71b61c1cacaf4e10d3bda7
2022-02-14 18:42:00 +02:00
Zuul
9c28af7d12 Merge "Adds use_name variable" 2022-02-13 12:09:57 +00:00
Alex Hussey
bcb5d18492 Adds use_name variable
This commit adds the ability to specify whether the ansible_host and
ansible_ssh_host variables should use 'name' inplace of 'interface_ip'.

The primary use case for this, is if you want to access hosts using
the instance name defined in OpenStack instead of the floating IP.
This is usually when using a jump/bastion host.

Implements: use_names
Change-Id: I809cca0f27f16b37cb9c1c18121f468ccf5c805c
2022-02-10 21:44:38 +11:00
Sagi Shnaidman
7aa626377b Remove project properties tests and support
Keystone project doesn't have project "properties" documented and
discourage users to use them. Remove support for this feature and
tests for it. It was removed from new SDK as well.

Change-Id: I2e47ade56c3df5945e991d11d70f429760c0d852
2022-02-10 12:05:17 +02:00
Harald Jensås
0a7889b9a2 Add openstack.cloud.baremetal_port module
Create, Update, Remove ironic ports from OpenStack.

NOTE: Does not support 'is_smart_nic', afict this is
      not implemented in openstacksdk.

Change-Id: I6d9519988e98b10d0f7bd19b1387fb1f3b657046
2022-02-09 23:41:19 +01:00
Harald Jensås
a1b920742f Add openstack.cloud.baremetal_port_info module
Retrieve information about Bare Metal ports from OpenStack

NOTE: Does not support 'is_smart_nic', afict this is
      not implemented in openstacksdk.

Change-Id: I1d57ab976ac3b4c5552b9b21db7e90e25fd71764
2022-02-09 14:23:01 +01:00
Zuul
bd55e1f905 Merge "Add openstack.cloud.baremetal_node_info" 2022-02-09 09:48:57 +00:00
Harald Jensås
20329c0329 Add openstack.cloud.baremetal_node_info
Add module baremetal_node_info / os_ironic_info.
Retrieve information about Bare Metal nodes from OpenStack

Change-Id: I597a66b817bb6b53ecad7503e44f6818aec031a2
2022-02-03 20:23:13 +01:00
Sagi Shnaidman
bdf472a53f Move identity domain to use proxy layer
Make it compatible with new SDK and fix bug with "enabled"

Change-Id: I1f577fae27c24c257571d1cf90e49527470edace
2022-02-02 19:35:37 +02:00
Sagi Shnaidman
b7fb23b097 Add zuul artifact
Change-Id: I01a4b1bf8347461f47316f8b9e3571262cb080cc
2022-01-30 20:42:17 +02:00
Sagi Shnaidman
6ed02eff2d Write tests log to a separate file
Change-Id: I18649c24cb048c4ef5dbab85272975dad7584cd1
2022-01-27 15:53:38 +02:00
Zuul
cb396cf03d Merge "Add dns_[name,domain] to the port module" 2022-01-26 12:56:10 +00:00
hamza alqtaishat
20c2633ea3 Add dns_[name,domain] to the port module
The dns-integration extension adds the dns_name and dns_domain attributes
with this change updated/set operations can be done on those attributes

Change-Id: I4bb0f8692dec3fba5ab50f07571029f374761a5b
2022-01-25 22:51:38 +00:00
Sagi Shnaidman
6569e07023 Add new SDK job non-voting
Change-Id: I9cb89573cb0b6c206016c44b1261971586a57105
2022-01-25 21:00:51 +02:00
Sagi Shnaidman
031475d42e Fix CI for new openstack SDK
Change-Id: I14ced5861cac0656f8b2096a166a45f770d2bf35
2022-01-25 12:39:31 +02:00
Ivan ROGER
5e2ab3d8c3 Fix identity user lookup with a domain
Task: 44308
Story: 2009790
Change-Id: I3bc99ebdf8bc915d7b1ae5e98230058a3f43223f
2022-01-18 15:39:32 +01:00
Sagi Shnaidman
f3b12fed68 Release 1.6.0 version
Change-Id: Ia93e0c9ad892cafabfa43de1578800c099cb5804
2022-01-13 14:46:19 +02:00
Zuul
39a627d4a0 Merge "Add Neutron RBAC modules" 2022-01-12 11:13:53 +00:00
hamza alqtaishat
4eb7c43539 Add compute services list module
The module retrieve the nova compute services info
filters by
 * host
 * binary ( nova-compute, nova-conductor, ... )

Closes-Bug: 2009775
Change-Id: I0f9cac27a7a91727ba1d005e04431e8f83c46fa8
2022-01-11 17:14:54 +00:00
Ashraf Hasson
8c6d1041fa Add Neutron RBAC modules
Change-Id: Ibaff06561055c5cd024abb789dae075dd7871f08
2022-01-11 11:59:58 -05:00
Zuul
26530ac97b Merge "Leave queens job only in experimental" 2021-12-18 23:25:14 +00:00
Zuul
b3e07a1864 Merge "quota: Adds metadata_items parameter" 2021-12-18 23:18:44 +00:00
Sagi Shnaidman
94933250e8 Leave queens job only in experimental
Change-Id: Ibc77dfe72e972948c0b4b018c8f4b18dc7dec790
2021-12-18 22:23:24 +02:00
Pierre Riteau
1582956dcd Remove failing job from gate
Change-Id: I7920e99efd152c2f5a9839bdcbe96a14d6587688
2021-12-17 23:40:05 +01:00
Sagi Shnaidman
b1952e0c4b Replace victoria job by xena one
Move victoria job to experimental, add xena job to check/gate.
Change-Id: Ia0376bf253b9f0ce2f13222982e7e9b8582a93d6
2021-12-16 22:08:44 +02:00
Sagi Shnaidman
9cd6d2f69a Move queens job to experimental
Change-Id: I2df552e6fa98e642b9ccce891d730bb96dedb9a8
2021-12-16 21:56:30 +02:00
Will Szumski
86a57498e8 quota: Adds metadata_items parameter
This is used to set the maximum number of metadata items per instance.

Change-Id: Ib5b86126ec25e9e84436d7ee7f79e43e22637272
2021-12-16 18:59:40 +00:00
Zuul
15f73aa72e Merge "Release 1.5.3 version with bugfixes" 2021-11-11 12:44:09 +00:00
Zuul
22a7f516f3 Merge "server_volume: check specified server is found" 2021-11-11 12:44:07 +00:00
Sagi Shnaidman
de54be5ecd Release 1.5.3 version with bugfixes
Change-Id: I90f72c7ea5869331633ad655275722fdb69570aa
2021-11-11 13:58:54 +02:00
Baptiste Mille-Mathias
3f1a693bd6 server_volume: check specified server is found
... in order to fail nicely instead of throwing an exception.

Change-Id: I6d7f793b4058fdcaffd015724ae9b53aa21e5367
2021-11-11 11:11:45 +01:00
Sagi Shnaidman
8e87ad651f Don't require allowed_address_pairs for port
Port can miss allowed_address_pairs parameter.

Story: 2009192
Task: 43246
Resolves: rhbz#2021810

Change-Id: I8fcc19889eaaec6342c8d7910a55f06e98dbd368
2021-11-10 18:11:43 +02:00
Sagi Shnaidman
b2f3cf3210 Release 1.5.2 version
Change-Id: Id8eb73da64631e1f25b5febd8a9f6dbee9707476
2021-11-09 13:39:40 +02:00
Sagi Shnaidman
11c7cd23f8 Fix issue with same host and group names
When host and group name is the same, the inventory fails to run.
Use different method of adding host to inventory with this case.

Fixes rhbz#2017495
Change-Id: Iad288c3c11d0791be33b379554577eab8381b44d
2021-11-02 11:39:24 +02:00
Zuul
59d0e4c3a4 Merge "Flavor properties are not deleted on changes and id will stay" 2021-11-01 09:57:08 +00:00
Jiri Stransky
014665ddac Add documentation links to README.md
Change-Id: I04235d8485cf46038c979de799a9666429163fab
2021-10-25 13:32:04 +02:00
Sven Anders
21b70f6b9b Flavor properties are not deleted on changes and id will stay
Fixing a bug on compute_falvor that causes that extra_specs
are deleted and the id is changing when a property of the
falvor is changed.


Changing the id will cause that a server which is using the falvor is
afterwards not assigned to the falvor anymore.


Story: 2009260
Change-Id: If7cbce107ce99de79749359e257933e4247e3634
2021-10-07 05:14:58 +00:00
Zuul
ecaff2a798 Merge "Add client and member listener timeouts for persistence (Ex. SSH)" 2021-10-05 15:44:50 +00:00
Sagi Shnaidman
02e9e87964 Clean up the old jobs for rocky,stein,queens
And return voting to train job
Change-Id: I9e39b8a5862f2a93a12498e7dd5ea8e9b978fbb1
2021-10-05 13:47:25 +03:00
Sagi Shnaidman
980536c32e Move CI to use Ansible 2.12 version as main
Move only from victoria, since Ansible 2.12 is installed with
py > 3.8.
Remove ussuri from voting jobs, use it for experimental only.
Change-Id: I74b7272794ea5fbafb7d81a5cf0068c09130bb0d
2021-10-04 15:05:51 +03:00
Alexandru Verdes
a9a0d23441 Add client and member listener timeouts for persistence (Ex. SSH)
Add possibility to specify connection timeouts for SSH listeners.
These values are available in openstacksdk:
95ee95f52c/openstack/load_balancer/v2/listener.py (L89)

Change-Id: Ief1abd9018bb6dab73702cc416e5a916f8baa0d7
2021-10-01 09:17:55 +00:00
Zuul
011515de2d Merge "Added missing warn() used in cloud.openstack.quota" 2021-09-21 16:40:31 +00:00
Daniel Speichert
4292a00f75 Added missing warn() used in cloud.openstack.quota
Change-Id: Ic7ba09cb464049a9ce0db4bafdba30a67b4c8b86
2021-09-15 14:38:30 -04:00
Zuul
bbefa8c156 Merge "Don't run functional jobs on galaxy.yml change" 2021-09-02 14:41:19 +00:00
Sagi Shnaidman
b023aa337a Don't run functional jobs on galaxy.yml change
Change-Id: Ib736f927f448bd2d53cb7f3e3723a9bfc8ea3bf2
2021-09-02 13:45:44 +03:00
Sagi Shnaidman
c13f02fd54 Release 1.5.1 version
Change-Id: Ib87202496ed05a6d2717d13a787f389a9c8d1336
2021-09-02 12:44:20 +03:00
Sagi Shnaidman
ae4e7f3c06 Remove tests directory from ansible-tests
Because we don't include tests in collection tar.
Change-Id: I3697f7b0ccd115ff1859658417d51e1643e10be8
2021-08-16 16:06:10 +03:00
Sagi Shnaidman
2d554d1e22 Add support check mode for all info modules
As it's required by new ansible-test rules.
See https://github.com/ansible-collections/overview/issues/45#issuecomment-893543025
Change-Id: Ib6b73e810b972997b8de2b4a9eb8e07e246823d5
2021-08-16 15:56:27 +03:00
Sagi Shnaidman
770b283593 Reenable octavia job to vote
Add swap memory because octavia LB is killed by OOM killer.
Change-Id: I5cfb5b19cd2a11198a98993b86b8474310ee2cdc
2021-08-11 13:55:17 +03:00
Zuul
42921c6d9f Merge "Changed minversion in tox to 3.18.0" 2021-08-09 15:52:36 +00:00
likui
292aabb477 Changed minversion in tox to 3.18.0
The patch bumps min version of tox to 3.18.0 in order to
replace tox's whitelist_externals by allowlist_externals option:
https://github.com/tox-dev/tox/blob/master/docs/changelog.rst#v3180-2020-07-23

Change-Id: Ia8700e03773398bc9347259bc504ae56c0978882
2021-08-09 20:08:27 +08:00
Jakob Meng
3a08a9c07c Allow to attach multiple floating ips to a server
OpenStack allows to attach multiple floating ips to a single server.
Previously, only one floating ip was supported by this module. It
would call openstacksdk's get_server_public_ip(), which in turn
would return just one of the attached floating ips. If this floating
ip would not point to the right nat_destination or fixed_address,
then the module would fail.

If no floating ip had been attached to a server, then this module
would call openstacksdk's add_ips_to_server() with both parameters
"floating_ip_address" and "network" to attach a floating ip to the
server. But both parameters are mutually exclusive [1], i.e.
add_ips_to_server() will ignore "floating_ip_address" if "network"
is set and then choose any non-attached floating ip from "network".
If "floating_ip_address" has not been created in OpenStack and
"network" is not given, then this module would not create this
floating ip [2].

The new module code allows to create and add more than one floating
ip to a server. It priorizes more specific parameters over generic
ones, i.e. if both "floating_ip_address" and "network" are given,
then "floating_ip_address" precedes "network".

Parameter "network" is now required if "floating_ip_address" is
specified, because both are necessary when creating floating ips.

Module documentation and args have been updated accordingly.

Ref.:
[1] a6b0ece282/openstack/cloud/_floating_ip.py (L987)
[2] a6b0ece282/openstack/cloud/_floating_ip.py (L907)

Task: 40939
Story: 2008181
Change-Id: I1ada1be0994f526f72f81f7458782afbcca3c92c
2021-08-06 15:02:20 +02:00
Jakob Meng
0e370b2c51 Only add or remove router interfaces when needed
Previously, when updating a router all its interfaces where removed and
readded by Ansible's os_router module. As a unwanted side effect all
active connections of the router and nat'ed devices where dropped,
closing e.g. all active tcp sessions. Now, only necessary changes
are applied.

Task: 40136
Story: 2007845
Change-Id: I172caf360e6e342dd54865da5a5b72b0dc0205c8
2021-08-03 13:22:13 +00:00
Sagi Shnaidman
0441403c42 Run ansible devel sanity tests on py38
And fix some module typos.
Disable voting for octavia jobs till investigation.
Change-Id: Ie4cb69aa2337b0f951ac194cf456e4515dbc24fb
2021-08-03 01:32:31 +03:00
Sagi Shnaidman
4160888887 Reenable ansible 2.11 linters job
After PR fix[1] was merged, reenable 2.11 job.

[1] https://github.com/ansible/ansible/pull/75358
Change-Id: Ida493c4316b682c3c2664bbe48c8dffc72f6ac8c
2021-07-30 09:07:17 +03:00
Sagi Shnaidman
07374a1f0d Add mandatory requires_ansible version to metadata
Disable ansible-test since it's broken in 2.11[1]

[1] https://github.com/ansible/ansible/issues/75353
Change-Id: Idd2f99ddfe507b5b02de206c1f8c75692d6a84a2
2021-07-29 17:05:11 +03:00
Sagi Shnaidman
8a395a04cf Remove semver check from release job
Jinja in Zuul Ansible version doesn't support semver key for versions.
Change-Id: I8bf9aa17e18f9b6d2c8e307f4368d1cea3362cb5
2021-07-29 10:20:32 +03:00
Zuul
441a61fd8c Merge "Change the pipeline of releasing to tag pipeline" 2021-07-28 23:14:40 +00:00
Sagi Shnaidman
c05b1fdbaf Change the pipeline of releasing to tag pipeline
Because zuul pre-release pipeline is pep400 compliant, but no
semver compliant, we can't push pre-release tags. Galaxy expects
from tags to be pure semver (not pep440).
Change the pipeline to be 'tag' and be triggered by any tag.

Change-Id: Ia288452668179723e35452d6e9579fb1dd0c4c3a
2021-07-28 23:43:51 +03:00
Zuul
9cd92208d6 Merge "Wait for pool to be active and online" 2021-07-28 16:55:56 +00:00
Sagi Shnaidman
5ef192f1f2 Add automatic release job triggered by tag
Currently put it in pre-release pipeline to test that it's ok.

Change-Id: I791478464ed59933273bb0e5f88f3636074c6729
2021-07-28 15:11:07 +03:00
Jesper Schmitz Mouridsen
aed60716ee Wait for pool to be active and online
In order to use a newly generated pool for a new
healthmonitor the pool must be online and active,
to avoid 409 conflict, when trying to update a pool
with e.g pending update as a status.

Change-Id: I160a75c6fbbf1555f3adcb444c77057f59b4cdfb
2021-07-19 13:05:33 +02:00
cuongmax
938b90ea19 Add protocol listener octavia
Signed-off-by: cuongmax <ptitcuongmax@gmail.com>
Change-Id: I98c316865837e7c68fa3eed2f5304950ebfc2141
2021-07-17 09:17:55 +07:00
Zuul
ce853a8f9f Merge "Add missing info to changelog" 2021-06-24 20:42:05 +00:00
Sagi Shnaidman
9911c7f93a Add missing info to changelog
Change-Id: Ic6113a785090cc05771fb2f4730dc25f40a8d4dc
2021-06-24 23:13:24 +03:00
Sagi Shnaidman
8c890e656b Update IRC server in README
Change-Id: Ida13b691ae09c2222ae1c83a88b47702fdf684f4
2021-06-24 16:59:56 +03:00
Sagi Shnaidman
b839f9e25d Bump to devel 1.5.1-dev version
Change-Id: I99857903ed22f46e4bbf317dab49f5e581141ea2
2021-06-23 18:41:14 +03:00
Sagi Shnaidman
b7765776a7 Release 1.5.0 version
Change-Id: I433087510adf633e9656f844680ef22c1aff1a72
2021-06-23 17:41:08 +03:00
Zuul
4490e008c4 Merge "Only apply necessary changes to subnets" 2021-06-23 14:35:49 +00:00
Zuul
f376d4679e Merge "fix update on empty list of allowed address pairs" 2021-06-23 13:10:44 +00:00
Zuul
12ec8c63c2 Merge "Add address scope module" 2021-06-23 11:38:23 +00:00
Jan Hartkopf
72f371c157 fix update on empty list of allowed address pairs
Story: 2008986
Task: 42636
Change-Id: I1a500673d870b706d9187ce9780fc72d3603bad9
2021-06-23 10:43:16 +00:00
Jakob Meng
ce421fe370 Only apply necessary changes to subnets
Previously, all subnet properties were updated if any value did not match.
But this behaviour caused errors like e.g. "Current gateway ip 192.168.0.1
already in use by port [ID]. Unable to update." even if that gateway was
not about to be changed.

Task: 40927
Story: 2008172
Change-Id: I049b0dade4c7ea3e1ef24777ae558f650caa136c
2021-06-23 10:40:57 +00:00
Ümit Seren
f20ec3a151 Add address scope module
Change-Id: If02e03f124a8677cba42aa7019947e8f00ea476f
2021-06-22 23:23:50 +02:00
Zuul
a89ec027b0 Merge "Switch Snapshot module to OpenStackModule" 2021-06-22 20:53:47 +00:00
Zuul
322f96c4db Merge "Switch Quota module to OpenStackModule" 2021-06-22 20:48:11 +00:00
Zuul
50b55560fc Merge "Switch user_info module to OpenStackModule" 2021-06-21 17:16:09 +00:00
Zuul
0c0013504e Merge "Switch ProjectAccess module to OpenStackModule" 2021-06-21 17:04:10 +00:00
Zuul
e651838f3e Merge "Switch role_assignment module to OpenStackModule" 2021-06-21 17:04:07 +00:00
Zuul
4553282545 Merge "Switch identity_role module to OpenStackModule" 2021-06-21 16:19:07 +00:00
Zuul
235628dace Merge "Switch hostaggregate module to OpenStackModule" 2021-06-21 15:20:38 +00:00
Zuul
4ee8621b37 Merge "Dns zone info module" 2021-06-17 17:09:58 +00:00
Zuul
d07039a7ec Merge "Switch lb_listener module to OpenStackModule" 2021-06-17 16:13:49 +00:00
Zuul
54728a83fa Merge "Switch lb_member module to OpenStackModule" 2021-06-17 16:13:46 +00:00
Zuul
8431232eeb Merge "Switch lb_pool module to OpenStackModule" 2021-06-17 15:58:57 +00:00
Zuul
b21b8b1084 Merge "Switch catalog_service module to OpenStackModule" 2021-06-17 15:06:35 +00:00
Zuul
e2ffed388e Merge "Switch group_assignment module to OpenStackModule" 2021-06-17 14:06:08 +00:00
Zuul
ff44a1d1e5 Merge "Switch KeystoneFederationProtocolInfo module to OpenStackModule" 2021-06-17 12:05:32 +00:00
Zuul
9f893824c5 Merge "Switch federation_mapping module to OpenStackModule" 2021-06-17 11:59:37 +00:00
Zuul
b9df964149 Merge "Switch federation_mapping_info module to OpenStackModule" 2021-06-17 11:20:33 +00:00
Zuul
0c8fe9002e Merge "Switch floating_ip module to OpenStackModule" 2021-06-17 11:20:20 +00:00
Zuul
e010db6273 Merge "Switch federation_idp_info module to OpenStackModule" 2021-06-17 11:20:09 +00:00
Zuul
88277a59af Merge "Switch port_info module to OpenStackModule" 2021-06-17 11:20:05 +00:00
Zuul
1a4d0128c7 Merge "Add check_mode attribute to OpenstackModule" 2021-06-17 11:20:02 +00:00
Polina Gubina
03a86669de Dns zone info module
Change-Id: I99f084bcb2fa3d4a203f439a55eef162ab82d43d
2021-06-17 10:52:05 +00:00
Artem Goncharov
fa7526a0ec Switch hostaggregate module to OpenStackModule
Change-Id: I86ebbcc52b6558f4110fc439ed13fb590dddb590
2021-06-17 13:41:22 +03:00
Artem Goncharov
7446ab23b8 Switch ProjectAccess module to OpenStackModule
Switch project_access module to the general OpenStackModule.

Change-Id: I359fcf8d815413b52b993b343c458c8c986bc247
2021-06-17 13:28:10 +03:00
Zuul
4171ee52b7 Merge "Switch endpoint module to OpenStackModule" 2021-06-16 20:46:52 +00:00
Zuul
60f1b8e2a5 Merge "Switch ServerGroup module to OpenStackModule" 2021-06-16 19:12:51 +00:00
Zuul
0bff3f286f Merge "Switch Stack module to OpenStackModule" 2021-06-16 19:12:48 +00:00
Zuul
5188e281b9 Merge "Switch flavor_info module to OpenStackModule" 2021-06-16 11:46:04 +00:00
Zuul
966b6597f3 Merge "Switch Recordset module to OpenStackModule" 2021-06-16 11:45:59 +00:00
Zuul
5636d502ce Merge "Switch identity_domain_info module to OpenStackModule" 2021-06-16 08:56:22 +00:00
Zuul
4db925b452 Merge "Switch auth module to OpenStackModule" 2021-06-16 08:20:43 +00:00
Zuul
3ce4455bc8 Merge "Switch coe_cluster_template module to OpenStackModule" 2021-06-16 08:20:22 +00:00
Zuul
309c3025ba Merge "Switch identity_user module to OpenStackModule" 2021-06-16 08:20:19 +00:00
Zuul
637d321a9a Merge "Switch flavor module to OpenStackModule" 2021-06-16 06:30:51 +00:00
Zuul
74c18f34f3 Merge "Switch identity_group_info module to OpenStackModule" 2021-06-15 18:25:46 +00:00
Zuul
00be40a462 Merge "Switch port module to OpenStackModule" 2021-06-15 18:25:43 +00:00
Zuul
1eb5d85b68 Merge "Switch coe_cluster module to OpenStackModule" 2021-06-15 17:25:29 +00:00
Zuul
d0a4d6e8cc Merge "Switch object module to OpenStackModule" 2021-06-15 14:22:05 +00:00
Zuul
29c03592cc Merge "Switch identity_group module to OpenStackModule" 2021-06-15 14:22:02 +00:00
Zuul
7888b51053 Merge "Switch federation_idp module to OpenStackModule" 2021-06-15 13:37:38 +00:00
Zuul
0e4dc21bab Merge "Switch identity_domain module to OpenStackModule" 2021-06-15 12:18:35 +00:00
Zuul
623b4afbd1 Merge "Floating ip info module" 2021-06-15 10:13:12 +00:00
Zuul
80e6597f96 Merge "Switch federation_protocol module to OpenStackModule" 2021-06-15 09:30:54 +00:00
Zuul
8f1512166e Merge "Switch ServerMetadata module to OpenStackModule" 2021-06-15 09:05:08 +00:00
Sagi Shnaidman
eabe945194 Add check_mode attribute to OpenstackModule
Change-Id: I4a779113f7bf293b5f059d662a1a562d4192e537
2021-06-14 14:04:47 +03:00
Artem Goncharov
06115c77b7 Switch Quota module to OpenStackModule
Switch quota module to the general OpenStackModule.

Change-Id: I28a61bf70b161358b76e3adb70b32896613e9aba
2021-06-14 13:48:29 +03:00
Zuul
4a1b092efb Merge "Fail if referenced source image for a new volume does not exist" 2021-06-07 15:46:16 +00:00
Zuul
da1fab6629 Merge "Fix host_aggregate to tolerate aggregate.hosts being None" 2021-06-07 15:45:40 +00:00
Zuul
0efb855c68 Merge "Update checks for validate_certs in openstack_cloud_from_module" 2021-06-07 15:45:33 +00:00
Georgina Shippey
329a5ef50d Update checks for validate_certs in openstack_cloud_from_module
Change I51105f11565c5ff33b04add36259c8703af11240 moved validate_certs default from None to False.
This causes checks to fail in openstack_cloud_from_module as validate_certs is never None anymore.

This patch changes reverts the default back to None, and reflects this in the documentation.

Task: 41776
Story: 2008600
Change-Id: Ic79510f863cf3a39c3f5c6d99f61d335f92f9388
2021-06-01 17:22:37 +01:00
Christian Rohmann
47708e0172 Fix host_aggregate to tolerate aggregate.hosts being None
Story: 2008925
Task: 42524

Change-Id: I0b2f8d0578b764ba3484d45c212f81ad728072e5
2021-06-01 12:45:44 +02:00
Polina Gubina
17d5c7de8e Floating ip info module
Change-Id: If932651c9d7a1819f805a49b020826682c5b8087
2021-05-27 12:03:04 +03:00
Christian Rohmann
82792ab5d5 Fail if referenced source image for a new volume does not exist
Story: 2008926
Task: 42525
Change-Id: I867d6869744528aae3034a7e0add2d0e922a97ff
2021-05-26 18:21:08 +02:00
Zuul
d4033b4cea Merge "Remove pip job" 2021-05-25 21:10:10 +00:00
Zuul
426b6e782a Merge "Make tripleo master job voting" 2021-05-25 21:10:06 +00:00
Zuul
75b2c60960 Merge "Fix inventory plugin on Ansible 2.11" 2021-05-25 19:59:49 +00:00
Sagi Shnaidman
c9527889a0 Remove pip job
Pip installation is not recommended for collections anyway, so
let's drop this check to make CI more tiny.
Change-Id: I3d02f0c8101a5c46404563b64e8bea78fe422a59
2021-05-25 20:48:01 +03:00
per-lind
42a5cb5601 Fix inventory plugin on Ansible 2.11
The bug here is that the openstack inventory plugin will no longer work with Ansible 2.11. You can test an inventory file (named openstack.yml) with either of these syntaxes:

plugin: openstack
plugin: openstack.cloud.openstack
The first option errors due to custom validation present in openstack's own inventory plugin:

[WARNING]: * Failed to parse /home/alancoding/repos/awx/testing/openstack/openstack.yml with auto plugin: plugin
config file, but not for us: openstack

Because this was written back before FQCNs (fully-qualified collection names) were a thing. Before it migrated to a collection, "openstack" was the expectation, but then self.NAME for the inventory plugin changed to "openstack.cloud.openstack", meaning that "openstack" by itself would no longer work. That made sense until Ansible core introduced routing where it would recognize "openstack" and route it to "openstack.cloud.openstack" for purposes of the "auto" inventory plugin routing. See the routing entry at:

2cbfd1e350/lib/ansible/config/ansible_builtin_runtime.yml (L9548)

The second option errors with:

[WARNING]: * Failed to parse /home/alancoding/repos/awx/testing/openstack_fqcn/openstack.yml with auto plugin:
Invalid value "openstack.cloud.openstack" for configuration option "plugin_type: inventory plugin:
ansible_collections.openstack.cloud.plugins.inventory.openstack setting: plugin ", valid values are: ['openstack']

This is due to Ansible core enforcing stricter validation of options. Merged in this PR ansible/ansible#73162

That broke many inventory plugins because the practice before the migration to collections was to list the name in the choices for the "plugin" option. This has been fixed in other collections.

Because neither of these options work, the inventory plugin is not usable in recent Ansible versions.

Suggested patch here:

https://github.com/AlanCoding/ansible-collections-openstack/compare/fqcn_name?expand=1

This allows the user to use either syntax, because there's an argument for the validity of both.

credit to https://github.com/AlanCoding

Change-Id: Ie1211796929d0bc12c7a48764bd8efc7defdd2d7
2021-05-25 19:42:04 +02:00
Sagi Shnaidman
aa387aab3a Make tripleo master job voting
And train as non-voting - mostly for informational purpose.
Change-Id: Ib0d186865591922614d8d7f786da520cd26c3976
2021-05-25 13:45:31 +03:00
Artem Goncharov
af79857bfb Switch Stack module to OpenStackModule
Switch stack module to the general OpenStackModule.

Change-Id: I98006adcb16c57d5d00990ef6cb76298ff9af9f9
2021-05-25 10:37:19 +02:00
Artem Goncharov
a51d922bee Switch identity_domain module to OpenStackModule
Change-Id: I8d7250cbc5396af25b9720c6f5ccb3925a398ac7
2021-05-21 12:15:29 +00:00
Artem Goncharov
0cbaeb6fbb Switch identity_role module to OpenStackModule
Change-Id: I57c2c558bd01c984453fb11048e8a888ec4d9eea
2021-05-21 12:14:49 +00:00
Artem Goncharov
532857c0b2 Switch federation_idp module to OpenStackModule
Change-Id: I9de209373991c8d999b0514549ad5808981441f1
2021-05-21 14:14:16 +02:00
Artem Goncharov
acd9bc993b Switch group_assignment module to OpenStackModule
Change-Id: I443ed6785500a0e4aafe9c976a11c022e8f23db0
2021-05-21 12:13:15 +00:00
Artem Goncharov
0904ddd2fe Switch federation_protocol module to OpenStackModule
Change-Id: I28a69171df0d4b2df768458f0b5cff72c3937f59
2021-05-21 14:12:08 +02:00
Artem Goncharov
2120814356 Switch KeystoneFederationProtocolInfo module to OpenStackModule
Switch keystone federation_protocol_info module to the general OpenStackModule.

Change-Id: Ia42c602ad7ea01dcb27d77370cc2617ec51aaaf3
2021-05-21 14:07:25 +02:00
Artem Goncharov
ad70a20af5 Switch identity_group module to OpenStackModule
Change-Id: I880e425a5b334abfe7b9498d70229427292c2296
2021-05-21 14:05:25 +02:00
Artem Goncharov
a32cff23c7 Switch Recordset module to OpenStackModule
Switch dns.recordset module to the general OpenStackModule.

Change-Id: I858880834acce6112eadd7e78e339f39b7c455da
2021-05-21 14:04:34 +02:00
Artem Goncharov
f29a8407af Switch port module to OpenStackModule
Switch port module to the general OpenStackModule.

Change-Id: I66fcc0bc126563a6652253151e098fab62f9c68f
2021-05-21 14:02:49 +02:00
Artem Goncharov
555178ecc6 Switch user_info module to OpenStackModule
Drop deprecated block to keep simplicity.

Change-Id: I9e64913cd157f2985ef720ddecfbeb9ad996fa2c
2021-05-21 14:01:46 +02:00
Artem Goncharov
f93172677c Switch ServerGroup module to OpenStackModule
Switch ServerGroup module to the general OpenStackModule.

Change-Id: Ib80483fbc6c3d93003b690997014d8d08315296d
2021-05-21 13:57:38 +02:00
Artem Goncharov
2a461cadd9 Switch ServerMetadata module to OpenStackModule
Switch ServerMetadata module to the general OpenStackModule.

Change-Id: If3f3086a964c47407ec82dda662d2c1524283fb6
2021-05-21 13:56:43 +02:00
Artem Goncharov
e3c61aeefd Switch Snapshot module to OpenStackModule
Switch snapshot module to the general OpenStackModule.

Change-Id: I0f4281324e5276122f51722c7b8e79ee185fd476
2021-05-21 13:47:50 +02:00
Artem Goncharov
3e4413ec31 Switch auth module to OpenStackModule
Change-Id: I6e81a6a8171f62651dce0a4b3cc794b045a5a453
2021-05-21 07:47:42 +00:00
Artem Goncharov
37afe5f2e6 Switch catalog_service module to OpenStackModule
Change-Id: I77332c1af2311a472702e90f72ea9b21d385df3c
2021-05-21 07:46:26 +00:00
Artem Goncharov
7e190d12b4 Switch coe_cluster module to OpenStackModule
Change-Id: Idb316136840001e406f76c08d99654d32e14d168
2021-05-21 07:46:15 +00:00
Artem Goncharov
3d9f9a0f87 Switch coe_cluster_template module to OpenStackModule
Change-Id: I486d98d3f4ec480254a0dcb82a5cb48a9ecc8d3f
2021-05-21 07:44:43 +00:00
Artem Goncharov
57e1087177 Switch flavor module to OpenStackModule
Change-Id: I49302c7ca72b85c74c00e436bc4d695115471f70
2021-05-21 07:44:28 +00:00
Artem Goncharov
6cb6e70645 Switch flavor_info module to OpenStackModule
Change-Id: I96f876bdf1eab0e451ee6d251b62f6aaa52ffc6f
2021-05-21 07:43:56 +00:00
Artem Goncharov
662ac61640 Switch endpoint module to OpenStackModule
Change-Id: Ibd208374297342764c79ffe3968e360cc3ae004d
2021-05-21 07:43:44 +00:00
Artem Goncharov
891fb6df53 Switch federation_idp_info module to OpenStackModule
Change-Id: I7d37e83da3bccd13ed4c7bd5f0dce5bfe9e205cb
2021-05-21 07:42:41 +00:00
Artem Goncharov
0c6752215b Switch federation_mapping module to OpenStackModule
Change-Id: If50b83aaae9eb684624a5fe34415c3b67d10b65f
2021-05-21 07:42:30 +00:00
Artem Goncharov
a6f1177584 Switch federation_mapping_info module to OpenStackModule
Change-Id: Ia0abcaea7694396a6c7b7f8fd01a3b29f27c7729
2021-05-21 07:40:56 +00:00
Artem Goncharov
2dc2806c57 Switch floating_ip module to OpenStackModule
Change-Id: I0d406b527a2389d5299ab4e5f5c557737fe2ad99
2021-05-21 07:40:05 +00:00
Artem Goncharov
59df183660 Switch identity_domain_info module to OpenStackModule
Change-Id: If866ef04ae822b09b162773262e49ec8f33f5e92
2021-05-21 07:38:50 +00:00
Artem Goncharov
2c287d754c Switch identity_group_info module to OpenStackModule
Change-Id: I6e425cad55e7c1c9df44c4f2688c023e5011d2e9
2021-05-21 07:38:13 +00:00
Artem Goncharov
28d32b53e8 Switch identity_user module to OpenStackModule
Change-Id: I61a43ac31f23758204d11fe72754a50993dcc294
2021-05-21 07:36:31 +00:00
Artem Goncharov
2cb67620aa Switch lb_listener module to OpenStackModule
Switch loadbalancer listener module to the general OpenStackModule.

Change-Id: Ifa6372bc5ee18e3ec47edaf630a3149609e1db0b
2021-05-21 07:33:15 +00:00
Artem Goncharov
5217b6bdc4 Switch lb_member module to OpenStackModule
Switch loadbalancer member module to the general OpenStackModule.

Change-Id: I92d09c27205f8fa01df9ddab96448c433c42ef79
2021-05-21 07:32:54 +00:00
Artem Goncharov
96ea60a883 Switch lb_pool module to OpenStackModule
Switch loadbalancer_pool module to the general OpenStackModule.

Change-Id: I75dfd34dd65f73ae8d7584729aa0c14fd14ee366
2021-05-21 07:32:00 +00:00
Artem Goncharov
0eef3cb978 Switch object module to OpenStackModule
Switch object module to the general OpenStackModule.

Change-Id: Ic90d796fe4bbec118c148ffd468458bd98990422
2021-05-21 07:30:55 +00:00
Artem Goncharov
e695000daa Switch port_info module to OpenStackModule
Switch networking port_info module to OpenStackModule. Drop part of
deprecated functionality to keep it simple.

Change-Id: I1d310e369ba2fde76478d9751bd8151fe20e2ba7
2021-05-21 07:29:51 +00:00
Artem Goncharov
0258878400 Switch role_assignment module to OpenStackModule
Switch role_assignment module to the general OpenStackModule.

Change-Id: I67df08cced62fb729cb1d4fbb43ac5977fca61de
2021-05-21 09:25:58 +02:00
Paul Belanger
ea7ba854d5 Add bindep.txt for ansible-builder
This allows users to properly build openstacksdk when using
ansible-builder.

Signed-off-by: Paul Belanger <pabelanger@redhat.com>
Change-Id: I6cef73dedeac75a072309f7f2b6682906102a20d
2021-05-19 14:04:33 -04:00
Dmitriy Rabotyagov
6b3bf3bba0 Add support to setting image tags
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/783849
Change-Id: Idee1f3c16cb07db39395b434d406628a9c5b152d
2021-05-18 16:30:01 +00:00
Zuul
daaa6bf561 Merge "Switch project and project_info module to OpenStackModule" 2021-05-12 21:31:19 +00:00
Sagi Shnaidman
2027eb1f46 Add non-voting train TripleO jobs
Because we use modules starting from train, let's check we don't
break anything in train branch for TripleO.
Use non-voting more for informational purpose, since old branches
jobs can be unstable.

Change-Id: I0026b3bdd785a32b7d701ed6ac146853c0cdd162
2021-05-11 12:16:37 +03:00
Artem Goncharov
944f9ca498 Switch project and project_info module to OpenStackModule
Continuing our journey on generalization of the modules switch the
project modules.

Change-Id: I29c689212c07e1e582cffcdd47496975ac0d327c
2021-05-11 09:11:50 +00:00
Sagi Shnaidman
ca6824bffe Configure only one tripleo job
Because we run only one job, no need to set content provider.
Change-Id: I85ad4281906a6d4aec4dceb4e6fc985e8c60f1a8
2021-05-11 01:04:29 +03:00
Sagi Shnaidman
a10be98638 Add TripleO job on collections used in TripleO
Redefine irrelevant files for jobs.

Change-Id: I83616ca370a449dcead99aed03fe4e54358e9e5a
2021-05-06 17:53:26 +03:00
Zuul
6787924f13 Merge "Fix the idempotent of compute_flavor module" 2021-05-04 09:25:49 +00:00
Zuul
d1d6b4d2dd Merge "setup.cfg: Replace dashes with underscores" 2021-04-29 13:46:33 +00:00
Zuul
06e76a1687 Merge "Remove CI jobs for rocky and stein branches from check" 2021-04-29 13:26:03 +00:00
Zuul
464d7767bb Merge "Migrating image module from AnsibleModule to OpenStackModule" 2021-04-29 12:09:05 +00:00
Sagi Shnaidman
718f3a6b3a Remove CI jobs for rocky and stein branches from check
We don't want to support full compatibility with rocky and stein
branches. Move CI jobs for them to experimental pipeline.
Change-Id: I738831bada5c4779869024c5660d9a7607a603c5
2021-04-29 12:57:12 +03:00
yangyawei
3320c662c8 setup.cfg: Replace dashes with underscores
Setuptools v54.1.0 introduces a warning that the use of dash-separated
options in 'setup.cfg' will not be supported in a future version [1].
Get ahead of the issue by replacing the dashes with underscores. Without
this, we see 'UserWarning' messages like the following on new enough
versions of setuptools:

  UserWarning: Usage of dash-separated 'description-file' will not be
  supported in future versions. Please use the underscore name
  'description_file' instead

[1] https://github.com/pypa/setuptools/commit/a2e9ae4cb

Change-Id: I01ed896fb685dc6e8873b26942fa1c85c897a25f
2021-04-29 17:38:54 +08:00
wuchunyang
77acba047b Fix the idempotent of compute_flavor module
if flavor's swap is not set (or 0),nova returns empty string [0]
rather than 0 when query flavor spec. this behavior will break
the idempotent of the ansible deployment. this ps changes the empty
string to 0 before compare them.
[0]: https://docs.openstack.org/api-ref/compute/?expanded=list-flavors-detail,list-flavors-with-details-detail#list-flavors-with-details

Change-Id: I041cbcc0432051d795e2c3f0e7ac7378e1970008
2021-04-27 18:12:29 +08:00
anbanerj
890401b605 Migrating image module from AnsibleModule to OpenStackModule
1. Added ImageModule class
2. Added deprecated_names
3. Updated types in param

Change-Id: I58beb5cab26106769d18e25cd3d23df68145e363
2021-04-22 10:32:46 +02:00
Sagi Shnaidman
8da4e852f0 Add wallaby job to CI
Add voting for train.
Change-Id: I5ecdc746056edf59d647b73c7fa7d316c092b38a
2021-04-20 04:05:12 +03:00
Sagi Shnaidman
f3e9c78c18 Bump to dev version
Change-Id: I8a10b36eef9a98fe1a4b43a7c6ce8986950154ad
2021-04-09 00:23:25 +03:00
151 changed files with 9609 additions and 3686 deletions

View File

@@ -1,14 +1,43 @@
# yamllint disable
---
# Keep parent jobs in sync between branches to avoid issues e.g. with job scheduling. Zuul CI will search in master
# branch first when collecting job variants during job freeze which can have unwanted side effects. For example, when
# parent job *-base has been changed in stable/1.0.0 branch, Zuul could still use *-base variants from master branch
# during job freeze on child jobs such as *-ussuri-ansible-2.11 etc.
#
# Do not share job definitions with the job.branches attribute across multiple branches. Do not define jobs which are
# specific to other branches, except for parent jobs which are shared across branches. For example, to not add a job
# which is specific for the stable/1.0.0 branch to the .zuul.yaml in master branch. In particular do not use the
# job.branches directive on a job which will be copied to multiple branches. When you have multiple copies of a job with
# the job.branches attribute, Zuul CI could pick any of the job definitions which might not be the one you expected.
- job:
name: ansible-collections-openstack-functional-devstack
name: ansible-collections-openstack-functional-devstack-base
parent: openstacksdk-functional-devstack
# Do not restrict branches in base jobs because else Zuul would not find a matching
# parent job variant during job freeze when child jobs are on other branches.
post-run: ci/playbooks/postlog.yaml
description: |
Run openstack collections functional tests against a master devstack
using master of openstacksdk with latest ansible release
Run openstack collections functional tests against a devstack
# Do not set job.override-checkout or job.required-projects.override-checkout in base job because
# else Zuul will use this branch when matching variants for parent jobs during job freeze
required-projects:
- openstack/ansible-collections-openstack
- openstack/designate
# openstack/devstack is required through parent job openstacksdk-functional-devstack
# openstack/os-client-config is required through parent job openstacksdk-functional-devstack
# openstack/openstacksdk is required through parent job openstacksdk-functional-devstack
irrelevant-files: &ignore_files
- changelogs/.*
- galaxy.*
- COPYING
- docs/.*
- .*\.md
- .*\.rst
- tools/run-ansible-sanity.sh
- tests/sanity/.*
- contrib/.*
- .zuul.yaml
vars:
zuul_work_dir: src/opendev.org/openstack/ansible-collections-openstack
tox_envlist: ansible
@@ -18,19 +47,24 @@
designate: https://opendev.org/openstack/designate
devstack_services:
designate: true
neutron-dns: true
zuul_copy_output:
'{{ devstack_log_dir }}/test_output.log': 'logs'
extensions_to_txt:
log: true
- job:
name: ansible-collections-openstack-functional-devstack-octavia
parent: ansible-collections-openstack-functional-devstack
name: ansible-collections-openstack-functional-devstack-octavia-base
parent: ansible-collections-openstack-functional-devstack-base
# Do not restrict branches in base jobs because else Zuul would not find a matching
# parent job variant during job freeze when child jobs are on other branches.
description: |
Run openstack collections functional tests against a master devstack
with Octavia plugin enabled, using releases of openstacksdk and latest
ansible release. Run it only on Load Balancer changes.
Run openstack collections functional tests against a devstack with Octavia plugin enabled
pre-run: ci/playbooks/get_amphora_tarball.yaml
# Do not set job.override-checkout or job.required-projects.override-checkout in base job because
# else Zuul will use this branch when matching variants for parent jobs during job freeze
required-projects:
- openstack/octavia
- name: github.com/ansible/ansible
override-checkout: stable-2.11
files:
- ^ci/roles/loadbalancer/.*$
- ^plugins/modules/lb_health_monitor.py
@@ -39,12 +73,14 @@
- ^plugins/modules/lb_pool.py
- ^plugins/modules/loadbalancer.py
vars:
tox_envlist: ansible
configure_swap_size: 8192
tox_install_siblings: false
devstack_plugins:
designate: https://opendev.org/openstack/designate
octavia: https://opendev.org/openstack/octavia
devstack_services:
designate: true
neutron-dns: true
octavia: true
o-api: true
o-cw: true
@@ -56,306 +92,448 @@
OCTAVIA_AMP_IMAGE_NAME: "test-only-amphora-x64-haproxy-ubuntu-bionic"
- job:
name: ansible-collections-openstack-functional-devstack-releases
parent: ansible-collections-openstack-functional-devstack
name: ansible-collections-openstack-functional-devstack-octavia
parent: ansible-collections-openstack-functional-devstack-octavia-base
branches: stable/1.0.0
description: |
Run openstack collections functional tests against a master devstack
using releases of openstacksdk and latest ansible release
with Octavia plugin enabled, using 0.*.* releases of openstacksdk
and latest ansible release. Run it only on Load Balancer changes.
required-projects:
- # Choose parent devstack job from master branch instead of non-existing stable/1.0.0 branch
name: openstack/devstack
override-checkout: master
- # Choose parent devstack job from master branch instead of non-existing stable/1.0.0 branch
name: openstack/openstacksdk
override-checkout: master
vars:
tox_envlist: ansible
tox_constraints_file: '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/constraints-openstacksdk-0.x.x.txt'
- job:
name: ansible-collections-openstack-functional-devstack-releases
parent: ansible-collections-openstack-functional-devstack-base
branches: stable/1.0.0
description: |
Run openstack collections functional tests against a master devstack
using 0.*.* releases of openstacksdk and latest ansible release
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.9
- # Choose parent devstack job from master branch instead of non-existing stable/1.0.0 branch
name: openstack/devstack
override-checkout: master
- # Choose parent devstack job from master branch instead of non-existing stable/1.0.0 branch
name: openstack/openstacksdk
override-checkout: master
vars:
tox_constraints_file: '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/constraints-openstacksdk-0.x.x.txt'
tox_install_siblings: false
# Job with Ansible 2.9 for checking backward compatibility
- job:
name: ansible-collections-openstack-functional-devstack-ansible-2.9
parent: ansible-collections-openstack-functional-devstack
parent: ansible-collections-openstack-functional-devstack-base
branches: stable/1.0.0
description: |
Run openstack collections functional tests against a master devstack
using master of openstacksdk and stable 2.9 branch of ansible
using 0.*.* releases of openstacksdk and stable 2.9 branch of ansible
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.9
- # Choose parent devstack job from master branch instead of non-existing stable/1.0.0 branch
name: openstack/devstack
override-checkout: master
- name: openstack/openstacksdk
# Yoga has the latest SDK release of the 0.*.* series atm
override-checkout: stable/yoga
vars:
tox_envlist: ansible-2.9
- job:
name: ansible-collections-openstack-functional-devstack-ansible-2.11
parent: ansible-collections-openstack-functional-devstack
parent: ansible-collections-openstack-functional-devstack-base
branches: stable/1.0.0
description: |
Run openstack collections functional tests against a master devstack
using master of openstacksdk and stable 2.11 branch of ansible
using 0.*.* releases of openstacksdk and stable 2.12 branch of ansible
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.11
vars:
tox_envlist: ansible
- job:
name: ansible-collections-openstack-functional-devstack-ansible-devel
parent: ansible-collections-openstack-functional-devstack
description: |
Run openstack collections functional tests against a master devstack
using master of openstacksdk and devel branch of ansible
voting: false
required-projects:
- name: github.com/ansible/ansible
override-checkout: devel
- # Choose parent devstack job from master branch instead of non-existing stable/1.0.0 branch
name: openstack/devstack
override-checkout: master
- name: openstack/openstacksdk
# Yoga has the latest SDK release of the 0.*.* series atm
override-checkout: stable/yoga
vars:
tox_envlist: ansible-2.11
# Pip installation job
- job:
name: ansible-collections-openstack-functional-devstack-ansible-pip
parent: ansible-collections-openstack-functional-devstack
name: ansible-collections-openstack-functional-devstack-ansible-2.12
parent: ansible-collections-openstack-functional-devstack-base
branches: stable/1.0.0
description: |
Run openstack collections functional tests against a master devstack
using master of openstacksdk with latest ansible release.
Ansible collection is built using PIP.
vars:
tox_envlist: ansible-pip
# Stable branches tests
- job:
name: ansible-collections-openstack-functional-devstack-victoria-ansible-2.11
parent: ansible-collections-openstack-functional-devstack-ansible-devel
description: |
Run openstack collections functional tests against a victoria devstack
using victoria brach of openstacksdk and stable 2.11 branch of ansible
voting: true
override-checkout: stable/victoria
using 0.*.* releases of openstacksdk and stable 2.12 branch of ansible
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.11
override-checkout: stable-2.12
- # Choose parent devstack job from master branch instead of non-existing stable/1.0.0 branch
name: openstack/devstack
override-checkout: master
- name: openstack/openstacksdk
# Yoga has the latest SDK release of the 0.*.* series atm
override-checkout: stable/yoga
vars:
tox_envlist: ansible-2.12
# Stable branches tests
- job:
name: ansible-collections-openstack-functional-devstack-xena-ansible-2.12
# Do not inherit from any parent job which does not run for branch stable/1.0.0 because Zuul would dismiss this job
# when collecting parent job variants. For example, when job.branches is set to master in a parent job, then Zuul
# will not match that job when it collects job variants.
#
# Do not inherit from any parent job which sets job.required-projects.override-checkout on openstack/devstack
# because Zuul would use that git ref instead of stable branch defined below to checkout projects of parent devstack
# jobs when collecting variants for parent jobs.
parent: ansible-collections-openstack-functional-devstack-base
description: |
Run openstack collections functional tests against a xena devstack
using xena branch of openstacksdk and stable 2.12 branch of ansible
branches: stable/1.0.0
override-checkout: stable/xena
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.12
- # Choose parent devstack job from stable/1.0.0 branch instead of non-existing stable/xena branch
name: openstack/ansible-collections-openstack
override-checkout: stable/1.0.0
- # Choose parent devstack job from stable/xena branch
name: openstack/devstack
override-checkout: stable/xena
- name: openstack/openstacksdk
override-checkout: stable/xena
vars:
tox_envlist: ansible-2.12
- job:
name: ansible-collections-openstack-functional-devstack-wallaby-ansible-2.12
# Do not inherit from any parent job which does not run for branch stable/1.0.0 because Zuul would dismiss this job
# when collecting parent job variants. For example, when job.branches is set to master in a parent job, then Zuul
# will not match that job when it collects job variants.
#
# Do not inherit from any parent job which sets job.required-projects.override-checkout on openstack/devstack
# because Zuul would use that git ref instead of stable branch defined below to checkout projects of parent devstack
# jobs when collecting variants for parent jobs.
parent: ansible-collections-openstack-functional-devstack-base
description: |
Run openstack collections functional tests against a wallaby devstack
using wallaby branch of openstacksdk and stable 2.12 branch of ansible
branches: stable/1.0.0
override-checkout: stable/wallaby
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.12
- # Choose parent devstack job from stable/1.0.0 branch instead of non-existing stable/wallaby branch
name: openstack/ansible-collections-openstack
override-checkout: stable/1.0.0
- # Choose parent devstack job from stable/wallaby branch
name: openstack/devstack
override-checkout: stable/wallaby
- name: openstack/openstacksdk
override-checkout: stable/wallaby
vars:
tox_envlist: ansible-2.12
- job:
name: ansible-collections-openstack-functional-devstack-victoria-ansible-2.12
# Do not inherit from any parent job which does not run for branch stable/1.0.0 because Zuul would dismiss this job
# when collecting parent job variants. For example, when job.branches is set to master in a parent job, then Zuul
# will not match that job when it collects job variants.
#
# Do not inherit from any parent job which sets job.required-projects.override-checkout on openstack/devstack
# because Zuul would use that git ref instead of stable branch defined below to checkout projects of parent devstack
# jobs when collecting variants for parent jobs.
parent: ansible-collections-openstack-functional-devstack-base
description: |
Run openstack collections functional tests against a victoria devstack
using victoria branch of openstacksdk and stable 2.12 branch of ansible
branches: stable/1.0.0
override-checkout: stable/victoria
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.12
- # Choose parent devstack job from stable/1.0.0 branch instead of non-existing stable/victoria branch
name: openstack/ansible-collections-openstack
override-checkout: stable/1.0.0
- # Choose parent devstack job from stable/victoria branch
name: openstack/devstack
override-checkout: stable/victoria
- name: openstack/openstacksdk
override-checkout: stable/victoria
vars:
tox_envlist: ansible
tox_envlist: ansible-2.12
- job:
name: ansible-collections-openstack-functional-devstack-ussuri-ansible-2.11
parent: ansible-collections-openstack-functional-devstack-ansible-devel
# Do not inherit from any parent job which does not run for branch stable/1.0.0 because Zuul would dismiss this job
# when collecting parent job variants. For example, when job.branches is set to master in a parent job, then Zuul
# will not match that job when it collects job variants.
#
# Do not inherit from any parent job which sets job.required-projects.override-checkout on openstack/devstack
# because Zuul would use that git ref instead of stable branch defined below to checkout projects of parent devstack
# jobs when collecting variants for parent jobs.
parent: ansible-collections-openstack-functional-devstack-base
description: |
Run openstack collections functional tests against a ussuri devstack
using ussuri brach of openstacksdk and stable 2.11 branch of ansible
voting: true
using ussuri branch of openstacksdk and stable 2.11 branch of ansible
branches: stable/1.0.0
override-checkout: stable/ussuri
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.11
- # Choose parent devstack job from stable/1.0.0 branch instead of non-existing stable/ussuri branch
name: openstack/ansible-collections-openstack
override-checkout: stable/1.0.0
- # Choose parent devstack job from stable/ussuri branch
name: openstack/devstack
override-checkout: stable/ussuri
- name: openstack/openstacksdk
override-checkout: stable/ussuri
- name: openstack/os-client-config
override-checkout: stable/ussuri
vars:
tox_envlist: ansible
tox_envlist: ansible-2.11
- job:
name: ansible-collections-openstack-functional-devstack-train-ansible-2.11
parent: ansible-collections-openstack-functional-devstack-ansible-devel
# Do not inherit from any parent job which does not run for branch stable/1.0.0 because Zuul would dismiss this job
# when collecting parent job variants. For example, when job.branches is set to master in a parent job, then Zuul
# will not match that job when it collects job variants.
#
# Do not inherit from any parent job which sets job.required-projects.override-checkout on openstack/devstack
# because Zuul would use that git ref instead of stable branch defined below to checkout projects of parent devstack
# jobs when collecting variants for parent jobs.
parent: ansible-collections-openstack-functional-devstack-base
description: |
Run openstack collections functional tests against a train devstack
using train brach of openstacksdk and stable 2.11 branch of ansible
voting: false
using train branch of openstacksdk and stable 2.11 branch of ansible
branches: stable/1.0.0
override-checkout: stable/train
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.11
- name: openstack/openstacksdk
- # Choose parent devstack job from stable/1.0.0 branch instead of non-existing stable/train branch
name: openstack/ansible-collections-openstack
override-checkout: stable/1.0.0
- # Choose parent devstack job from stable/train branch
name: openstack/devstack
override-checkout: stable/train
- name: openstack/os-client-config
override-checkout: stable/train
vars:
tox_envlist: ansible
- job:
name: ansible-collections-openstack-functional-devstack-stein-ansible-2.11
parent: ansible-collections-openstack-functional-devstack-ansible-devel
description: |
Run openstack collections functional tests against a stein devstack
using stein brach of openstacksdk and stable 2.11 branch of ansible
voting: true
override-checkout: stable/stein
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.11
- name: openstack/openstacksdk
override-checkout: stable/stein
- name: openstack/os-client-config
override-checkout: stable/stein
vars:
tox_envlist: ansible
- job:
name: ansible-collections-openstack-functional-devstack-rocky-ansible-2.11
parent: ansible-collections-openstack-functional-devstack-ansible-devel
description: |
Run openstack collections functional tests against a rocky devstack
using rocky brach of openstacksdk and stable 2.11 branch of ansible
voting: true
override-checkout: stable/rocky
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.11
- name: openstack/openstacksdk
override-checkout: stable/rocky
- name: openstack/os-client-config
override-checkout: stable/rocky
- name: openstack/shade
override-checkout: stable/rocky
vars:
tox_envlist: ansible
- job:
name: ansible-collections-openstack-functional-devstack-queens-ansible-2.11
parent: ansible-collections-openstack-functional-devstack-ansible-devel
description: |
Run openstack collections functional tests against a queens devstack
using master branch of openstacksdk and stable 2.11 branch of ansible
voting: true
override-checkout: stable/queens
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.11
- name: openstack/openstacksdk
# Run queens with highest possible py2 version of SDK
override-checkout: stable/train
vars:
tox_envlist: ansible
- job:
name: ansible-collections-openstack-functional-devstack-queens-ansible-devel
parent: ansible-collections-openstack-functional-devstack-ansible-devel
description: |
Run openstack collections functional tests against a queens devstack
using master branch of openstacksdk and devel branch of ansible
voting: false
override-checkout: stable/queens
required-projects:
- name: github.com/ansible/ansible
override-checkout: devel
- name: openstack/openstacksdk
# Run queens with highest possible py2 version of SDK
override-checkout: stable/train
vars:
tox_envlist: ansible-2.11
# Linters
- job:
name: openstack-tox-linters-ansible-devel
name: openstack-tox-linters-ansible
parent: openstack-tox-linters
nodeset: ubuntu-bionic
nodeset: ubuntu-focal
description: |
Run openstack collections linter tests using the devel branch of ansible
required-projects:
- name: github.com/ansible/ansible
override-checkout: devel
vars:
# override tox_constraints_file from parent job
tox_constraints_file: '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/constraints-none.txt'
tox_envlist: linters
tox_install_siblings: true
- job:
name: openstack-tox-linters-ansible-devel
parent: openstack-tox-linters-ansible
description: |
Run openstack collections linter tests using the devel branch of ansible
# non-voting because we can't prevent ansible devel from breaking us
voting: false
required-projects:
- name: github.com/ansible/ansible
override-checkout: devel
vars:
tox_envlist: linters-2.11
python_version: 3.8
bindep_profile: test py38
- job:
name: openstack-tox-linters-ansible-2.11
parent: openstack-tox-linters
nodeset: ubuntu-bionic
name: openstack-tox-linters-ansible-2.12
parent: openstack-tox-linters-ansible
description: |
Run openstack collections linter tests using the 2.11 branch of ansible
voting: true
Run openstack collections linter tests using the 2.12 branch of ansible
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.11
- job:
name: openstack-tox-linters-ansible-2.9
parent: openstack-tox-linters
nodeset: ubuntu-bionic
description: |
Run openstack collections linter tests using the 2.9 branch of ansible
voting: true
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.9
override-checkout: stable-2.12
vars:
tox_envlist: linters-2.9
tox_envlist: linters-2.12
python_version: 3.8
bindep_profile: test py38
# Cross-checks with other projects
- job:
name: bifrost-collections-src
parent: bifrost-integration-tinyipa-ubuntu-focal
override-checkout: stable/yoga
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- openstack/ansible-collections-openstack
- # always use existing branch when collecting parent job variants, refer to git blame for rationale.
name: openstack/bifrost
# Yoga has the latest SDK release of the 0.*.* series atm
override-checkout: stable/yoga
- job:
name: bifrost-keystone-collections-src
parent: bifrost-integration-tinyipa-keystone-ubuntu-focal
override-checkout: stable/yoga
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- openstack/ansible-collections-openstack
- # always use existing branch when collecting parent job variants, refer to git blame for rationale.
name: openstack/bifrost
# Yoga has the latest SDK release of the 0.*.* series atm
override-checkout: stable/yoga
# TripleO jobs
- job:
name: tripleo-ci-centos-8-standalone-osa-pre-zed
parent: tripleo-ci-centos-8-standalone-build
# Do not restrict branches in base jobs because else Zuul would not find a matching
# parent job variant during job freeze when child jobs are on other branches.
vars: &tripleo_vars
consumer_job: false
# Define branch_override in child jobs, e.g. branch_override: stable/yoga
force_non_periodic: true
required-projects: &tripleo_required_projects
- # Required for TripleO Quickstart to install current patchset of the collection
# Ref.: https://opendev.org/openstack/tripleo-quickstart/src/commit/b48d869e14de40444d69a107a0b718b5f721e912/quickstart.sh#L123
openstack/ansible-collections-openstack
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
name: openstack/tripleo-ci
override-checkout: master
irrelevant-files: &tripleo_irrelevant_files
- .*molecule.*
- ^.*\.md$
- ^.*\.rst$
- ^changelogs/.*$
- ^contrib/.*$
- ^docs/.*$
- ^meta/.*$
- ^requirements.*$
- ^setup.*$
- ^tests/.*$
- ^tools/.*$
- tox.ini
# Run only on files used in TripleO
files: &tripleo_files
- ^.zuul.yaml$
- ^plugins/module_utils/openstack.*$
- ^plugins/modules/catalog_service.*$
- ^plugins/modules/compute_flavor.*$
- ^plugins/modules/endpoint.*$
- ^plugins/modules/identity_domain.*$
- ^plugins/modules/identity_domain_info.*$
- ^plugins/modules/identity_role.*$
- ^plugins/modules/identity_user.*$
- ^plugins/modules/image.*$
- ^plugins/modules/keypair.*$
- ^plugins/modules/network.*$
- ^plugins/modules/project.*$
- ^plugins/modules/role_assignment.*$
- ^plugins/modules/router.*$
- ^plugins/modules/stack.*$
- ^plugins/modules/subnet.*$
- job:
name: tripleo-ci-centos-9-standalone-osa-pre-zed
parent: tripleo-ci-centos-9-standalone-build
# Do not restrict branches in base jobs because else Zuul would not find a matching
# parent job variant during job freeze when child jobs are on other branches.
vars: *tripleo_vars
required-projects: *tripleo_required_projects
irrelevant-files: *tripleo_irrelevant_files
files: *tripleo_files
- job:
name: tripleo-ci-centos-8-standalone-osa-train
parent: tripleo-ci-centos-8-standalone-osa-pre-zed
branches: stable/1.0.0
override-checkout: stable/train
vars:
branch_override: stable/train
- job:
name: tripleo-ci-centos-8-standalone-osa-wallaby
parent: tripleo-ci-centos-8-standalone-osa-pre-zed
branches: stable/1.0.0
override-checkout: stable/wallaby
vars:
branch_override: stable/wallaby
- job:
name: tripleo-ci-centos-9-standalone-osa-wallaby
parent: tripleo-ci-centos-9-standalone-osa-pre-zed
branches: stable/1.0.0
override-checkout: stable/wallaby
vars:
branch_override: stable/wallaby
- job:
name: ansible-collections-openstack-release
parent: base
run: ci/publish/publish_collection.yml
secrets:
- ansible_galaxy_info
- secret:
name: ansible_galaxy_info
data:
url: https://galaxy.ansible.com
token: !encrypted/pkcs1-oaep
- lZFzfoCbuwqV1k6qRfl/VS7E+knUW7+zpg7BptrenK4n0g7UY0HtdVkYq0pV0Tj/LbhzG
jHD0mehcV1iS6B7ORKg4criJkdDfEx09BD8z8yv0EleiIMmhlrCoMcY593OZMBtVbGi0D
CwQtNO98QIsfZogChfLfvRNiBmUV98mEb/p6p3EtGx8J7qcAsqfWxc/CzB8GCleLAHHHT
FuikMM03ZnV0ew7E+TPkHbzzPhBZOqS5HYF0HtgttHwIXdfIWp/XdTuEEk7uRRgYZ2Iao
ifWRzoKaOQmhM++e1ydCqw9D4y9dZEFNMQLwSqcrvtb8cNwT1kl7SCFqYNE2lbutj4ne6
PTBQRsKegMB4Y3ena14fNF6tCynvJLPhF/cjPH2Jhs+B19XQhWkL3TgiOY02W24YHwRcP
+LdkM8inAvyVi3DEbEqdjBPO9OFJcBOKPlCdkGvuwdNCuEpEwctWs0gV3voflG2CDKzmJ
wu9JJOAWnq/0l1WpuDqWreKeQ/BUGZC2Gb4xRAqofulgvhs4WuYoEccjH4EJFIZ90S1EP
R/ZLadqZaEhmjwGM5sMWbBbjT23XsRgg0Tzt9m8DENYMuYDqkMdRbt2jYZa+32p4hyxVe
Y6H/pqYq5b9uOzumnShaK4WlmkQyXcNPkoSlMC1h4OGvqX/WUixpI38jyMA5Tc=
- project:
check:
jobs:
- tox-pep8
- openstack-tox-linters-ansible-devel
- openstack-tox-linters-ansible-2.11
- openstack-tox-linters-ansible-2.9
- ansible-collections-openstack-functional-devstack:
- openstack-tox-linters-ansible-2.12
- ansible-collections-openstack-functional-devstack-releases:
dependencies: &deps_unit_lint
- tox-pep8
- openstack-tox-linters-ansible-2.9
- openstack-tox-linters-ansible-2.11
irrelevant-files: &ignore_files
- changelogs/.*
- COPYING
- docs/.*
- .*\.md
- .*\.rst
- tools/run-ansible-sanity.sh
- tests/sanity/.*
- contrib/.*
- ansible-collections-openstack-functional-devstack-releases:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
- openstack-tox-linters-ansible-2.12
- ansible-collections-openstack-functional-devstack-ansible-2.9:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
- ansible-collections-openstack-functional-devstack-ansible-2.11:
- ansible-collections-openstack-functional-devstack-ansible-2.12:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
- ansible-collections-openstack-functional-devstack-ansible-devel:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
- ansible-collections-openstack-functional-devstack-ansible-pip:
- ansible-collections-openstack-functional-devstack-xena-ansible-2.12:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
- ansible-collections-openstack-functional-devstack-victoria-ansible-2.11:
- ansible-collections-openstack-functional-devstack-wallaby-ansible-2.12:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
- ansible-collections-openstack-functional-devstack-ussuri-ansible-2.11:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
- ansible-collections-openstack-functional-devstack-train-ansible-2.11:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
voting: false
- ansible-collections-openstack-functional-devstack-stein-ansible-2.11:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
voting: false
- ansible-collections-openstack-functional-devstack-rocky-ansible-2.11:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
voting: false
- ansible-collections-openstack-functional-devstack-queens-ansible-2.11:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
voting: false
- ansible-collections-openstack-functional-devstack-octavia:
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
- bifrost-collections-src:
voting: false
@@ -366,42 +544,50 @@
dependencies: *deps_unit_lint
irrelevant-files: *ignore_files
- tripleo-ci-centos-8-standalone-osa-wallaby:
dependencies: *deps_unit_lint
- tripleo-ci-centos-9-standalone-osa-wallaby:
voting: false
dependencies: *deps_unit_lint
gate:
jobs:
- tox-pep8
- openstack-tox-linters-ansible-2.11
- openstack-tox-linters-ansible-2.9
- ansible-collections-openstack-functional-devstack
- openstack-tox-linters-ansible-2.12
- ansible-collections-openstack-functional-devstack-releases
- ansible-collections-openstack-functional-devstack-ansible-2.9
- ansible-collections-openstack-functional-devstack-ansible-2.11
- ansible-collections-openstack-functional-devstack-ansible-pip
- ansible-collections-openstack-functional-devstack-victoria-ansible-2.11
- ansible-collections-openstack-functional-devstack-ussuri-ansible-2.11
# - ansible-collections-openstack-functional-devstack-train-ansible-2.11
# - ansible-collections-openstack-functional-devstack-stein-ansible-2.11
# - ansible-collections-openstack-functional-devstack-rocky-ansible-2.11
# - ansible-collections-openstack-functional-devstack-queens-ansible-2.11
# - ansible-collections-openstack-functional-devstack-ansible-2.9
# - ansible-collections-openstack-functional-devstack-ansible-2.12
- ansible-collections-openstack-functional-devstack-wallaby-ansible-2.12
- ansible-collections-openstack-functional-devstack-xena-ansible-2.12
- ansible-collections-openstack-functional-devstack-train-ansible-2.11
- ansible-collections-openstack-functional-devstack-octavia
- tripleo-ci-centos-8-standalone-osa-wallaby
periodic:
jobs:
- openstack-tox-linters-ansible-devel
- openstack-tox-linters-ansible-2.11
- openstack-tox-linters-ansible-2.9
- ansible-collections-openstack-functional-devstack
- openstack-tox-linters-ansible-2.12
- ansible-collections-openstack-functional-devstack-releases
- ansible-collections-openstack-functional-devstack-ansible-2.9
- ansible-collections-openstack-functional-devstack-ansible-2.11
- ansible-collections-openstack-functional-devstack-ansible-2.12
- ansible-collections-openstack-functional-devstack-ansible-devel
- ansible-collections-openstack-functional-devstack-ansible-pip
- ansible-collections-openstack-functional-devstack-victoria-ansible-2.11
- ansible-collections-openstack-functional-devstack-ussuri-ansible-2.11
- ansible-collections-openstack-functional-devstack-xena-ansible-2.12
- ansible-collections-openstack-functional-devstack-wallaby-ansible-2.12
- ansible-collections-openstack-functional-devstack-victoria-ansible-2.12
- ansible-collections-openstack-functional-devstack-train-ansible-2.11
- ansible-collections-openstack-functional-devstack-stein-ansible-2.11
- ansible-collections-openstack-functional-devstack-rocky-ansible-2.11
- ansible-collections-openstack-functional-devstack-queens-ansible-2.11
- ansible-collections-openstack-functional-devstack-queens-ansible-devel
- bifrost-collections-src
- bifrost-keystone-collections-src
- ansible-collections-openstack-functional-devstack-octavia
- tripleo-ci-centos-9-standalone-osa-wallaby
- tripleo-ci-centos-8-standalone-osa-wallaby
experimental:
jobs:
- tripleo-ci-centos-8-standalone-osa-train
- ansible-collections-openstack-functional-devstack-ansible-2.11
- ansible-collections-openstack-functional-devstack-victoria-ansible-2.12
- ansible-collections-openstack-functional-devstack-ussuri-ansible-2.11
tag:
jobs:
- ansible-collections-openstack-release

View File

@@ -5,6 +5,293 @@ Openstack Cloud Ansilbe modules Release Notes
.. contents:: Topics
v1.9.0
======
Release Summary
---------------
This release will enforce openstacksdk<0.99.0, has a dozen modules refactored and several bugs fixed.
Bugfixes
--------
- Added support for specifying a maximum version of the OpenStack SDK
- Constrain filters in compute_service_info to SDK >= 0.53.0
- Drop username from return values of identity_user_info
- Fix logic in routers_info
- Fixed return value disable{d,s}_reason in compute_service_info module
- Fixed return values in compute_service_info module again
- Follow up to bump of minimum required OpenStack SDK release to SDK 0.36.0 (Train)
- Lowered maximum OpenStack SDK version to 0.98.999
- Move dns zone info to use proxy layer
- Refactored catalog_service module
- Refactored endpoint module
- Refactored host_aggregate module
- Refactored identity_domain_info module
- Refactored identity_group_info module
- Refactored identity_role module
- Refactored identity_role_info module
- Refactored identity_user module
- Refactored identity_user_info module
- Refactored image_info module
- Refactored keypair_info module
- Refactored recordset module
- Refactored role_assignment module
- Set owner in image module
- Support description in sg-rule creation
- Warn users about us breaking backward compatibility
Known Issues
------------
- For compatibility with OpenStack SDK >= 0.99.0 use Ansible OpenStack collection 2.0.0 or later which is currently under development.
- Release series 1.x.x of this collection is compatible to OpenStack SDK prior to 0.99.0 only.
v1.8.0
======
Release Summary
---------------
Subnet pool module and bugfixes
Bugfixes
--------
- Add 'all_projects' to server_action module
- Add subnet pool module
- Bumped minimum required OpenStack SDK release to SDK 0.36.0 (Train)
- Changed compute_flavor_info module to use OpenStack SDK's proxy layer
- Dropped deprecated return values in floating_ip_info and assert remaining fields
- Fix ansible-lint issues for the newest version
- Fix assertion after stack deletion
- Handle aggregate host list set to None
- Reenabled check-import.sh which tests imports to Ansible Galaxy
- Remove old, unsupported parameters from documentation in image_info module
- Router - Remove unneeded 'filter' parameter
- Updated return value docs of compute_service_info module
New Modules
-----------
- openstack.cloud.subnet_pool - Create or Delete subnet pools from OpenStack.
v1.7.2
======
Release Summary
---------------
Bugfixes
Bugfixes
--------
- Fix collection guidelines
v1.7.1
======
Release Summary
---------------
Bugfixes
Minor Changes
-------------
- lb_member - Add monitor_[address,port] parameter
Bugfixes
--------
- openstack_inventory - Fix documentation
- quota - Fix description of volumes_types parameter
v1.7.0
======
Release Summary
---------------
New modules for Ironic and bugfixes
Minor Changes
-------------
- openstack_inventory - Adds use_name variable
- port - Add dns_[name,domain] to the port module
- project - Remove project properties tests and support
Bugfixes
--------
- identity_user_info - Fix identity user lookup with a domain
- keystone_domain - Move identity domain to use proxy layer
New Modules
-----------
- openstack.cloud.baremetal_node_info - Retrieve information about Bare Metal nodes from OpenStack an object.
- openstack.cloud.baremetal_port - Create, Update, Remove ironic ports from OpenStack
- openstack.cloud.baremetal_port_info - Retrieve information about Bare Metal ports from OpenStack an object.
v1.6.0
======
Release Summary
---------------
New modules for RBAC and Nova services
Minor Changes
-------------
- quota - Adds metadata_items parameter
New Modules
-----------
- openstack.cloud.compute_service_info - Retrieve information about one or more OpenStack compute services
- openstack.cloud.neutron_rbac_policies_info - Fetch Neutron policies.
- openstack.cloud.neutron_rbac_policy - Create or delete a Neutron policy to apply a RBAC rule against an object.
v1.5.3
======
Release Summary
---------------
Bugfixes
Bugfixes
--------
- Don't require allowed_address_pairs for port
- server_volume - check specified server is found
v1.5.2
======
Release Summary
---------------
Bugfixes
Minor Changes
-------------
- Add documentation links to README.md
- Don't run functional jobs on galaxy.yml change
- Move CI to use Ansible 2.12 version as main
Bugfixes
--------
- Add client and member listener timeouts for persistence (Ex. SSH)
- Added missing warn() used in cloud.openstack.quota
- Fix issue with same host and group names
- Flavor properties are not deleted on changes and id will stay
v1.5.1
======
Release Summary
---------------
Bugfixes for networking modules
Minor Changes
-------------
- Changed minversion in tox to 3.18.0
- Update IRC server in README
Bugfixes
--------
- Add mandatory requires_ansible version to metadata
- Add protocol listener octavia
- Add support check mode for all info modules
- Allow to attach multiple floating ips to a server
- Only add or remove router interfaces when needed
- Wait for pool to be active and online
v1.5.0
======
Release Summary
---------------
New modules for DNS and FIPs and bugfixes.
Minor Changes
-------------
- Add bindep.txt for ansible-builder
- Add check_mode attribute to OpenstackModule
- Migrating image module from AnsibleModule to OpenStackModule
- Switch KeystoneFederationProtocolInfo module to OpenStackModule
- Switch ProjectAccess module to OpenStackModule
- Switch Quota module to OpenStackModule
- Switch Recordset module to OpenStackModule
- Switch ServerGroup module to OpenStackModule
- Switch ServerMetadata module to OpenStackModule
- Switch Snapshot module to OpenStackModule
- Switch Stack module to OpenStackModule
- Switch auth module to OpenStackModule
- Switch catalog_service module to OpenStackModule
- Switch coe_cluster module to OpenStackModule
- Switch coe_cluster_template module to OpenStackModule
- Switch endpoint module to OpenStackModule
- Switch federation_idp module to OpenStackModule
- Switch federation_idp_info module to OpenStackModule
- Switch federation_mapping module to OpenStackModule
- Switch federation_mapping_info module to OpenStackModule
- Switch federation_protocol module to OpenStackModule
- Switch flavor module to OpenStackModule
- Switch flavor_info module to OpenStackModule
- Switch floating_ip module to OpenStackModule
- Switch group_assignment module to OpenStackModule
- Switch hostaggregate module to OpenStackModule
- Switch identity_domain module to OpenStackModule
- Switch identity_domain_info module to OpenStackModule
- Switch identity_group module to OpenStackModule
- Switch identity_group_info module to OpenStackModule
- Switch identity_role module to OpenStackModule
- Switch identity_user module to OpenStackModule
- Switch lb_listener module to OpenStackModule
- Switch lb_member module to OpenStackModule
- Switch lb_pool module to OpenStackModule
- Switch object module to OpenStackModule
- Switch port module to OpenStackModule
- Switch port_info module to OpenStackModule
- Switch project and project_info module to OpenStackModule
- Switch role_assignment module to OpenStackModule
- Switch user_info module to OpenStackModule
- image - Add support to setting image tags
Bugfixes
--------
- Update checks for validate_certs in openstack_cloud_from_module
- compute_flavor - Fix the idempotent of compute_flavor module
- host_aggregate - Fix host_aggregate to tolerate aggregate.hosts being None
- inventory/openstack - Fix inventory plugin on Ansible 2.11
- port - fix update on empty list of allowed address pairs
- setup.cfg Replace dashes with underscores
- subnet - Only apply necessary changes to subnets
- volume - Fail if referenced source image for a new volume does not exist
New Modules
-----------
- openstack.cloud.address_scope - Create or delete address scopes from OpenStack
- openstack.cloud.dns_zone_info - Getting information about dns zones
- openstack.cloud.floating_ip_info - Get information about floating ips
v1.4.0
======

View File

@@ -2,11 +2,44 @@
# Ansible Collection: openstack.cloud
This repo hosts the `openstack.cloud` Ansible Collection.
The collection includes the Openstack modules and plugins supported by Openstack community to help the management of Openstack infrastructure.
## Breaking backward compatibility :warning:
Dear contributors and users of the Ansible OpenStack collection!
Our codebase has been split into two separate release series:
* `2.x.x` releases of Ansible OpenStack collection are compatible with OpenStack SDK `1.x.x` and its release candidates
`0.99.x` *only* (OpenStack Zed and later). Our `master` branch tracks our `2.x.x` releases.
* `1.x.x` releases of Ansible OpenStack collection are compatible with OpenStack SDK `0.x.x` prior to `0.99.0` *only*
(OpenStack Yoga and earlier). Our `stable/1.0.0` branch tracks our `1.x.x` releases.
Both branches will be developed in parallel for the time being. Patches from `master` will be backported to
`stable/1.0.0` on a best effort basis but expect new features to be introduced in our `master` branch only.
Contributions are welcome for both branches!
Differences between both branches are mainly renamed and sometimes dropped module return values. We try to keep our
module parameters backward compatible by offering aliases but e.g. the semantics of `filters` parameters in `*_info`
modules have changed due to updates in the OpenStack SDK.
Our decision to break backward compatibility was not taken lightly. OpenStack SDK's first major release (`1.0.0` and its
release candidates `0.99.x`) has streamlined and improved large parts of its codebase. For example, its Connection
interface now consistently uses the Resource interfaces under the hood. This required breaking changes from older SDK
releases though. The Ansible OpenStack collection is heavily based on OpenStack SDK. With OpenStack SDK becoming
backward incompatible, so does our Ansible OpenStack collection. We simply lack the devpower to maintain a backward
compatible interface in Ansible OpenStack collection across several SDK releases.
Our first `2.0.0` release is currently under development and we still have a long way to go. If you use modules of the
Ansible OpenStack collection and want to join us in porting them to the upcoming OpenStack SDK, please contact us!
Ping Jakob Meng <mail@jakobmeng.de> (jm1) or Rafael Castillo <rcastill@redhat.com> (rcastillo) and we will give you a
quick introduction. We are also hanging around on `irc.oftc.net/#openstack-ansible-sig` and `irc.oftc.net/#oooq` 😎
We have extensive documentation on [why, what and how we are adopting and reviewing the new modules](
https://hackmd.io/szgyWa5qSUOWw3JJBXLmOQ?view), [how to set up a working DevStack environment for hacking on the
collection](https://hackmd.io/PI10x-iCTBuO09duvpeWgQ?view) and, most importantly, [a list of modules where we are
coordinating our porting efforts](https://hackmd.io/7NtovjRkRn-tKraBXfz9jw?view).
## Installation and Usage
### Installing dependencies
@@ -15,7 +48,7 @@ For using the Openstack Cloud collection firstly you need to install `ansible` a
For example with pip:
```bash
pip install ansible openstacksdk
pip install "ansible>=2.9" "openstacksdk>=0.36,<0.99.0"
```
OpenStackSDK has to be available to Ansible and to the Python interpreter on the host, where Ansible executes the module (target host).
@@ -83,6 +116,14 @@ Or you can add the full namespace and collection name in the `collections` eleme
device: /dev/vdb
```
### Usage
See the collection docs at Ansible site:
* [openstack.cloud collection docs (version released in Ansible package)](https://docs.ansible.com/ansible/latest/collections/openstack/cloud/index.html)
* [openstack.cloud collection docs (devel version)](https://docs.ansible.com/ansible/devel/collections/openstack/cloud/index.html)
## Contributing
For information on contributing, please see [CONTRIBUTING](https://opendev.org/openstack/ansible-collections-openstack/src/branch/master/CONTRIBUTING.rst)
@@ -114,7 +155,7 @@ TBD
## Communication
We have a dedicated Interest Group for Openstack Ansible modules.
You can find other people interested in this in `#openstack-ansible-sig` on Freenode IRC.
You can find other people interested in this in `#openstack-ansible-sig` on [OFTC IRC](https://www.oftc.net/).
## License

7
bindep.txt Normal file
View File

@@ -0,0 +1,7 @@
# This is a cross-platform list tracking distribution packages needed by tests;
# see https://docs.openstack.org/infra/bindep/ for additional information.
gcc [compile platform:centos-8 platform:rhel-8]
python38-cryptography [platform:centos-8 platform:rhel-8]
python38-devel [compile platform:centos-8 platform:rhel-8]
python38-requests [platform:centos-8 platform:rhel-8]

View File

@@ -166,3 +166,215 @@ releases:
name: object_container
namespace: ''
release_date: '2021-04-08'
1.5.0:
changes:
bugfixes:
- Update checks for validate_certs in openstack_cloud_from_module
- compute_flavor - Fix the idempotent of compute_flavor module
- host_aggregate - Fix host_aggregate to tolerate aggregate.hosts being None
- inventory/openstack - Fix inventory plugin on Ansible 2.11
- port - fix update on empty list of allowed address pairs
- setup.cfg Replace dashes with underscores
- subnet - Only apply necessary changes to subnets
- volume - Fail if referenced source image for a new volume does not exist
minor_changes:
- Add bindep.txt for ansible-builder
- Add check_mode attribute to OpenstackModule
- Migrating image module from AnsibleModule to OpenStackModule
- Switch KeystoneFederationProtocolInfo module to OpenStackModule
- Switch ProjectAccess module to OpenStackModule
- Switch Quota module to OpenStackModule
- Switch Recordset module to OpenStackModule
- Switch ServerGroup module to OpenStackModule
- Switch ServerMetadata module to OpenStackModule
- Switch Snapshot module to OpenStackModule
- Switch Stack module to OpenStackModule
- Switch auth module to OpenStackModule
- Switch catalog_service module to OpenStackModule
- Switch coe_cluster module to OpenStackModule
- Switch coe_cluster_template module to OpenStackModule
- Switch endpoint module to OpenStackModule
- Switch federation_idp module to OpenStackModule
- Switch federation_idp_info module to OpenStackModule
- Switch federation_mapping module to OpenStackModule
- Switch federation_mapping_info module to OpenStackModule
- Switch federation_protocol module to OpenStackModule
- Switch flavor module to OpenStackModule
- Switch flavor_info module to OpenStackModule
- Switch floating_ip module to OpenStackModule
- Switch group_assignment module to OpenStackModule
- Switch hostaggregate module to OpenStackModule
- Switch identity_domain module to OpenStackModule
- Switch identity_domain_info module to OpenStackModule
- Switch identity_group module to OpenStackModule
- Switch identity_group_info module to OpenStackModule
- Switch identity_role module to OpenStackModule
- Switch identity_user module to OpenStackModule
- Switch lb_listener module to OpenStackModule
- Switch lb_member module to OpenStackModule
- Switch lb_pool module to OpenStackModule
- Switch object module to OpenStackModule
- Switch port module to OpenStackModule
- Switch port_info module to OpenStackModule
- Switch project and project_info module to OpenStackModule
- Switch role_assignment module to OpenStackModule
- Switch user_info module to OpenStackModule
- image - Add support to setting image tags
release_summary: New modules for DNS and FIPs and bugfixes.
modules:
- description: Create or delete address scopes from OpenStack
name: address_scope
namespace: ''
- description: Getting information about dns zones
name: dns_zone_info
namespace: ''
- description: Get information about floating ips
name: floating_ip_info
namespace: ''
release_date: '2021-06-23'
1.5.1:
changes:
bugfixes:
- Add mandatory requires_ansible version to metadata
- Add protocol listener octavia
- Add support check mode for all info modules
- Allow to attach multiple floating ips to a server
- Only add or remove router interfaces when needed
- Wait for pool to be active and online
minor_changes:
- Changed minversion in tox to 3.18.0
- Update IRC server in README
release_summary: Bugfixes for networking modules
release_date: '2021-09-02'
1.5.2:
changes:
bugfixes:
- Add client and member listener timeouts for persistence (Ex. SSH)
- Added missing warn() used in cloud.openstack.quota
- Fix issue with same host and group names
- Flavor properties are not deleted on changes and id will stay
minor_changes:
- Add documentation links to README.md
- Don't run functional jobs on galaxy.yml change
- Move CI to use Ansible 2.12 version as main
release_summary: Bugfixes
release_date: '2021-11-09'
1.5.3:
changes:
bugfixes:
- Don't require allowed_address_pairs for port
- server_volume - check specified server is found
release_summary: Bugfixes
release_date: '2021-11-11'
1.6.0:
changes:
minor_changes:
- quota - Adds metadata_items parameter
release_summary: New modules for RBAC and Nova services
modules:
- description: Retrieve information about one or more OpenStack compute services
name: compute_service_info
namespace: ''
- description: Fetch Neutron policies.
name: neutron_rbac_policies_info
namespace: ''
- description: Create or delete a Neutron policy to apply a RBAC rule against
an object.
name: neutron_rbac_policy
namespace: ''
release_date: '2022-01-13'
1.7.0:
changes:
bugfixes:
- identity_user_info - Fix identity user lookup with a domain
- keystone_domain - Move identity domain to use proxy layer
minor_changes:
- openstack_inventory - Adds use_name variable
- port - Add dns_[name,domain] to the port module
- project - Remove project properties tests and support
release_summary: New modules for Ironic and bugfixes
modules:
- description: Retrieve information about Bare Metal nodes from OpenStack an object.
name: baremetal_node_info
namespace: ''
- description: Create, Update, Remove ironic ports from OpenStack
name: baremetal_port
namespace: ''
- description: Retrieve information about Bare Metal ports from OpenStack an object.
name: baremetal_port_info
namespace: ''
release_date: '2022-02-15'
1.7.1:
changes:
bugfixes:
- openstack_inventory - Fix documentation
- quota - Fix description of volumes_types parameter
minor_changes:
- lb_member - Add monitor_[address,port] parameter
release_summary: Bugfixes
release_date: '2022-03-08'
1.7.2:
changes:
bugfixes:
- Fix collection guidelines
release_summary: Bugfixes
release_date: '2022-03-10'
1.8.0:
changes:
bugfixes:
- Add 'all_projects' to server_action module
- Add subnet pool module
- Bumped minimum required OpenStack SDK release to SDK 0.36.0 (Train)
- Changed compute_flavor_info module to use OpenStack SDK's proxy layer
- Dropped deprecated return values in floating_ip_info and assert remaining
fields
- Fix ansible-lint issues for the newest version
- Fix assertion after stack deletion
- Handle aggregate host list set to None
- Reenabled check-import.sh which tests imports to Ansible Galaxy
- Remove old, unsupported parameters from documentation in image_info module
- Router - Remove unneeded 'filter' parameter
- Updated return value docs of compute_service_info module
release_summary: Subnet pool module and bugfixes
modules:
- description: Create or Delete subnet pools from OpenStack.
name: subnet_pool
namespace: ''
release_date: '2022-04-08'
1.9.0:
changes:
bugfixes:
- Added support for specifying a maximum version of the OpenStack SDK
- Constrain filters in compute_service_info to SDK >= 0.53.0
- Drop username from return values of identity_user_info
- Fix logic in routers_info
- Fixed return value disable{d,s}_reason in compute_service_info module
- Fixed return values in compute_service_info module again
- Follow up to bump of minimum required OpenStack SDK release to SDK 0.36.0
(Train)
- Lowered maximum OpenStack SDK version to 0.98.999
- Move dns zone info to use proxy layer
- Refactored catalog_service module
- Refactored endpoint module
- Refactored host_aggregate module
- Refactored identity_domain_info module
- Refactored identity_group_info module
- Refactored identity_role module
- Refactored identity_role_info module
- Refactored identity_user module
- Refactored identity_user_info module
- Refactored image_info module
- Refactored keypair_info module
- Refactored recordset module
- Refactored role_assignment module
- Set owner in image module
- Support description in sg-rule creation
- Warn users about us breaking backward compatibility
known_issues:
- For compatibility with OpenStack SDK >= 0.99.0 use Ansible OpenStack collection
2.0.0 or later which is currently under development.
- Release series 1.x.x of this collection is compatible to OpenStack SDK prior
to 0.99.0 only.
release_summary: 'This release will enforce openstacksdk<0.99.0, has a dozen
modules refactored and several bugs fixed.'
release_date: '2022-08-25'

View File

@@ -0,0 +1,8 @@
- hosts: all
tasks:
- zuul_return:
data:
zuul:
artifacts:
- name: Test log
url: controller/logs/test_output_log.txt

View File

@@ -0,0 +1,78 @@
---
- hosts: all
vars:
collection_path: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
build_collection_path: /tmp/collection_built/
ansible_galaxy_path: "~/.local/bin/ansible-galaxy"
tasks:
- name: Include role for pip
include_role:
name: ensure-pip
- name: Install ansible
pip:
name: ansible-core<2.12
- name: Discover tag version
set_fact:
version_tag: "{{ zuul.tag|default('no_version', true) }}"
- name: Fail if no tag version found
fail:
msg: "No tag was found in Zuul vars!"
when: version_tag == 'no_version'
- name: Create a directory for collection
file:
state: "{{ item }}"
path: "{{ build_collection_path }}"
loop:
- absent
- directory
- name: Set galaxy.yml for right version from tag
lineinfile:
path: '{{ collection_path }}/galaxy.yml'
regexp: '^version:.*'
line: 'version: {{ version_tag }}'
- name: Build collection
command: "{{ ansible_galaxy_path }} collection build --output-path {{ build_collection_path }} --force"
args:
chdir: "{{ collection_path }}"
- name: Publish content to Ansible Galaxy
block:
- name: Create ansible.cfg configuration file tempfile
tempfile:
state: file
suffix: .cfg
register: _ansiblecfg_tmp
- name: Create ansible.cfg configuration file
copy:
dest: "{{ _ansiblecfg_tmp.path }}"
mode: 0600
content: |
[galaxy]
server_list = release_galaxy
[galaxy_server.release_galaxy]
url = {{ ansible_galaxy_info.url }}
token = {{ ansible_galaxy_info.token }}
- name: Include galaxy.yml as vars file
include_vars: "{{ collection_path }}/galaxy.yml"
- name: Publish collection to Ansible Galaxy / Automation Hub
environment:
ANSIBLE_CONFIG: "{{ _ansiblecfg_tmp.path }}"
shell: >-
{{ ansible_galaxy_path }} collection publish -vvv
{{ build_collection_path }}/{{ namespace }}-{{ name }}-{{ version_tag }}.tar.gz
always:
- name: Shred ansible-galaxy credentials
command: "shred {{ _ansiblecfg_tmp.path }}"

View File

@@ -0,0 +1 @@
address_scope_name: "adrdess_scope"

View File

@@ -0,0 +1,40 @@
---
- name: Create address_scope
openstack.cloud.address_scope:
cloud: "{{ cloud }}"
name: "{{ address_scope_name }}"
shared: False
ip_version: "4"
register: create_address_scope
- name: Verify address scope
assert:
that:
- create_address_scope is successful
- create_address_scope is changed
- create_address_scope.address_scope.name == address_scope_name
- create_address_scope.address_scope.is_shared == False
- create_address_scope.address_scope.ip_version == 4
- name: Update address scope
openstack.cloud.address_scope:
cloud: "{{ cloud }}"
name: "{{ address_scope_name }}"
shared: True
ip_version: "4"
register: update_address_scope
- name: Verify updated IPv4 address scope
assert:
that:
- update_address_scope is successful
- update_address_scope is changed
- update_address_scope.address_scope.name == address_scope_name
- update_address_scope.address_scope.is_shared == True
- update_address_scope.address_scope.ip_version == 4
- name: Delete created address scope
openstack.cloud.address_scope:
cloud: "{{ cloud }}"
name: "{{ address_scope_name }}"
state: absent

View File

@@ -0,0 +1,94 @@
---
- name: Delete service test
openstack.cloud.catalog_service:
cloud: "{{ cloud }}"
service_type: test
name: test
state: absent
register: service_delete
- name: Assert changed is set to false
assert:
that:
- not service_delete.changed
- name: Create a service for test
openstack.cloud.catalog_service:
cloud: "{{ cloud }}"
name: "test_service"
state: present
service_type: test_type
description: "Test service"
register: service_test
- name: Verify returned values
assert:
that:
- item in service_test.service
loop:
- description
- id
- enabled
- name
- service_type
- type
- name: Check if the service test was created successfully
openstack.cloud.catalog_service:
cloud: "{{ cloud }}"
service_type: test
name: test
register: service_created
- name: Verify returned values
assert:
that:
- item in service_created.service
loop:
- description
- id
- enabled
- name
- type
- service_type
- name: Update service test
openstack.cloud.catalog_service:
cloud: "{{ cloud }}"
service_type: test
description: "A new description"
is_enabled: False
name: test
register: service_test
- name: Check if description and enabled were updated
assert:
that:
- service_test.service.description == "A new description"
- not (service_test.service.enabled|bool)
- name: Delete service test
openstack.cloud.catalog_service:
cloud: "{{ cloud }}"
service_type: test
name: test
state: absent
register: service_deleted
- name: Verify if service was deleted
assert:
that:
- service_deleted.changed
- name: Delete service test again
openstack.cloud.catalog_service:
cloud: "{{ cloud }}"
service_type: test
name: test
state: absent
register: service_deleted
- name: Assert changed is set to false
assert:
that:
- not service_deleted.changed

View File

@@ -0,0 +1,33 @@
---
- name: List flavors
openstack.cloud.compute_flavor_info:
cloud: "{{ cloud }}"
- name: List flavors with filter
openstack.cloud.compute_flavor_info:
cloud: "{{ cloud }}"
name: "m1.tiny"
register: flavor_name
- name: Check output of list flavors with filter
assert:
that:
- flavor_name.openstack_flavors | length == 1
- name: Assert fields on SDK 0.*
when: sdk_version is version(1.0, '<')
assert:
that:
- '["name", "description", "disk", "is_public", "ram",
"vcpus", "swap", "ephemeral", "is_disabled", "rxtx_factor", "id",
"extra_specs"] | difference(flavor_name.openstack_flavors.0.keys())
| length == 0'
- name: Assert fields on SDK 1.*
when: sdk_version is version(1.0, '>=')
assert:
that:
- '["name", "original_name", "description", "disk", "is_public", "ram",
"vcpus", "swap", "ephemeral", "is_disabled", "rxtx_factor", "id",
"extra_specs"] | difference(flavor_name.openstack_flavors.0.keys())
| length == 0'

View File

@@ -18,53 +18,6 @@
- debug: var=updated_dns_zone
- name: Create a recordset
openstack.cloud.recordset:
cloud: "{{ cloud }}"
zone: "{{ updated_dns_zone.zone.name }}"
name: "{{ recordset_name }}"
recordset_type: "a"
records: "{{ records }}"
register: recordset
- name: Verify recordset info
assert:
that:
- recordset["recordset"].name == recordset_name
- recordset["recordset"].zone_name == dns_zone.zone.name
- recordset["recordset"].records == records
- name: Update a recordset
openstack.cloud.recordset:
cloud: "{{ cloud }}"
zone: "{{ updated_dns_zone.zone.name }}"
name: "{{ recordset_name }}"
recordset_type: "a"
records: "{{ updated_records }}"
description: "new test recordset"
register: updated_recordset
- name: Verify recordset info
assert:
that:
- updated_recordset["recordset"].zone_name == dns_zone.zone.name
- updated_recordset["recordset"].name == recordset_name
- updated_recordset["recordset"].records == updated_records
- name: Delete recordset
openstack.cloud.recordset:
cloud: "{{ cloud }}"
zone: "{{ updated_dns_zone.zone.name }}"
name: "{{ recordset.recordset.name }}"
state: absent
register: deleted_recordset
- name: Verify recordset deletion
assert:
that:
- deleted_recordset is successful
- deleted_recordset is changed
- name: Delete dns zone
openstack.cloud.dns_zone:
cloud: "{{ cloud }}"

View File

@@ -0,0 +1,49 @@
---
- name: Set random prefix
set_fact:
prefix: "{{ 99999999 | random | to_uuid | hash('md5') }}"
- name: Create dns zone
openstack.cloud.dns_zone:
cloud: "{{ cloud }}"
name: "{{ (prefix + '.test.zone.') }}"
email: test@example.net
- name: Getting info about dns zones
openstack.cloud.dns_zone_info:
cloud: "{{ cloud }}"
register: zones
- name: assert result
assert:
that:
- zones is success
- zones is not changed
- zones | length > 0
- name: Getting info about created zone
openstack.cloud.dns_zone_info:
cloud: "{{ cloud }}"
name: "{{ (prefix + '.test.zone.') }}"
register: zone
- name: assert result
assert:
that:
- zone is success
- zone is not changed
- zone.zones | length == 1
- name: Assert keys exist
assert:
that:
- '["action", "attributes", "created_at", "description", "email",
"links", "masters", "name", "pool_id", "project_id", "serial",
"status", "ttl", "type", "updated_at", "id"] |
difference(zone.zones.0.keys()) | length == 0'
- name: Drop created dns zone
openstack.cloud.dns_zone:
cloud: "{{ cloud }}"
name: "{{ (prefix + '.test.zone.') }}"
state: absent

View File

@@ -0,0 +1,65 @@
---
- name: Create a service for compute
openstack.cloud.endpoint:
cloud: "{{ cloud }}"
service: nova
endpoint_interface: internal
url: http://controller:9292
region: RegionOne
state: present
register: endpoint_test
- name: Ensure service was created
assert:
that:
- endpoint_test.endpoint.id is defined
- name: Ensure service have the proper endpoint
assert:
that:
- endpoint_test.endpoint.url == "http://controller:9292"
- name: Create service for compute again
openstack.cloud.endpoint:
cloud: "{{ cloud }}"
service: nova
endpoint_interface: internal
url: http://controller:9292
region: RegionOne
state: present
register: endpoint_again
- name: Ensure changed is false
assert:
that:
- not endpoint_again.changed
- name: Update endpoint url
openstack.cloud.endpoint:
cloud: "{{ cloud }}"
service: nova
endpoint_interface: internal
url: http://controller:9393
region: RegionOne
state: present
register: endpoint_updated
- name: Ensure endpoint was updated
assert:
that:
- endpoint_updated.endpoint.url == "http://controller:9393"
- name: Delete endpoint
openstack.cloud.endpoint:
cloud: "{{ cloud }}"
service: nova
endpoint_interface: internal
url: http://controller:9393
region: RegionOne
state: absent
register: endpoint_deleted
- name: Ensure endpoint was deleted
assert:
that:
- endpoint_deleted.changed

View File

@@ -0,0 +1,466 @@
---
# Prepare environment
- name: Gather information about public network
openstack.cloud.networks_info:
cloud: "{{ cloud }}"
name: public
register: public_network
- name: Assert that public network exists
assert:
that: public_network.openstack_networks|length == 1
- name: Create external network
openstack.cloud.network:
cloud: "{{ cloud }}"
state: present
name: ansible_external
external: true
- name: Create external subnet
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: present
network_name: ansible_external
name: ansible_external_subnet
cidr: 10.6.6.0/24
- name: Create external port 1
openstack.cloud.port:
cloud: "{{ cloud }}"
state: present
name: ansible_external_port1
network: ansible_external
fixed_ips:
- ip_address: 10.6.6.50
- name: Create external port 2
openstack.cloud.port:
cloud: "{{ cloud }}"
state: present
name: ansible_external_port2
network: ansible_external
fixed_ips:
- ip_address: 10.6.6.51
- name: Create internal network
openstack.cloud.network:
cloud: "{{ cloud }}"
state: present
name: ansible_internal
external: false
- name: Create internal subnet
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: present
network_name: ansible_internal
name: ansible_internal_subnet
cidr: 10.7.7.0/24
- name: Create internal port 1
openstack.cloud.port:
cloud: "{{ cloud }}"
state: present
name: ansible_internal_port1
network: ansible_internal
fixed_ips:
- ip_address: 10.7.7.100
- name: Create internal port 2
openstack.cloud.port:
cloud: "{{ cloud }}"
state: present
name: ansible_internal_port2
network: ansible_internal
fixed_ips:
- ip_address: 10.7.7.101
- name: Create internal port 3
openstack.cloud.port:
cloud: "{{ cloud }}"
state: present
name: ansible_internal_port3
network: ansible_internal
fixed_ips:
- ip_address: 10.7.7.102
- name: Create router 1
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: ansible_router1
network: ansible_external
external_fixed_ips:
- subnet: ansible_external_subnet
ip: 10.6.6.10
interfaces:
- net: ansible_internal
subnet: ansible_internal_subnet
portip: 10.7.7.1
# Router 2 is required for the simplest, first test that assigns a new floating IP to server
# from first available external network or nova pool which is DevStack's public network
- name: Create router 2
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: ansible_router2
network: public
interfaces:
- net: ansible_internal
subnet: ansible_internal_subnet
portip: 10.7.7.10
- name: Get all floating ips
openstack.cloud.floating_ip_info:
cloud: "{{ cloud }}"
register: fips
- name: Check if public network has any floating ips
set_fact:
public_network_had_fips: "{{ fips.floating_ips|
selectattr('floating_network_id', '==', public_network.openstack_networks.0.id)|
list|length > 0 }}"
# TODO: Replace with appropriate Ansible module once available
- name: Create a floating ip on public network (required for simplest, first floating ip test)
command: openstack --os-cloud={{ cloud }} floating ip create public
when: not public_network_had_fips
# TODO: Replace with appropriate Ansible module once available
- name: Create floating ip 1 on external network
command: >
openstack --os-cloud={{ cloud }} floating ip create
--subnet ansible_external_subnet
--floating-ip-address 10.6.6.150
ansible_external
when: fips.floating_ips|length == 0 or
"10.6.6.150" not in fips.floating_ips|map(attribute="floating_ip_address")|list
- name: Create server with one nic
openstack.cloud.server:
cloud: "{{ cloud }}"
state: present
name: ansible_server1
image: "{{ image }}"
flavor: m1.tiny
nics:
# one nic only else simple, first floating ip test does not work
- port-name: ansible_internal_port1
auto_ip: false
wait: true
- name: Get info about server
openstack.cloud.server_info:
cloud: "{{ cloud }}"
server: ansible_server1
register: info
- name: Assert one internal port and no floating ips on server 1
# If this assertion fails because server has an public ipv4 address (public_v4) then make sure
# that no floating ip on public network is associated with "10.7.7.100" before running this role
assert:
that:
- info.openstack_servers|length == 1
- info.openstack_servers.0.public_v4|length == 0
- info.openstack_servers.0.public_v6|length == 0
- info.openstack_servers.0.addresses.ansible_internal|length == 1
- info.openstack_servers.0.addresses.ansible_internal|map(attribute="addr")|sort|list == ["10.7.7.100"]
- name: Create server with two nics
openstack.cloud.server:
cloud: "{{ cloud }}"
state: present
name: ansible_server2
image: "{{ image }}"
flavor: m1.tiny
nics:
- port-name: ansible_internal_port2
- port-name: ansible_internal_port3
auto_ip: false
wait: true
- name: Get info about server
openstack.cloud.server_info:
cloud: "{{ cloud }}"
server: ansible_server2
register: info
- name: Assert two internal ports and no floating ips on server 2
assert:
that:
- info.openstack_servers|length == 1
- info.openstack_servers.0.public_v4|length == 0
- info.openstack_servers.0.public_v6|length == 0
- info.openstack_servers.0.addresses.ansible_internal|length == 2
- info.openstack_servers.0.addresses.ansible_internal|map(attribute="addr")|sort|list ==
["10.7.7.101", "10.7.7.102"]
# Tests
- name: Assign new floating IP to server from first available external network or nova pool
openstack.cloud.floating_ip:
cloud: "{{ cloud }}"
state: present
server: ansible_server1
wait: true
- name: Get info about server
openstack.cloud.server_info:
cloud: "{{ cloud }}"
server: ansible_server1
register: info
- name: Assert one internal port and one floating ip on server 1
assert:
that:
- info.openstack_servers.0.addresses.ansible_internal|length == 2
- info.openstack_servers.0.addresses.ansible_internal|map(attribute="OS-EXT-IPS:type")|sort|list ==
["fixed", "floating"]
- name: Detach floating IP from server
openstack.cloud.floating_ip:
cloud: "{{ cloud }}"
state: absent
server: ansible_server1
network: public
floating_ip_address: "{{ (info.openstack_servers.0.addresses.ansible_internal|
selectattr('OS-EXT-IPS:type', '==', 'floating')|map(attribute='addr')|list)[0] }}"
- name: Get info about server
openstack.cloud.server_info:
cloud: "{{ cloud }}"
server: ansible_server1
register: info
# When detaching a floating ip from an instance there might be a delay until openstack.cloud.server_info
# does not list it any more in info.openstack_servers.0.addresses.ansible_internal, so retry if necessary.
retries: 10
delay: 3
until: info.openstack_servers.0.addresses.ansible_internal|length == 1
- name: Assert one internal port on server 1
assert:
that:
- info.openstack_servers.0.addresses.ansible_internal|length == 1
- info.openstack_servers.0.addresses.ansible_internal|map(attribute="addr")|list == ["10.7.7.100"]
- name: Assign floating IP to server
openstack.cloud.floating_ip:
cloud: "{{ cloud }}"
state: present
reuse: yes
server: ansible_server2
network: public
fixed_address: 10.7.7.101
wait: true
- name: Get info about server
openstack.cloud.server_info:
cloud: "{{ cloud }}"
server: ansible_server2
register: info
- name: Assert two internal ports and one floating ip on server 2
assert:
that:
- info.openstack_servers.0.addresses.ansible_internal|length == 3
- info.openstack_servers.0.addresses.ansible_internal|map(attribute="OS-EXT-IPS:type")|sort|list ==
["fixed", "fixed", "floating"]
- name: Assign a second, specific floating IP to server
openstack.cloud.floating_ip:
cloud: "{{ cloud }}"
state: present
reuse: yes
server: ansible_server2
network: ansible_external
fixed_address: 10.7.7.102
floating_ip_address: "10.6.6.150"
# We cannot wait for second floating ip to be attached because OpenStackSDK checks only for first floating ip
# Ref.: https://github.com/openstack/openstacksdk/blob/e0372b72af8c5f471fc17e53434d7a814ca958bd/openstack/cloud/_floating_ip.py#L733
- name: Get info about server
openstack.cloud.server_info:
cloud: "{{ cloud }}"
server: ansible_server2
register: info
# retry because we cannot wait for second floating ip
retries: 10
delay: 3
until: info.openstack_servers.0.addresses.ansible_internal|length == 4
- name: Assert two internal ports and two floating ips on server 2
assert:
that:
- info.openstack_servers.0.addresses.ansible_internal|length == 4
- ("10.6.6.150" in info.openstack_servers.0.addresses.ansible_internal|map(attribute="addr")|sort|list)
- name: Detach second floating IP from server
openstack.cloud.floating_ip:
cloud: "{{ cloud }}"
state: absent
server: ansible_server2
network: ansible_external
floating_ip_address: "10.6.6.150"
- name: Get info about server
openstack.cloud.server_info:
cloud: "{{ cloud }}"
server: ansible_server2
register: info
# When detaching a floating ip from an instance there might be a delay until openstack.cloud.server_info
# does not list it any more in info.openstack_servers.0.addresses.ansible_internal, so retry if necessary.
retries: 10
delay: 3
until: info.openstack_servers.0.addresses.ansible_internal|length == 3
- name: Assert two internal ports and one floating ip on server 2
assert:
that:
- info.openstack_servers.0.addresses.ansible_internal|length == 3
- name: Detach remaining floating IP from server
openstack.cloud.floating_ip:
cloud: "{{ cloud }}"
state: absent
server: ansible_server2
network: public
floating_ip_address: "{{ (info.openstack_servers.0.addresses.ansible_internal|
selectattr('OS-EXT-IPS:type', '==', 'floating')|map(attribute='addr')|list)[0] }}"
- name: Get info about server
openstack.cloud.server_info:
cloud: "{{ cloud }}"
server: ansible_server2
register: info
# When detaching a floating ip from an instance there might be a delay until openstack.cloud.server_info
# does not list it any more in info.openstack_servers.0.addresses.ansible_internal, so retry if necessary.
retries: 10
delay: 3
until: info.openstack_servers.0.addresses.ansible_internal|length == 2
- name: Assert two internal ports on server 2
assert:
that:
- info.openstack_servers.0.addresses.ansible_internal|length == 2
- info.openstack_servers.0.addresses.ansible_internal|map(attribute="addr")|list == ["10.7.7.101", "10.7.7.102"]
# Clean environment
- name: Delete server with two nics
openstack.cloud.server:
cloud: "{{ cloud }}"
state: absent
name: ansible_server2
wait: true
- name: Delete server with one nic
openstack.cloud.server:
cloud: "{{ cloud }}"
state: absent
name: ansible_server1
wait: true
- name: Get all floating ips
openstack.cloud.floating_ip_info:
cloud: "{{ cloud }}"
register: fips
# TODO: Replace with appropriate Ansible module once available
- name: Delete floating ip on public network if we created it
when: not public_network_had_fips
command: >
openstack --os-cloud={{ cloud }} floating ip delete
{{ fips.floating_ips|selectattr('floating_network_id', '==', public_network.openstack_networks.0.id)|
map(attribute="floating_ip_address")|list|join(' ') }}
# TODO: Replace with appropriate Ansible module once available
- name: Delete floating ip 1
command: openstack --os-cloud={{ cloud }} floating ip delete 10.6.6.150
when: fips.floating_ips|length > 0 and "10.6.6.150" in fips.floating_ips|map(attribute="floating_ip_address")|list
- name: Get remaining floating ips on external network
openstack.cloud.floating_ip_info:
cloud: "{{ cloud }}"
floating_network: ansible_external
register: fips
# TODO: Replace with appropriate Ansible module once available
# The first, simple floating ip test might have allocated a floating ip on the external network.
# This floating ip must be removed before external network can be deleted.
- name: Delete remaining floating ips on external network
when: fips.floating_ips|length > 0
command: >
openstack --os-cloud={{ cloud }} floating ip delete
{{ fips.floating_ips|map(attribute="floating_ip_address")|list|join(' ') }}
# Remove routers after floating ips have been detached and disassociated else removal fails with
# Error detaching interface from router ***: Client Error for url: ***,
# Router interface for subnet *** on router *** cannot be deleted,
# as it is required by one or more floating IPs.
- name: Delete router 2
openstack.cloud.router:
cloud: "{{ cloud }}"
state: absent
name: ansible_router2
- name: Delete router 1
openstack.cloud.router:
cloud: "{{ cloud }}"
state: absent
name: ansible_router1
- name: Delete internal port 3
openstack.cloud.port:
cloud: "{{ cloud }}"
state: absent
name: ansible_internal_port3
- name: Delete internal port 2
openstack.cloud.port:
cloud: "{{ cloud }}"
state: absent
name: ansible_internal_port2
- name: Delete internal port 1
openstack.cloud.port:
cloud: "{{ cloud }}"
state: absent
name: ansible_internal_port1
- name: Delete internal subnet
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: absent
name: ansible_internal_subnet
- name: Delete internal network
openstack.cloud.network:
cloud: "{{ cloud }}"
state: absent
name: ansible_internal
- name: Delete external port 2
openstack.cloud.port:
cloud: "{{ cloud }}"
state: absent
name: ansible_external_port2
- name: Delete external port 1
openstack.cloud.port:
cloud: "{{ cloud }}"
state: absent
name: ansible_external_port1
- name: Delete external subnet
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: absent
name: ansible_external_subnet
- name: Delete external network
openstack.cloud.network:
cloud: "{{ cloud }}"
state: absent
name: ansible_external

View File

@@ -0,0 +1,21 @@
---
- name: Getting info about allocated ips
openstack.cloud.floating_ip_info:
cloud: "{{ cloud }}"
register: fips
- name: assert result
assert:
that:
- fips is success
- fips is not changed
- name: assert fields
when: fips.floating_ips|length > 0
assert:
that:
# allow new fields to be introduced but prevent fields from being removed
- '["created_at", "description", "dns_domain", "dns_name", "fixed_ip_address", "floating_ip_address",
"floating_network_id", "id", "name", "port_details", "port_id", "project_id", "qos_policy_id",
"revision_number", "router_id", "status", "subnet_id", "tags", "updated_at"]|
difference(fips.floating_ips.0.keys())|length == 0'

View File

@@ -0,0 +1,10 @@
# Parameter deleted has been renamed to is_deleted in openstacksdk 0.52.0,
# hence we cannot test with this list here.
# Ref.: https://github.com/openstack/openstacksdk/commit/b60915aab3ee0348f3e3cc8aa548f94d2a68b7eb
expected_fields:
- availability_zone
- hosts
- id
- location
- metadata
- name

View File

@@ -0,0 +1,99 @@
---
- name: ensure aggregate doesn't exist before tests
openstack.cloud.host_aggregate:
cloud: "{{ cloud }}"
state: absent
name: test_aggregate
register: aggregate
- block:
- name: create aggregate
openstack.cloud.host_aggregate:
cloud: "{{ cloud }}"
state: present
name: test_aggregate
hosts:
- "{{ ansible_hostname }}"
register: aggregate
- name: assert aggregate is changed
assert:
that: aggregate is changed
- name: assert aggregate fields
assert:
that: item in aggregate.aggregate
loop: "{{ expected_fields }}"
- block:
- name: recreate aggregate
openstack.cloud.host_aggregate:
cloud: "{{ cloud }}"
state: present
name: test_aggregate
hosts:
- "{{ ansible_hostname }}"
register: aggregate
- name: assert aggregate is not changed
assert:
that: aggregate is not changed
- name: assert aggregate fields
assert:
that: item in aggregate.aggregate
loop: "{{ expected_fields }}"
- block:
- name: update aggregate
openstack.cloud.host_aggregate:
cloud: "{{ cloud }}"
state: present
name: test_aggregate
metadata:
ssd: "true"
hosts:
- "{{ ansible_hostname }}"
register: aggregate
- name: assert aggregate is changed
assert:
that: aggregate is changed
- name: assert aggregate fields
assert:
that: item in aggregate.aggregate
loop: "{{ expected_fields }}"
- block:
- name: purge hosts
openstack.cloud.host_aggregate:
cloud: "{{ cloud }}"
state: present
name: test_aggregate
hosts: []
purge_hosts: true
register: aggregate
- name: assert hosts were purged
assert:
that:
- aggregate is changed
- aggregate.aggregate.hosts | length == 0
- name: assert aggregate fields
assert:
that: item in aggregate.aggregate
loop: "{{ expected_fields }}"
- block:
- name: delete aggregate
openstack.cloud.host_aggregate:
cloud: "{{ cloud }}"
state: absent
name: test_aggregate
register: aggregate
- name: assert aggregate is changed
assert:
that: aggregate is changed

View File

@@ -0,0 +1,8 @@
domain_name: domain_info_test_domain
unexistent_domain_name: domain_info_unexistent_domain
disabled_domain_name: test_domain_disabled
domain_info_fields:
- description
- id
- enabled
- name

View File

@@ -0,0 +1,72 @@
---
- block:
- name: Ensure domain does not exist
openstack.cloud.identity_domain:
cloud: "{{ cloud }}"
state: absent
name: "{{ unexistent_domain_name }}"
- name: Get unexistent domain
openstack.cloud.identity_domain_info:
cloud: "{{ cloud }}"
name: "{{ unexistent_domain_name }}"
register: domain_info
- name: Assert no results returned
assert:
that: not domain_info.openstack_domains
- block:
- name: Ensure domain exists
openstack.cloud.identity_domain:
cloud: "{{ cloud }}"
state: present
name: "{{ domain_name }}"
description: "test description"
register: domain
- name: Get domain
openstack.cloud.identity_domain_info:
cloud: "{{ cloud }}"
name: "{{ domain_name }}"
register: domain_info
- name: Assert one result exists
assert:
that: domain_info.openstack_domains | length == 1
- name: Assert fields are present
assert:
that: item in domain_info.openstack_domains[0]
loop: "{{ domain_info_fields }}"
- name: Assert returned value
assert:
that:
- domain_info.openstack_domains[0].description == domain.domain.description
- block:
- name: Get all domains
openstack.cloud.identity_domain_info:
cloud: "{{ cloud }}"
register: domain_info
- block:
- name: Ensure disabled domain exists
openstack.cloud.identity_domain:
cloud: "{{ cloud }}"
state: present
name: "{{ disabled_domain_name }}"
enabled: false
description: "test description"
register: domain
- name: Get filtered domains
openstack.cloud.identity_domain_info:
cloud: "{{ cloud }}"
filters:
enabled: true
register: domain_info
- name: Assert at least one result
assert:
that: domain_info.openstack_domains | length >= 1
- name: Assert returned value
assert:
that: item.enabled == true
loop: "{{ domain_info.openstack_domains }}"

View File

@@ -0,0 +1,74 @@
---
- name: List group by domain_id
openstack.cloud.identity_group_info:
cloud: "{{ cloud }}"
domain: default
register: group_domain
- name: Assert groups were returned
assert:
that:
- group_domain.openstack_groups | length > 0
- group_domain.openstack_groups[0].domain_id == 'default'
- group_domain.openstack_groups[0].id is defined
- group_domain.openstack_groups[0].description is defined
- group_domain.openstack_groups[0].name is defined
- name: List group by domain_id and group
openstack.cloud.identity_group_info:
cloud: "{{ cloud }}"
domain: default
name: admins
register: groups_info
- name: Assert groups by domain_id and grouph returned
assert:
that:
- groups_info.openstack_groups | length > 0
- groups_info.openstack_groups[0].domain_id == 'default'
- groups_info.openstack_groups[0].id is defined
- groups_info.openstack_groups[0].description is defined
- groups_info.openstack_groups[0].name is defined
- name: List group by filter
openstack.cloud.identity_group_info:
cloud: "{{ cloud }}"
domain: default
filters:
name: admins
register: groups_filter
- name: Assert group by filter returned
assert:
that:
- groups_filter.openstack_groups | length > 0
- groups_filter.openstack_groups[0].domain_id == 'default'
- groups_filter.openstack_groups[0].id is defined
- groups_filter.openstack_groups[0].description is defined
- groups_filter.openstack_groups[0].name is defined
- name: Verify returned values of group info
assert:
that:
- item in groups_info.openstack_groups[0]
loop:
- description
- domain_id
- id
- name
- name: List group by group name
openstack.cloud.identity_group_info:
cloud: "{{ cloud }}"
name: admins
register: groups_name
- name: Assert group by name returned
assert:
that:
- groups_name.openstack_groups | length > 0
- groups_name.openstack_groups[0].domain_id == 'default'
- groups_name.openstack_groups[0].id is defined
- groups_name.openstack_groups[0].description is defined
- groups_name.openstack_groups[0].name is defined
- groups_name.openstack_groups[0].name == 'admins'

View File

@@ -0,0 +1,5 @@
role_name: ansible_keystone_role
expected_fields:
- domain_id
- id
- name

View File

@@ -0,0 +1,83 @@
---
- name: Cleanup before tests
block:
- openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: absent
name: "{{ role_name }}"
- block:
- name: Delete unexistent role
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: absent
name: "{{ role_name }}"
register: role
- name: Assert role didn't change
assert:
that: role is not changed
- block:
- name: Create keystone role
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: present
name: "{{ role_name }}"
register: role
- name: Try to get role
openstack.cloud.identity_role_info:
cloud: "{{ cloud }}"
name: "{{ role_name }}"
register: roles
- name: Assert role found
assert:
that:
- roles.openstack_roles | length == 1
- name: Assert role changed
assert:
that: role is changed
- name: Assert return fields
assert:
that: item in role['role']
loop: "{{ expected_fields }}"
- name: Assert return value
assert:
that: role['role']['name'] == role_name
- name: Assert retrieved values
assert:
that: roles.openstack_roles[0].name == role_name
- block:
- name: Create existing keystone role
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: present
name: "{{ role_name }}"
register: role
- name: Assert role not changed
assert:
that: role is not changed
- name: Assert return fields
assert:
that: item in role['role']
loop: "{{ expected_fields }}"
- block:
- name: Delete keystone role
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: absent
name: "{{ role_name }}"
register: role
- name: Assert role changed
assert:
that: role is changed
- name: Try to get role
openstack.cloud.identity_role_info:
cloud: "{{ cloud }}"
name: "{{ role_name }}"
register: roles
- name: Assert no role found
assert:
that:
- roles.openstack_roles | length == 0

View File

@@ -0,0 +1,62 @@
- name: Ensure role does not exist before tests
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: absent
name: test_role
- name: Get unexistent role
openstack.cloud.identity_role_info:
cloud: "{{ cloud }}"
name: test_role
register: roleinfo
- debug:
var: roleinfo
- name: Assert that no results were returned
assert:
that: not roleinfo.openstack_roles
- name: Create keystone role
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: present
name: test_role
- name: Create second role
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: present
name: test_role2
- name: Get role by name
openstack.cloud.identity_role_info:
cloud: "{{ cloud }}"
name: test_role
register: roleinfo
- debug:
var: roleinfo
- name: Assert that only one result was returned
assert:
that: roleinfo.openstack_roles | length == 1
- name: Assert that roleinfo has fields
assert:
that: item in roleinfo.openstack_roles[0]
loop:
- domain_id
- id
- name
- name: Post-test cleanup
block:
- name: Clean up roles
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: absent
name: "{{ item }}"
loop:
- test_role
- test_role2

View File

@@ -0,0 +1,9 @@
os_identity_user_fields:
- default_project_id
- description
- domain_id
- email
- enabled
- id
- name
- username

View File

@@ -0,0 +1,197 @@
---
- name: setup
block:
- name: Delete user before running tests
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: absent
name: "{{ item }}"
loop:
- ansible_user
- ansible_user2
register: user
- block:
- name: Delete unexistent user
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: absent
name: ansible_user
register: user
- name: Ensure user was not changed
assert:
that: user is not changed
- block:
- name: Create a user without a password
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
email: ansible.user@nowhere.net
domain: default
default_project: demo
register: user
- name: Ensure user was changed
assert:
that: user is changed
- name: Ensure user has fields
assert:
that: item in user['user']
loop: "{{ os_identity_user_fields }}"
- name: Fail when update_password is always but no password specified
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
update_password: always
email: ansible.user@nowhere.net
domain: default
default_project: demo
register: user
ignore_errors: yes
- assert:
that: user.msg == "update_password is always but a password value is missing"
- name: Delete user
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: absent
name: ansible_user
- block:
- name: Create user with a password
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
password: secret
email: ansible.user@nowhere.net
update_password: on_create
domain: default
default_project: demo
register: user
- name: Assert user has fields
assert:
that: item in user['user']
loop: "{{ os_identity_user_fields }}"
- block:
- name: Create identical user
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
password: secret
email: ansible.user@nowhere.net
update_password: on_create
domain: default
default_project: demo
register: user
- name: Assert user was not changed
assert:
that: user is not changed
- name: Assert user has fields
assert:
that: item in user['user']
loop: "{{ os_identity_user_fields }}"
- block:
- name: Update user with password
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
password: secret2
email: updated.ansible.user@nowhere.net
register: user
- name: Ensure user was changed
assert:
that: user is changed
- name: Ensure user has fields
assert:
that: item in user['user']
loop: "{{ os_identity_user_fields }}"
- name: Update user without password and update_password set to always
block:
- openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
update_password: always
email: updated.ansible.user@nowhere.net
register: user
ignore_errors: yes
- assert:
that: user.msg == "update_password is always but a password value is missing"
- block:
- name: Ensure user with update_password set to on_create
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
update_password: on_create
password: secret3
email: updated.ansible.user@nowhere.net
register: user
- name: Ensure user was not changed
assert:
that: user is not changed
- block:
- name: Ensure user with update_password set to always
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
update_password: always
password: secret3
email: updated.ansible.user@nowhere.net
register: user
- name: Ensure user was changed
assert:
that: user is changed
- block:
- name: Create user without a password
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user2
password: secret
email: ansible.user2@nowhere.net
update_password: on_create
domain: default
default_project: demo
register: user
- name: Assert user has fields
assert:
that: item in user['user']
loop: "{{ os_identity_user_fields }}"
- block:
- name: Delete user
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: absent
name: ansible_user
- name: Ensure user was changed
assert:
that: user is changed

View File

@@ -0,0 +1,9 @@
os_expected_user_info_fields:
- default_project_id
- description
- domain_id
- email
- enabled
- id
- name
- username

View File

@@ -0,0 +1,69 @@
- name: Ensure user does not exist before tests
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: absent
name: ansible_user
- block:
- name: Get unexistent user
openstack.cloud.identity_user_info:
cloud: "{{ cloud }}"
name: ansible_user
register: userinfo
- name: Ensure nothing was returned
assert:
that: not userinfo.openstack_users
- block:
- name: Create user
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
password: secret
email: ansible.user@nowhere.net
domain: default
default_project: demo
register: user
- name: Create second user
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user2
password: secret
email: ansible.user2@nowhere.net
domain: default
default_project: demo
register: user
- name: Get first user info
openstack.cloud.identity_user_info:
cloud: "{{ cloud }}"
name: ansible_user
register: userinfo
- name: Assert only one result exists
assert:
that: "{{ userinfo.openstack_users | length }} == 1"
- name: Assert userinfo has fields
assert:
that: item in userinfo.openstack_users[0]
loop: "{{ os_expected_user_info_fields }}"
- block:
- name: Get all users
openstack.cloud.identity_user_info:
cloud: "{{ cloud }}"
register: userinfo
- name: Assert results were returned
assert:
that: "{{ userinfo.openstack_users | length }} > 0"
- name: Post-test cleanup
block:
- name: Ensure users do not exist
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: absent
name: "{{ item }}"
loop:
- ansible_user
- ansible_user2

View File

@@ -1 +1,4 @@
image_name: ansible_image
image_tags:
- test
- ansible

View File

@@ -13,6 +13,7 @@
name: "{{ image_name }}"
filename: "{{ tmp_file.stdout }}"
disk_format: raw
tags: "{{ image_tags }}"
register: image
- name: Get details of created image
@@ -24,7 +25,8 @@
- name: Verify image info
assert:
that:
- "image_info_result.openstack_image.name == image_name"
- "image_info_result.openstack_images[0].name == image_name"
- "image_info_result.openstack_images[0].tags | sort == image_tags | sort"
- name: Delete raw image (defaults)
openstack.cloud.image:
@@ -55,11 +57,6 @@
state: absent
name: "{{ image_name }}"
- name: Delete test image file
file:
name: "{{ tmp_file.stdout }}"
state: absent
- name: Try to get details of deleted image
openstack.cloud.image_info:
cloud: "{{ cloud }}"
@@ -69,4 +66,83 @@
- name: Verify image is deleted
assert:
that:
- not deleted_image_info_result.openstack_image
- not deleted_image_info_result.openstack_images
- name: Create owner project
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: image_owner_project
description: Project owning test image
domain_id: default
enabled: True
register: owner_project
- name: Create raw image (owner by project name)
openstack.cloud.image:
cloud: "{{ cloud }}"
state: present
name: "{{ image_name }}"
filename: "{{ tmp_file.stdout }}"
disk_format: raw
tags: "{{ image_tags }}"
project: image_owner_project
register: image
- name: Get details of created image (owner by project name)
openstack.cloud.image_info:
cloud: "{{ cloud }}"
image: "{{ image_name }}"
register: image_info_result
- name: Verify image owner (owner by project name)
assert:
that:
- image_info_result.openstack_images[0].owner == owner_project.project.id
- name: Delete raw image (owner by project name)
openstack.cloud.image:
cloud: "{{ cloud }}"
state: absent
name: "{{ image_name }}"
- name: Create raw image (owner by project name and domain name)
openstack.cloud.image:
cloud: "{{ cloud }}"
state: present
name: "{{ image_name }}"
filename: "{{ tmp_file.stdout }}"
disk_format: raw
tags: "{{ image_tags }}"
project: image_owner_project
project_domain: default
register: image
- name: Get details of created image (owner by project name and domain name)
openstack.cloud.image_info:
cloud: "{{ cloud }}"
image: "{{ image_name }}"
register: image_info_result
- name: Verify image owner (owner by project name and domain name)
assert:
that:
- image_info_result.openstack_images[0].owner == owner_project.project.id
- name: Delete raw image (owner by project name and domain name)
openstack.cloud.image:
cloud: "{{ cloud }}"
state: absent
name: "{{ image_name }}"
- name: Delete owner project
openstack.cloud.project:
cloud: "{{ cloud }}"
state: absent
name: image_owner_project
domain_id: default
- name: Delete test image file
file:
name: "{{ tmp_file.stdout }}"
state: absent

View File

@@ -0,0 +1,23 @@
expected_fields:
- checksum
- container_format
- created_at
- direct_url
- disk_format
- file
- id
- locations
- metadata
- min_disk
- min_ram
- name
- os_hidden
- owner
- properties
- schema
- size
- status
- tags
- updated_at
- virtual_size
- visibility

View File

@@ -0,0 +1,11 @@
---
- name: List all images # This will list at least the default cirros image of devstack
openstack.cloud.image_info:
cloud: "{{ cloud }}"
register: image_list_result
- name: Assert fields
assert:
that:
- item in image_list_result.openstack_images.0.keys()
loop: "{{ expected_fields }}"

View File

@@ -1 +1,11 @@
keypair_name: shade_keypair
expected_fields:
- created_at
- fingerprint
- id
- is_deleted
- name
- private_key
- public_key
- type
- user_id

View File

@@ -1,13 +1,17 @@
---
- name: Create keypair (non-existing)
openstack.cloud.keypair:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: present
register:
keypair
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: present
register: keypair
- name: Get list of keypairs
- name: Get list of all keypairs
openstack.cloud.keypair_info:
cloud: "{{ cloud }}"
register: keypairs_all
- name: Get list of keypairs with filter
openstack.cloud.keypair_info:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
@@ -18,17 +22,35 @@
that:
- keypairs['openstack_keypairs']|length == 1
- name: Assert fields
assert:
that:
- item in keypairs.openstack_keypairs.0.keys()
loop: "{{ expected_fields }}"
# This assert verifies that Ansible is capable serializing data returned by SDK
- name: Ensure private key is returned
- name: Ensure public key is returned
assert:
that:
- keypair.key.public_key is defined and keypair.key.public_key
- name: Create another keypair
openstack.cloud.keypair:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}-2"
state: present
- name: Delete keypair (non-existing)
openstack.cloud.keypair:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: absent
cloud: "{{ cloud }}"
name: "non-existing"
state: absent
- name: Delete keypair
openstack.cloud.keypair:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: absent
- name: Get list of keypairs
openstack.cloud.keypair_info:
@@ -41,18 +63,24 @@
that:
- keypairs['openstack_keypairs']|length == 0
- name: Delete another keypair
openstack.cloud.keypair:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}-2"
state: absent
- name: Generate test key file
user:
name: "{{ ansible_env.USER }}"
generate_ssh_key: yes
ssh_key_file: .ssh/shade_id_rsa
name: "{{ ansible_env.USER }}"
generate_ssh_key: yes
ssh_key_file: .ssh/shade_id_rsa
- name: Create keypair (file)
openstack.cloud.keypair:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: present
public_key_file: "{{ ansible_env.HOME }}/.ssh/shade_id_rsa.pub"
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: present
public_key_file: "{{ ansible_env.HOME }}/.ssh/shade_id_rsa.pub"
- name: Get list of keypairs
openstack.cloud.keypair_info:
@@ -67,9 +95,9 @@
- name: Delete keypair (file)
openstack.cloud.keypair:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: absent
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: absent
- name: Get list of keypairs
openstack.cloud.keypair_info:
@@ -84,10 +112,10 @@
- name: Create keypair (key)
openstack.cloud.keypair:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: present
public_key: "{{ lookup('file', '~/.ssh/shade_id_rsa.pub') }}"
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: present
public_key: "{{ lookup('file', '~/.ssh/shade_id_rsa.pub') }}"
- name: Get list of keypairs
openstack.cloud.keypair_info:
@@ -102,9 +130,9 @@
- name: Delete keypair (key)
openstack.cloud.keypair:
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: absent
cloud: "{{ cloud }}"
name: "{{ keypair_name }}"
state: absent
- name: Get list of keypairs
openstack.cloud.keypair_info:
@@ -119,10 +147,10 @@
- name: Delete test key pub file
file:
name: "{{ ansible_env.HOME }}/.ssh/shade_id_rsa.pub"
state: absent
name: "{{ ansible_env.HOME }}/.ssh/shade_id_rsa.pub"
state: absent
- name: Delete test key pvt file
file:
name: "{{ ansible_env.HOME }}/.ssh/shade_id_rsa"
state: absent
name: "{{ ansible_env.HOME }}/.ssh/shade_id_rsa"
state: absent

View File

@@ -1,19 +1,36 @@
---
- name: Create keystone domain
openstack.cloud.identity_domain:
cloud: "{{ cloud }}"
state: present
name: "{{ domain_name }}"
description: "test description"
cloud: "{{ cloud }}"
state: present
name: "{{ domain_name }}"
description: "test description"
register: os_domain
- name: Test output
assert:
that:
- "'domain' in os_domain"
- os_domain.domain.name == "{{ domain_name }}"
- >-
('enabled' in os_domain.domain.keys() and os_domain.domain['enabled']|bool) or
('is_enabled' in os_domain.domain and os_domain.domain['is_enabled']|bool)
- os_domain.domain.description == "test description"
- name: Update keystone domain
openstack.cloud.identity_domain:
cloud: "{{ cloud }}"
name: "{{ domain_name }}"
description: "updated description"
cloud: "{{ cloud }}"
name: "{{ domain_name }}"
description: "updated description"
register: os_domain_updated
- name: Test output
assert:
that:
- os_domain_updated.domain.description == "updated description"
- name: Delete keystone domain
openstack.cloud.identity_domain:
cloud: "{{ cloud }}"
state: absent
name: "{{ domain_name }}"
cloud: "{{ cloud }}"
state: absent
name: "{{ domain_name }}"

View File

@@ -1 +0,0 @@
role_name: ansible_keystone_role

View File

@@ -1,35 +0,0 @@
---
- name: Create keystone role
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: present
name: "{{ role_name }}"
- name: List keystone roles
openstack.cloud.identity_role_info:
cloud: "{{ cloud }}"
register: roles
- name: Check roles
assert:
that:
- roles.openstack_roles | length > 0
- "'{{ role_name }}' in (roles.openstack_roles | map(attribute='name') | list)"
- name: List keystone roles by name
openstack.cloud.identity_role_info:
cloud: "{{ cloud }}"
name: "{{ role_name}}"
register: roles1
- name: Check roles
assert:
that:
- roles1.openstack_roles | length == 1
- roles1.openstack_roles[0]['name'] == role_name
- name: Delete keystone role
openstack.cloud.identity_role:
cloud: "{{ cloud }}"
state: absent
name: "{{ role_name }}"

View File

@@ -0,0 +1,85 @@
---
# General run of tests
# - Prepare projects/network objects
# - Create rbac object
# - Get rbac object info
# - Verify RBAC object match
# - Delete rbac object
# - Get rbac object info
# - Verify RBAC object deleted
- name: Create source project
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: source_project
description: Source project for network RBAC test
domain_id: default
enabled: True
register: source_project
- name: Create network - generic
openstack.cloud.network:
cloud: "{{ cloud }}"
name: "{{ network_name }}"
state: present
project: "{{ source_project.project.id }}"
shared: false
external: "{{ network_external }}"
register: network
- name: Create target project
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: Target project for network RBAC test
domain_id: default
enabled: True
register: target_project
- name: Create a new network RBAC policy
openstack.cloud.neutron_rbac_policy:
cloud: "{{ cloud }}"
object_id: "{{ network.network.id }}"
object_type: 'network'
action: 'access_as_shared'
target_project_id: "{{ target_project.project.id }}"
project_id: "{{ source_project.project.id }}"
register: rbac_policy
- name: Get all rbac policies for {{ source_project.project.name }} - after creation
openstack.cloud.neutron_rbac_policies_info:
cloud: "{{ cloud }}"
project_id: "{{ source_project.project.id }}"
register: rbac_policies
- name: Capture all existing policy IDs
set_fact:
rbac_policy_ids: "{{ rbac_policies.policies | map(attribute='id') | list }}"
- name: Verify policy exists - after creation
assert:
that:
- rbac_policy.policy.id in rbac_policy_ids
- name: Delete RBAC policy
openstack.cloud.neutron_rbac_policy:
cloud: "{{ cloud }}"
policy_id: "{{ rbac_policy.policy.id }}"
state: absent
- name: Get all rbac policies for {{ source_project.project.name }} - after deletion
openstack.cloud.neutron_rbac_policies_info:
cloud: "{{ cloud }}"
project_id: "{{ source_project.project.id }}"
register: rbac_policies_remaining
- name: Capture all remaining policy IDs
set_fact:
remaining_rbac_policy_ids: "{{ rbac_policies_remaining.policies | map(attribute='id') | list }}"
- name: Verify policy does not exist - after deletion
assert:
that:
- not rbac_policy.policy.id in remaining_rbac_policy_ids

View File

@@ -0,0 +1,33 @@
---
- name: Get nova compute services info
openstack.cloud.compute_service_info:
cloud: "{{ cloud }}"
register: result
failed_when: "result.openstack_compute_services | length <= 0"
- name: Assert fields on OpenStack SDK before 0.53
when: sdk_version is version(0.53, '<')
assert:
that:
- '["availability_zone", "binary", "disables_reason",
"host", "name", "state", "status", "id"] |
difference(result.openstack_compute_services.0.keys()) | length == 0'
- name: Assert fields on OpenStack SDK 0.53 and later
when: sdk_version is version(0.53, '>=')
assert:
that:
- '["availability_zone", "binary", "disabled_reason", "is_forced_down",
"host", "name", "state", "status", "updated_at", "id"] |
difference(result.openstack_compute_services.0.keys()) | length == 0'
- name: Filter compute services. Supported since OpenStack SDK 0.53.0 (Wallaby).
when: sdk_version is version(0.53, '>=')
block:
- name: Get nova compute services info
openstack.cloud.compute_service_info:
cloud: "{{ cloud }}"
binary: "nova-compute"
register: result
failed_when: "result.openstack_compute_services | length <= 0"

View File

@@ -41,4 +41,4 @@
- assert:
that:
- stacks is defined
- stacks['stacks']|length == 0
- (stacks['stacks']|length == 0) or (stacks['stacks'][0]['status'] == 'DELETE_COMPLETE')

View File

@@ -60,6 +60,26 @@
state: absent
name: "{{ port_name }}"
- name: Create port (with dns_name, dns_domain)
openstack.cloud.port:
cloud: "{{ cloud }}"
state: present
name: "{{ port_name }}"
network: "{{ network_name }}"
fixed_ips:
- ip_address: 10.5.5.69
dns_name: "dns-port-name"
dns_domain: "example.com."
register: port
- debug: var=port
- name: Delete port (with dns name,domain)
openstack.cloud.port:
cloud: "{{ cloud }}"
state: absent
name: "{{ port_name }}"
- name: Create port (with allowed_address_pairs and extra_dhcp_opts)
openstack.cloud.port:
cloud: "{{ cloud }}"
@@ -101,7 +121,7 @@
- name: Assert binding:profile exists in created port
assert:
that: "port.port['binding:profile']"
that: "port.port['binding_profile']"
- debug: var=port

View File

@@ -1,2 +0,0 @@
dummy_value: 'test-value'
dummy_value_updated: 'test-value-updated'

View File

@@ -1,142 +0,0 @@
---
- name: 'Create project with properties - CHECK_MODE'
check_mode: yes
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: dummy description
domain_id: default
enabled: True
properties:
dummy_key: '{{ dummy_value }}'
register: create_project_cm
- assert:
that:
- create_project_cm is successful
- create_project_cm is changed
- name: 'Create project with properties'
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: dummy description
domain_id: default
enabled: True
properties:
dummy_key: '{{ dummy_value }}'
register: create_project
- assert:
that:
- create_project is successful
- create_project is changed
- '"project" in create_project'
- '"dummy_key" in create_project["project"]'
- create_project["project"].dummy_key == dummy_value
- name: 'Create project with properties (retry - no change) - CHECK_MODE'
check_mode: yes
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: dummy description
domain_id: default
enabled: True
properties:
dummy_key: '{{ dummy_value }}'
register: create_project_retry_cm
- assert:
that:
- create_project_retry_cm is successful
- create_project_retry_cm is not changed
- name: 'Create project with properties (retry - no change)'
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: dummy description
domain_id: default
enabled: True
properties:
dummy_key: '{{ dummy_value }}'
register: create_project_retry
- assert:
that:
- create_project_retry is successful
- create_project_retry is not changed
- '"project" in create_project_retry'
- '"dummy_key" in create_project_retry["project"]'
- create_project_retry["project"].dummy_key == dummy_value
- name: 'Update project with properties - CHECK_MODE'
check_mode: yes
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: new description
properties:
dummy_key: '{{ dummy_value_updated }}'
register: updated_project_cm
- assert:
that:
- updated_project_cm is successful
- updated_project_cm is changed
- name: 'Update project with properties'
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: new description
properties:
dummy_key: '{{ dummy_value_updated }}'
register: updated_project
- assert:
that:
- updated_project is successful
- updated_project is changed
- '"project" in updated_project'
- '"dummy_key" in updated_project["project"]'
- updated_project["project"].dummy_key == dummy_value_updated
- name: 'Update project with properties (retry - no change) - CHECK_MODE'
check_mode: yes
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: new description
properties:
dummy_key: '{{ dummy_value_updated }}'
register: updated_project_retry_cm
- assert:
that:
- updated_project_retry_cm is successful
- updated_project_retry_cm is not changed
- name: 'Update project with properties (retry - no change)'
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: new description
properties:
dummy_key: '{{ dummy_value_updated }}'
register: updated_project_retry
- assert:
that:
- updated_project_retry is successful
- updated_project_retry is not changed
- '"project" in updated_project_retry'
- '"dummy_key" in updated_project_retry["project"]'
- updated_project_retry["project"].dummy_key == dummy_value_updated
- name: Delete project with properties
openstack.cloud.project:
cloud: "{{ cloud }}"
state: absent
name: ansible_project

View File

@@ -0,0 +1,19 @@
dns_zone_name: test.dns.zone.
recordset_name: testrecordset.test.dns.zone.
records: ['10.0.0.0']
updated_records: ['10.1.1.1']
recordset_fields:
- action
- created_at
- description
- id
- links
- name
- project_id
- records
- status
- ttl
- type
- zone_id
- zone_name

View File

@@ -0,0 +1,112 @@
- name: Ensure DNS zone not present before tests
openstack.cloud.dns_zone:
cloud: "{{ cloud }}"
name: "{{ dns_zone_name }}"
zone_type: "primary"
email: test@example.net
state: absent
- name: Ensure dns zone
openstack.cloud.dns_zone:
cloud: "{{ cloud }}"
name: "{{ dns_zone_name }}"
zone_type: "primary"
email: test@example.net
register: dns_zone
- name: Create a recordset
openstack.cloud.recordset:
cloud: "{{ cloud }}"
zone: "{{ dns_zone.zone.name }}"
name: "{{ recordset_name }}"
recordset_type: "a"
records: "{{ records }}"
register: recordset
- name: Verify recordset info
assert:
that:
- recordset is changed
- recordset["recordset"].name == recordset_name
- recordset["recordset"].zone_name == dns_zone.zone.name
- recordset["recordset"].records == records
- name: Assert recordset fields
assert:
that: item in recordset.recordset
loop: "{{ recordset_fields }}"
- name: Create identical recordset
openstack.cloud.recordset:
cloud: "{{ cloud }}"
zone: "{{ dns_zone.zone.name }}"
name: "{{ recordset_name }}"
recordset_type: "a"
records: "{{ records }}"
register: recordset
- name: Assert recordset not changed
assert:
that:
- recordset is not changed
- name: Assert recordset fields
assert:
that: item in recordset.recordset
loop: "{{ recordset_fields }}"
- name: Update a recordset
openstack.cloud.recordset:
cloud: "{{ cloud }}"
zone: "{{ dns_zone.zone.name }}"
name: "{{ recordset_name }}"
recordset_type: "a"
records: "{{ updated_records }}"
description: "new test recordset"
register: recordset
- name: Verify recordset info
assert:
that:
- recordset is changed
- recordset["recordset"].zone_name == dns_zone.zone.name
- recordset["recordset"].name == recordset_name
- recordset["recordset"].records == updated_records
- name: Assert recordset fields
assert:
that: item in recordset.recordset
loop: "{{ recordset_fields }}"
- name: Delete recordset
openstack.cloud.recordset:
cloud: "{{ cloud }}"
zone: "{{ dns_zone.zone.name }}"
name: "{{ recordset.recordset.name }}"
state: absent
register: deleted_recordset
- name: Verify recordset deletion
assert:
that:
- deleted_recordset is successful
- deleted_recordset is changed
- name: Delete unexistent recordset
openstack.cloud.recordset:
cloud: "{{ cloud }}"
zone: "{{ dns_zone.zone.name }}"
name: "{{ recordset.recordset.name }}"
state: absent
register: deleted_recordset
- name: Verify recordset deletion
assert:
that:
- deleted_recordset is not changed
- name: Delete dns zone
openstack.cloud.dns_zone:
cloud: "{{ cloud }}"
name: "{{ dns_zone.zone.name }}"
state: absent

View File

@@ -0,0 +1,47 @@
---
- name: Create project
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: ansible_project
description: dummy description
domain_id: default
enabled: True
register: project
- name: Grant an admin role on the user admin in the project ansible_project
openstack.cloud.role_assignment:
cloud: "{{ cloud }}"
domain: default
project: ansible_project
role: admin
user: admin
- name: Grant an admin role on the user admin in the project ansible_project again
openstack.cloud.role_assignment:
cloud: "{{ cloud }}"
domain: default
project: ansible_project
role: admin
user: admin
register: grant_again
- name: Ensure grant again doesn't change anything
assert:
that:
- not grant_again.changed
- name: Revoke the admin role on the user admin in the project ansible_project
openstack.cloud.role_assignment:
cloud: "{{ cloud }}"
domain: default
project: ansible_project
role: admin
state: absent
user: admin
- name: Delete project
openstack.cloud.project:
cloud: "{{ cloud }}"
state: absent
name: ansible_project

View File

@@ -15,6 +15,30 @@
name: shade_subnet1
cidr: 10.7.7.0/24
- name: Create subnet2
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: present
network_name: "{{ network_name }}"
name: shade_subnet2
cidr: 10.8.8.0/24
- name: Create subnet3
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: present
network_name: "{{ network_name }}"
name: shade_subnet3
cidr: 10.9.9.0/24
- name: Create subnet4
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: present
network_name: "{{ network_name }}"
name: shade_subnet4
cidr: 10.10.10.0/24
- name: Create router
openstack.cloud.router:
cloud: "{{ cloud }}"
@@ -29,6 +53,19 @@
interfaces:
- shade_subnet1
- name: Update router (add interface) again
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- shade_subnet1
register: result
- name: Assert idempotent module
assert:
that: result is not changed
- name: Gather routers info
openstack.cloud.routers_info:
cloud: "{{ cloud }}"
@@ -43,6 +80,93 @@
- "result.openstack_routers.0.name == router_name"
- (result.openstack_routers.0.interfaces_info|length) == 1
- name: Update router (change interfaces)
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- net: '{{ network_name }}'
subnet: shade_subnet2
portip: 10.8.8.1
- net: '{{ network_name }}'
subnet: shade_subnet3
- shade_subnet4
- name: Update router (change interfaces) again
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- net: '{{ network_name }}'
subnet: shade_subnet2
portip: 10.8.8.1
- net: '{{ network_name }}'
subnet: shade_subnet3
- shade_subnet4
register: result
- name: Assert idempotent module
assert:
that: result is not changed
- name: Gather routers info
openstack.cloud.routers_info:
cloud: "{{ cloud }}"
name: "{{ router_name }}"
filters:
admin_state_up: true
register: result
- name: Verify routers info
assert:
that:
- "result.openstack_routers.0.name == router_name"
- (result.openstack_routers.0.interfaces_info|length) == 3
- result.openstack_routers.0.interfaces_info|map(attribute='ip_address')|sort|list ==
['10.10.10.1', '10.8.8.1', '10.9.9.1']
- name: Update router (remove interface)
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- net: '{{ network_name }}'
subnet: shade_subnet1
portip: 10.7.7.1
- name: Update router (remove interface) again
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- net: '{{ network_name }}'
subnet: shade_subnet1
portip: 10.7.7.1
register: result
- name: Assert idempotent module
assert:
that: result is not changed
- name: Gather routers info
openstack.cloud.routers_info:
cloud: "{{ cloud }}"
name: "{{ router_name }}"
filters:
admin_state_up: true
register: result
- name: Verify routers info
assert:
that:
- "result.openstack_routers.0.name == router_name"
- (result.openstack_routers.0.interfaces_info|length) == 1
- result.openstack_routers.0.interfaces_info.0.ip_address == '10.7.7.1'
# Admin operation
- name: Create external network
openstack.cloud.network:
@@ -53,12 +177,12 @@
when:
- network_external
- name: Create subnet2
- name: Create subnet5
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: present
network_name: "{{ external_network_name }}"
name: shade_subnet2
name: shade_subnet5
cidr: 10.6.6.0/24
when:
- network_external
@@ -88,6 +212,142 @@
- "result.openstack_routers.0.name == router_name"
- (result.openstack_routers.0.interfaces_info|length) == 1
- name: Update router (change external fixed ips)
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- shade_subnet1
network: "{{ external_network_name }}"
external_fixed_ips:
- subnet: shade_subnet5
ip: 10.6.6.100
when:
- network_external
- name: Gather routers info
openstack.cloud.routers_info:
cloud: "{{ cloud }}"
name: "{{ router_name }}"
filters:
admin_state_up: true
register: result
- name: Verify routers info
assert:
that:
- "result.openstack_routers.0.name == router_name"
- (result.openstack_routers.0.external_gateway_info.external_fixed_ips|length) == 1
- result.openstack_routers.0.external_gateway_info.external_fixed_ips.0.ip_address == "10.6.6.100"
when:
- network_external
- name: Update router (add external fixed ips)
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- shade_subnet1
network: "{{ external_network_name }}"
external_fixed_ips:
- subnet: shade_subnet5
ip: 10.6.6.100
- subnet: shade_subnet5
ip: 10.6.6.101
when:
- network_external
- name: Update router (add external fixed ips) again
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- shade_subnet1
network: "{{ external_network_name }}"
external_fixed_ips:
- subnet: shade_subnet5
ip: 10.6.6.100
- subnet: shade_subnet5
ip: 10.6.6.101
when:
- network_external
register: result
- name: Assert idempotent module
assert:
that: result is not changed
- name: Gather routers info
openstack.cloud.routers_info:
cloud: "{{ cloud }}"
name: "{{ router_name }}"
filters:
admin_state_up: true
register: result
- name: Verify routers info
assert:
that:
- "result.openstack_routers.0.name == router_name"
- (result.openstack_routers.0.external_gateway_info.external_fixed_ips|length) == 2
- result.openstack_routers.0.external_gateway_info.external_fixed_ips|map(attribute='ip_address')|sort|list ==
["10.6.6.100", "10.6.6.101"]
when:
- network_external
- name: Update router (remove external fixed ips)
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- shade_subnet1
network: "{{ external_network_name }}"
external_fixed_ips:
- subnet: shade_subnet5
ip: 10.6.6.101
when:
- network_external
- name: Update router (remove external fixed ips) again
openstack.cloud.router:
cloud: "{{ cloud }}"
state: present
name: "{{ router_name }}"
interfaces:
- shade_subnet1
network: "{{ external_network_name }}"
external_fixed_ips:
- subnet: shade_subnet5
ip: 10.6.6.101
when:
- network_external
register: result
- name: Assert idempotent module
assert:
that: result is not changed
- name: Gather routers info
openstack.cloud.routers_info:
cloud: "{{ cloud }}"
name: "{{ router_name }}"
filters:
admin_state_up: true
register: result
- name: Verify routers info
assert:
that:
- "result.openstack_routers.0.name == router_name"
- (result.openstack_routers.0.external_gateway_info.external_fixed_ips|length) == 1
- result.openstack_routers.0.external_gateway_info.external_fixed_ips.0.ip_address == "10.6.6.101"
when:
- network_external
- name: Delete router
openstack.cloud.router:
cloud: "{{ cloud }}"
@@ -105,6 +365,24 @@
cloud: "{{ cloud }}"
state: absent
name: shade_subnet2
- name: Delete subnet3
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: absent
name: shade_subnet3
- name: Delete subnet4
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: absent
name: shade_subnet4
- name: Delete subnet5
openstack.cloud.subnet:
cloud: "{{ cloud }}"
state: absent
name: shade_subnet5
when:
- network_external

View File

@@ -1,5 +1,8 @@
server_network: private
server_name: ansible_server
server_alt_network: private_alt
server_alt_subnet: subnet_alt
server_alt_name: ansible_server_alt
flavor: m1.tiny
floating_ip_pool_name: public
boot_volume_size: 5

View File

@@ -124,12 +124,8 @@
terminate_volume: true
wait: true
register: server
tags:
- object
- debug: var=server
tags:
- object
- name: Delete server with volume
openstack.cloud.server:
@@ -137,9 +133,6 @@
state: absent
name: "{{ server_name }}"
wait: true
tags:
- object
- name: Create a minimal server
openstack.cloud.server:
cloud: "{{ cloud }}"

View File

@@ -518,3 +518,95 @@
that:
- info24.openstack_servers.0.status == 'ACTIVE'
- server is not changed
- name: Create network for alternate server
openstack.cloud.network:
cloud: "{{ cloud_alt }}"
name: "{{ server_alt_network }}"
state: present
- name: Create subnet for alternate server
openstack.cloud.subnet:
cloud: "{{ cloud_alt }}"
network_name: "{{ server_alt_network }}"
name: "{{ server_alt_subnet }}"
state: present
cidr: 192.168.0.0/24
- name: Create server in alternate project
openstack.cloud.server:
cloud: "{{ cloud_alt }}"
state: present
name: "{{ server_alt_name }}"
image: "{{ image }}"
flavor: "{{ flavor }}"
network: "{{ server_alt_network }}"
auto_floating_ip: false
wait: true
register: server_alt
- name: Get info about server in alternate project
openstack.cloud.server_info:
cloud: "{{ cloud_alt }}"
server: "{{ server_alt_name }}"
register: info25
- name: Ensure status for server in alternate project is ACTIVE
assert:
that:
- info25.openstack_servers.0.status == 'ACTIVE'
- name: Try to stop server in alternate project
openstack.cloud.server_action:
cloud: "{{ cloud }}"
server: "{{ server_alt_name }}"
action: stop
wait: true
ignore_errors: true
register: server_alt
- name: Ensure server was not stopped
assert:
that:
- server_alt is failed
- server_alt.msg == "Could not find server {{ server_alt_name }}"
- name: Stop server in alternate project with all_projects=true
openstack.cloud.server_action:
cloud: "{{ cloud }}"
server: "{{ server_alt_name }}"
action: stop
wait: true
all_projects: True
register: server_alt
- name: Get info about server in alternate project
openstack.cloud.server_info:
cloud: "{{ cloud_alt }}"
server: "{{ server_alt_name }}"
register: info26
- name: Ensure status for server is SHUTOFF
assert:
that:
- info26.openstack_servers.0.status == 'SHUTOFF'
- server_alt is changed
- name: Delete server in alternate project
openstack.cloud.server:
cloud: "{{ cloud_alt }}"
state: absent
name: "{{ server_alt_name }}"
wait: true
- name: Delete subnet for alternate server
openstack.cloud.subnet:
cloud: "{{ cloud_alt }}"
name: "{{ server_alt_subnet }}"
state: absent
- name: Delete network for alternate server
openstack.cloud.network:
cloud: "{{ cloud_alt }}"
name: "{{ server_alt_network }}"
state: absent

View File

@@ -37,6 +37,7 @@
name: "{{ subnet_name }}"
state: present
cidr: 192.168.0.0/24
gateway_ip: 192.168.0.1
allocation_pool_start: 192.168.0.2
allocation_pool_end: 192.168.0.8

View File

@@ -0,0 +1,5 @@
subnet_pool_name: "subnet_pool"
address_scope_name: "address_scope"
default_prefix_length: 24
minimum_prefix_length: 10
maximum_prefix_length: 30

View File

@@ -0,0 +1,73 @@
---
- name: Create address_scope
openstack.cloud.address_scope:
cloud: "{{ cloud }}"
name: "{{ address_scope_name }}"
shared: False
ip_version: "4"
register: create_address_scope
- name: Create subnet pool
openstack.cloud.subnet_pool:
cloud: "{{ cloud }}"
name: "{{ subnet_pool_name }}"
shared: False
address_scope: "{{ address_scope_name }}"
prefixes:
- 192.168.0.0/24
register: create_subnet_pool
- name: Verify subnet pool
assert:
that:
- create_subnet_pool is successful
- create_subnet_pool is changed
- create_subnet_pool.subnet_pool.name == subnet_pool_name
- create_subnet_pool.subnet_pool.is_shared == False
- create_subnet_pool.subnet_pool.is_default == False
- create_subnet_pool.subnet_pool.address_scope_id == create_address_scope.address_scope.id
- create_subnet_pool.subnet_pool.prefixes == ['192.168.0.0/24']
- name: Update subnet pool
openstack.cloud.subnet_pool:
cloud: "{{ cloud }}"
name: "{{ subnet_pool_name }}"
address_scope: "{{ address_scope_name }}"
shared: False
default_prefix_length: "{{ default_prefix_length }}"
minimum_prefix_length: "{{ minimum_prefix_length }}"
maximum_prefix_length: "{{ maximum_prefix_length }}"
description: "test"
prefixes:
- 192.168.0.0/24
- 192.168.1.0/24
register: update_subnet_pool
- name: Verify updated subnet pool
assert:
that:
- update_subnet_pool is successful
- update_subnet_pool is changed
- update_subnet_pool.subnet_pool.name == subnet_pool_name
- update_subnet_pool.subnet_pool.is_shared == False
- update_subnet_pool.subnet_pool.is_default == False
- update_subnet_pool.subnet_pool.address_scope_id == create_address_scope.address_scope.id
- update_subnet_pool.subnet_pool.prefixes == ['192.168.0.0/23']
- update_subnet_pool.subnet_pool.description == 'test'
- update_subnet_pool.subnet_pool.default_prefix_length == default_prefix_length
- update_subnet_pool.subnet_pool.minimum_prefix_length == minimum_prefix_length
- update_subnet_pool.subnet_pool.maximum_prefix_length == maximum_prefix_length
- name: Delete created subnet pool
openstack.cloud.subnet_pool:
cloud: "{{ cloud }}"
name: "{{ subnet_pool_name }}"
state: absent
- name: Delete created address scope
openstack.cloud.address_scope:
cloud: "{{ cloud }}"
name: "{{ address_scope_name }}"
state: absent

View File

@@ -1,30 +0,0 @@
---
- name: Create user
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
password: secret
email: ansible.user@nowhere.net
domain: default
default_project: demo
register: user
- debug: var=user
- name: Update user
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: present
name: ansible_user
password: secret
email: updated.ansible.user@nowhere.net
register: updateduser
- debug: var=updateduser
- name: Delete user
openstack.cloud.identity_user:
cloud: "{{ cloud }}"
state: absent
name: ansible_user

View File

@@ -21,7 +21,7 @@
cloud: "{{ cloud }}"
name: ansible_volume_snapshot
register: snap_info
ignore_errors: sdk_version is version(0.49, '<')
ignore_errors: sdk_version is version('0.49', '<')
- name: Create volume backup
openstack.cloud.volume_backup:
@@ -30,14 +30,14 @@
display_name: ansible_volume_backup
volume: ansible_volume
register: vol_backup
ignore_errors: sdk_version is version(0.49, '<')
ignore_errors: sdk_version is version('0.49', '<')
- name: Get backup info
openstack.cloud.volume_backup_info:
cloud: "{{ cloud }}"
name: ansible_volume_backup
register: backup_info
ignore_errors: sdk_version is version(0.49, '<')
ignore_errors: sdk_version is version('0.49', '<')
- debug: var=vol

View File

@@ -6,20 +6,22 @@
#
# tox -e ansible [TAG ...]
# or
# tox -e ansible -- -c cloudX [TAG ...]
# tox -e ansible -- -c cloudX -u cloudY [TAG ...]
# or to use the development version of Ansible:
# tox -e ansible -- -d -c cloudX [TAG ...]
# tox -e ansible -- -d -c cloudX -u cloudY [TAG ...]
#
# USAGE:
# run-ansible-tests.sh -e ENVDIR [-d] [-c CLOUD] [TAG ...]
# run-ansible-tests.sh -e ENVDIR [-d] [-c CLOUD] [-u CLOUD_ALT] [TAG ...]
#
# PARAMETERS:
# -d Use Ansible source repo development branch.
# -e ENVDIR Directory of the tox environment to use for testing.
# -c CLOUD Name of the cloud to use for testing.
# Defaults to "devstack-admin".
# [TAG ...] Optional list of space-separated tags to control which
# modules are tested.
# -d Use Ansible source repo development branch.
# -e ENVDIR Directory of the tox environment to use for testing.
# -c CLOUD Name of the cloud to use for testing.
# Defaults to "devstack-admin".
# -u CLOUD_ALT Name of another cloud to use for testing.
# Defaults to "devstack-alt".
# [TAG ...] Optional list of space-separated tags to control which
# modules are tested.
#
# EXAMPLES:
# # Run all Ansible tests
@@ -31,14 +33,16 @@
set -ex
CLOUD="devstack-admin"
CLOUD_ALT="devstack-alt"
ENVDIR=
USE_DEV=0
while getopts "c:de:" opt
while getopts "c:de:u:" opt
do
case $opt in
d) USE_DEV=1 ;;
c) CLOUD=${OPTARG} ;;
u) CLOUD_ALT=${OPTARG} ;;
e) ENVDIR=${OPTARG} ;;
?) echo "Invalid option: -${OPTARG}"
exit 1;;
@@ -131,8 +135,9 @@ fi
SDK_VER=$(python -c "import openstack; print(openstack.version.__version__)")
pushd ci/
# run tests
set -o pipefail
ANSIBLE_COLLECTIONS_PATHS=$TEST_COLLECTIONS_PATHS ansible-playbook \
-vvv ./run-collection.yml \
-e "sdk_version=${SDK_VER} cloud=${CLOUD} image=${IMAGE} ${ANSIBLE_VARS}" \
${tag_opt}
-e "sdk_version=${SDK_VER} cloud=${CLOUD} cloud_alt=${CLOUD_ALT} image=${IMAGE} ${ANSIBLE_VARS}" \
${tag_opt} 2>&1 | sudo tee /opt/stack/logs/test_output.log
popd

View File

@@ -4,8 +4,11 @@
gather_facts: true
roles:
- { role: address_scope, tags: address_scope }
- { role: auth, tags: auth }
- { role: catalog_service, tags: catalog_service }
- { role: client_config, tags: client_config }
- { role: dns_zone_info, tags: dns_zone_info }
- role: object_container
tags: object_container
when: sdk_version is version(0.18, '>=')
@@ -13,7 +16,17 @@
- role: dns
tags: dns
when: sdk_version is version(0.28, '>=')
- { role: endpoint, tags: endpoint }
- { role: floating_ip_info, tags: floating_ip_info }
- { role: host_aggregate, tags: host_aggregate }
- { role: identity_domain_info, tags: identity_domain_info }
- { role: identity_group_info, tags: identity_group_info }
- { role: identity_user, tags: identity_user }
- { role: identity_user_info, tags: identity_user_info }
- { role: identity_role, tags: identity_role }
- { role: identity_role_info, tags: identity_role_info }
- { role: image, tags: image }
- { role: image_info, tags: image_info }
- { role: keypair, tags: keypair }
- { role: keystone_domain, tags: keystone_domain }
- role: keystone_mapping
@@ -25,20 +38,27 @@
- role: keystone_federation_protocol
tags: keystone_federation_protocol
when: sdk_version is version(0.44, '>=')
- { role: keystone_role, tags: keystone_role }
- { role: network, tags: network }
- role: neutron_rbac
tags:
- rbac
- neutron_rbac
- { role: nova_flavor, tags: nova_flavor }
- role: compute_flavor_info
tags: nova_flavor
- role: nova_services
tags: nova_services
when: sdk_version is version(0.44, '>=')
- { role: object, tags: object }
- { role: port, tags: port }
- { role: project, tags: project }
- role: project_properties
tags: project_properties
when: sdk_version is version("0.45.01", '>')
- { role: recordset, tags: recordset }
- { role: role_assignment, tags: role_assignment }
- { role: router, tags: router }
- { role: security_group, tags: security_group }
- { role: server, tags: server }
- { role: subnet, tags: subnet }
- { role: user, tags: user }
- { role: subnet_pool, tags: subnet_pool }
- { role: user_group, tags: user_group }
- { role: user_role, tags: user_role }
- { role: volume, tags: volume }
@@ -47,3 +67,4 @@
when: sdk_version is version("0.53.0", '>=')
- role: loadbalancer
tags: loadbalancer
- { role: floating_ip, tags: floating_ip }

View File

@@ -13,7 +13,7 @@ Naming
------
* This is a collection named ``openstack.cloud``. There is no need for further namespace prefixing.
* Name any module that a cloud consumer would expect to use after the logical resource it manages:
* Name any module that a cloud consumer would expect to use after the logical resource it manages:
``server`` not ``nova``. This naming convention acknowledges that the end user does not care
which service manages the resource - that is a deployment detail. For example cloud consumers may
not know whether their floating IPs are managed by Nova or Neutron.
@@ -24,6 +24,7 @@ Interface
* If the resource being managed has an id, it should be returned.
* If the resource being managed has an associated object more complex than
an id, it should also be returned.
* Return format shall be a dictionary or list
Interoperability
----------------
@@ -53,7 +54,7 @@ Libraries
* All complex cloud interaction or interoperability code should be housed in
the `openstacksdk <https://opendev.org/openstack/openstacksdk>`_
library.
* All OpenStack API interactions should happen via the openstacksdk and not via
* All OpenStack API interactions should happen via the openstackSDK and not via
OpenStack Client libraries. The OpenStack Client libraries do no have end
users as a primary audience, they are for intra-server communication.
* All modules should be registered in ``meta/action_groups.yml`` for enabling the

View File

@@ -33,4 +33,4 @@ build_ignore:
- ansible_collections_openstack.egg-info
- contrib
- changelogs
version: 1.4.0
version: 1.9.0

View File

@@ -18,7 +18,7 @@ build_ignore:
- ci
- galaxy.yml.in
- setup.cfg
- test-requirements.txt
- test-requirements*
- tests
- tools
- tox.ini
@@ -29,7 +29,7 @@ build_ignore:
- importer_result.json
- .tox
- .env
- .vscode
- ansible_collections_openstack.egg-info
- contrib
- changelogs/.plugin-cache.yaml
- changelogs/fragments
- changelogs

View File

@@ -1,5 +1,7 @@
requires_ansible: ">=2.8"
action_groups:
openstack:
- address_scope
- auth
- baremetal_inspect
- baremetal_inspect
@@ -7,6 +9,9 @@ action_groups:
- baremetal_node
- baremetal_node_action
- baremetal_node_action
- baremetal_node_info
- baremetal_port_info
- baremetal_port
- catalog_endpoint
- catalog_service
- catalog_service
@@ -17,10 +22,12 @@ action_groups:
- compute_flavor
- compute_flavor_info
- compute_flavor_info
- compute_service_info
- compute_service_info
- config
- config
- dns_zone
- dns_zone
- dns_zone_info
- endpoint
- endpoint
- federation_idp
@@ -32,6 +39,7 @@ action_groups:
- federation_mapping_info
- federation_mapping_info
- floating_ip
- floating_ip_info
- group_assignment
- group_assignment
- host_aggregate
@@ -91,6 +99,7 @@ action_groups:
- stack
- subnet
- subnets_info
- subnet_pool
- volume
- volume_backup
- volume_backup_info

View File

@@ -61,7 +61,6 @@ options:
- Whether or not SSL API requests should be verified.
- Before Ansible 2.3 this defaulted to C(yes).
type: bool
default: False
aliases: [ verify ]
ca_cert:
description:
@@ -92,7 +91,7 @@ options:
type: str
requirements:
- python >= 3.6
- openstacksdk >= 0.12.0
- openstacksdk >= 0.36, < 0.99.0
notes:
- The standard OpenStack environment variables, such as C(OS_USERNAME)
may be used instead of providing explicit values.

View File

@@ -9,7 +9,6 @@
DOCUMENTATION = '''
---
name: openstack
plugin_type: inventory
author: OpenStack Ansible SIG
short_description: OpenStack inventory source
requirements:
@@ -22,11 +21,11 @@ options:
plugin:
description: token that ensures this is a source file for the 'openstack' plugin.
required: True
choices: ['openstack']
choices: ['openstack', 'openstack.cloud.openstack']
show_all:
description: toggles showing all vms vs only those with a working IP
type: bool
default: 'no'
default: false
inventory_hostname:
description: |
What to register as the inventory hostname.
@@ -42,6 +41,13 @@ options:
- name
- uuid
default: "name"
use_names:
description: |
Use the host's 'name' instead of 'interface_ip' for the 'ansible_host' and
'ansible_ssh_host' facts. This might be desired when using jump or
bastion hosts and the name is the FQDN of the host.
type: bool
default: false
expand_hostvars:
description: |
Run extra commands on each host to fill in additional
@@ -50,7 +56,7 @@ options:
(Note, the default value of this is opposite from the default
old openstack.py inventory script's option expand_hostvars)
type: bool
default: 'no'
default: false
private:
description: |
Use the private interface of each server, if it has one, as
@@ -58,12 +64,13 @@ options:
running ansible inside a server in the cloud and would rather
communicate to your servers over the private network.
type: bool
default: 'no'
default: false
only_clouds:
description: |
List of clouds from clouds.yaml to use, instead of using
the whole list.
type: list
elements: str
default: []
fail_on_errors:
description: |
@@ -74,12 +81,12 @@ options:
default value of this is opposite from the old openstack.py
inventory script's option fail_on_errors)
type: bool
default: 'no'
default: false
all_projects:
description: |
Lists servers from all projects
type: bool
default: 'no'
default: false
clouds_yaml_path:
description: |
Override path to clouds.yaml file. If this value is given it
@@ -88,6 +95,7 @@ options:
/etc/ansible/openstack.yml to the regular locations documented
at https://docs.openstack.org/os-client-config/latest/user/configuration.html#config-files
type: list
elements: str
env:
- name: OS_CLIENT_CONFIG_FILE
compose:
@@ -112,7 +120,7 @@ extends_documentation_fragment:
EXAMPLES = '''
# file must be named openstack.yaml or openstack.yml
# Make the plugin behave like the default behavior of the old script
plugin: openstack
plugin: openstack.cloud.openstack
expand_hostvars: yes
fail_on_errors: yes
all_projects: yes
@@ -159,7 +167,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
msg = ''
if not self._config_data:
msg = 'File empty. this is not my config file'
elif 'plugin' in self._config_data and self._config_data['plugin'] != self.NAME:
elif 'plugin' in self._config_data and self._config_data['plugin'] not in (self.NAME, 'openstack'):
msg = 'plugin config file, but not for us: %s' % self._config_data['plugin']
elif 'plugin' not in self._config_data and 'clouds' not in self._config_data:
msg = "it's not a plugin configuration nor a clouds.yaml file"
@@ -237,6 +245,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
expand_hostvars = self._config_data.get('expand_hostvars', False)
fail_on_errors = self._config_data.get('fail_on_errors', False)
all_projects = self._config_data.get('all_projects', False)
self.use_names = self._config_data.get('use_names', False)
source_data = []
try:
@@ -311,7 +320,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
for group_name, group_hosts in groups.items():
gname = self.inventory.add_group(group_name)
for host in group_hosts:
self.inventory.add_child(gname, host)
if gname == host:
display.vvvv("Same name for host %s and group %s" % (host, gname))
self.inventory.add_host(host, gname)
else:
self.inventory.add_child(gname, host)
def _get_groups_from_server(self, server_vars, namegroup=True):
groups = []
@@ -359,10 +372,20 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
def _append_hostvars(self, hostvars, groups, current_host,
server, namegroup=False):
hostvars[current_host] = dict(
ansible_ssh_host=server['interface_ip'],
ansible_host=server['interface_ip'],
openstack=server)
if not self.use_names:
hostvars[current_host] = dict(
ansible_ssh_host=server['interface_ip'],
ansible_host=server['interface_ip'],
openstack=server,
)
if self.use_names:
hostvars[current_host] = dict(
ansible_ssh_host=server['name'],
ansible_host=server['name'],
openstack=server,
)
self.inventory.add_host(current_host)
if self.get_option('legacy_groups'):

View File

@@ -67,7 +67,8 @@ OVERRIDES = {'os_client_config': 'config',
CUSTOM_VAR_PARAMS = ['min_ver', 'max_ver']
MINIMUM_SDK_VERSION = '0.12.0'
MINIMUM_SDK_VERSION = '0.36.0'
MAXIMUM_SDK_VERSION = '0.98.999'
def openstack_argument_spec():
@@ -120,7 +121,7 @@ def openstack_full_argument_spec(**kwargs):
auth=dict(default=None, type='dict', no_log=True),
region_name=dict(default=None),
availability_zone=dict(default=None),
validate_certs=dict(default=False, type='bool', aliases=['verify']),
validate_certs=dict(default=None, type='bool', aliases=['verify']),
ca_cert=dict(default=None, aliases=['cacert']),
client_cert=dict(default=None, aliases=['cert']),
client_key=dict(default=None, no_log=True, aliases=['key']),
@@ -152,7 +153,7 @@ def openstack_module_kwargs(**kwargs):
# for compatibility with old versions
def openstack_cloud_from_module(module, min_version=None):
def openstack_cloud_from_module(module, min_version=None, max_version=None):
try:
# Due to the name shadowing we should import other way
sdk = importlib.import_module('openstack')
@@ -160,18 +161,30 @@ def openstack_cloud_from_module(module, min_version=None):
except ImportError:
module.fail_json(msg='openstacksdk is required for this module')
if min_version:
if min_version and MINIMUM_SDK_VERSION:
min_version = max(StrictVersion(MINIMUM_SDK_VERSION),
StrictVersion(min_version))
else:
elif MINIMUM_SDK_VERSION:
min_version = StrictVersion(MINIMUM_SDK_VERSION)
if StrictVersion(sdk_version.__version__) < min_version:
if max_version and MAXIMUM_SDK_VERSION:
max_version = min(StrictVersion(MAXIMUM_SDK_VERSION),
StrictVersion(max_version))
elif MAXIMUM_SDK_VERSION:
max_version = StrictVersion(MAXIMUM_SDK_VERSION)
if min_version and StrictVersion(sdk_version.__version__) < min_version:
module.fail_json(
msg="To utilize this module, the installed version of "
"the openstacksdk library MUST be >={min_version}.".format(
min_version=min_version))
if max_version and StrictVersion(sdk_version.__version__) > max_version:
module.fail_json(
msg="To utilize this module, the installed version of "
"the openstacksdk library MUST be <={max_version}.".format(
max_version=max_version))
cloud_config = module.params.pop('cloud', None)
try:
if isinstance(cloud_config, dict):
@@ -244,6 +257,7 @@ class OpenStackModule:
argument_spec = {}
module_kwargs = {}
module_min_sdk_version = None
module_max_sdk_version = None
def __init__(self):
"""Initialize Openstack base class.
@@ -256,10 +270,12 @@ class OpenStackModule:
**self.module_kwargs)
self.params = self.ansible.params
self.module_name = self.ansible._name
self.check_mode = self.ansible.check_mode
self.sdk_version = None
self.results = {'changed': False}
self.exit = self.exit_json = self.ansible.exit_json
self.fail = self.fail_json = self.ansible.fail_json
self.warn = self.ansible.warn
self.sdk, self.conn = self.openstack_cloud_from_module()
self.check_deprecated_names()
@@ -304,19 +320,36 @@ class OpenStackModule:
except ImportError:
self.fail_json(msg='openstacksdk is required for this module')
# Fail if the available SDK version doesn't meet the minimum version
# requirements
if self.module_min_sdk_version:
# Fail if the available SDK version doesn't meet the minimum
# and maximum version requirements
if self.module_min_sdk_version and MINIMUM_SDK_VERSION:
min_version = max(StrictVersion(MINIMUM_SDK_VERSION),
StrictVersion(self.module_min_sdk_version))
else:
elif MINIMUM_SDK_VERSION:
min_version = StrictVersion(MINIMUM_SDK_VERSION)
if StrictVersion(self.sdk_version) < min_version:
else:
min_version = None
if self.module_max_sdk_version and MAXIMUM_SDK_VERSION:
max_version = min(StrictVersion(MAXIMUM_SDK_VERSION),
StrictVersion(self.module_max_sdk_version))
elif MAXIMUM_SDK_VERSION:
max_version = StrictVersion(MAXIMUM_SDK_VERSION)
else:
max_version = None
if min_version and StrictVersion(self.sdk_version) < min_version:
self.fail(
msg="To utilize this module, the installed version of "
"the openstacksdk library MUST be >={min_version}.".format(
min_version=min_version))
if max_version and StrictVersion(self.sdk_version) > max_version:
self.fail(
msg="To utilize this module, the installed version of "
"the openstacksdk library MUST be <={max_version}.".format(
max_version=max_version))
# Fail if there are set unsupported for this version parameters
# New parameters should NOT use 'default' but rely on SDK defaults
for param in self.argument_spec:

View File

@@ -0,0 +1,201 @@
#!/usr/bin/python
# coding: utf-8 -*-
#
# Copyright (c) 2021 by Uemit Seren <uemit.seren@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
---
module: address_scope
short_description: Create or delete address scopes from OpenStack
author: OpenStack Ansible SIG
description:
- Create or Delete address scopes from OpenStack.
options:
state:
description:
- Indicate desired state of the resource
choices: ['present', 'absent']
default: present
type: str
name:
description:
- Name to be give to the address scope
required: true
type: str
project:
description:
- Unique name or ID of the project.
type: str
ip_version:
description:
- The IP version of the subnet 4 or 6
default: '4'
type: str
choices: ['4', '6']
shared:
description:
- Whether this address scope is shared or not.
type: bool
default: 'no'
extra_specs:
description:
- Dictionary with extra key/value pairs passed to the API
required: false
default: {}
type: dict
requirements:
- "python >= 3.6"
- "openstacksdk"
extends_documentation_fragment:
- openstack.cloud.openstack
'''
EXAMPLES = '''
# Create an IPv4 address scope.
- openstack.cloud.address_scope:
cloud: mycloud
state: present
name: my_adress_scope
# Create a shared IPv6 address scope for a given project.
- openstack.cloud.address_scope:
cloud: mycloud
state: present
ip_version: 6
name: ipv6_address_scope
project: myproj
# Delete address scope.
- openstack.cloud.address_scope:
cloud: mycloud
state: absent
name: my_adress_scope
'''
RETURN = '''
address_scope:
description: Dictionary describing the address scope.
returned: On success when I(state) is 'present'
type: complex
contains:
id:
description: Address Scope ID.
type: str
sample: "474acfe5-be34-494c-b339-50f06aa143e4"
name:
description: Address Scope name.
type: str
sample: "my_address_scope"
tenant_id:
description: The tenant ID.
type: str
sample: "861174b82b43463c9edc5202aadc60ef"
ip_version:
description: The IP version of the subnet 4 or 6.
type: str
sample: "4"
is_shared:
description: Indicates whether this address scope is shared across all tenants.
type: bool
sample: false
'''
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
class AddressScopeModule(OpenStackModule):
argument_spec = dict(
state=dict(default='present', choices=['absent', 'present']),
name=dict(required=True),
shared=dict(default=False, type='bool'),
ip_version=dict(type='str', default='4', choices=['4', '6']),
project=dict(default=None),
extra_specs=dict(type='dict', default=dict())
)
def _needs_update(self, address_scope, filters=None):
"""Decide if the given address_scope needs an update.
"""
ip_version = int(self.params['ip_version'])
if address_scope['is_shared'] != self.params['shared']:
return True
if ip_version and address_scope['ip_version'] != ip_version:
self.fail_json(msg='Cannot update ip_version in existing address scope')
return False
def _system_state_change(self, address_scope, filters=None):
"""Check if the system state would be changed."""
state = self.params['state']
if state == 'absent' and address_scope:
return True
if state == 'present':
if not address_scope:
return True
return self._needs_update(address_scope, filters)
return False
def run(self):
state = self.params['state']
name = self.params['name']
shared = self.params['shared']
ip_version = self.params['ip_version']
project = self.params['project']
extra_specs = self.params['extra_specs']
if project is not None:
proj = self.conn.get_project(project)
if proj is None:
self.fail(msg='Project %s could not be found' % project)
project_id = proj['id']
else:
project_id = self.conn.current_project_id
address_scope = self.conn.network.find_address_scope(name_or_id=name)
if self.ansible.check_mode:
self.exit_json(
changed=self._system_state_change(address_scope)
)
if state == 'present':
changed = False
if not address_scope:
kwargs = dict(
name=name,
ip_version=ip_version,
is_shared=shared,
tenant_id=project_id)
dup_args = set(kwargs.keys()) & set(extra_specs.keys())
if dup_args:
raise ValueError('Duplicate key(s) {0} in extra_specs'
.format(list(dup_args)))
kwargs = dict(kwargs, **extra_specs)
address_scope = self.conn.network.create_address_scope(**kwargs)
changed = True
else:
if self._needs_update(address_scope):
address_scope = self.conn.network.update_address_scope(address_scope['id'], is_shared=shared)
changed = True
else:
changed = False
self.exit_json(changed=changed, address_scope=address_scope, id=address_scope['id'])
elif state == 'absent':
if not address_scope:
self.exit(changed=False)
else:
self.conn.network.delete_address_scope(address_scope['id'])
self.exit_json(changed=True)
def main():
module = AddressScopeModule()
module()
if __name__ == '__main__':
main()

View File

@@ -38,29 +38,24 @@ service_catalog:
type: dict
'''
import traceback
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
class AuthModule(OpenStackModule):
argument_spec = dict()
module_kwargs = dict()
def run(self):
self.exit_json(
changed=False,
ansible_facts=dict(
auth_token=self.conn.auth_token,
service_catalog=self.conn.service_catalog))
def main():
argument_spec = openstack_full_argument_spec()
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec, **module_kwargs)
sdk, cloud = openstack_cloud_from_module(module)
try:
module.exit_json(
changed=False,
ansible_facts=dict(
auth_token=cloud.auth_token,
service_catalog=cloud.service_catalog))
except Exception as e:
module.fail_json(msg=str(e), exception=traceback.format_exc())
module = AuthModule()
module()
if __name__ == '__main__':

View File

@@ -299,7 +299,10 @@ def main():
required=False,
type='bool',
aliases=['skip_update_of_driver_password'],
deprecated_aliases=[dict(name='skip_update_of_driver_password', version='2.0.0')]
deprecated_aliases=[dict(
name='skip_update_of_driver_password',
version='2.0.0',
collection_name='openstack.cloud')]
),
state=dict(required=False, default='present', choices=['present', 'absent'])
)

View File

@@ -0,0 +1,555 @@
#!/usr/bin/python
# coding: utf-8 -*-
# Copyright (c) 2021 by Red Hat, Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
module: baremetal_node_info
short_description: Retrieve information about Bare Metal nodes from OpenStack
author: OpenStack Ansible SIG
description:
- Retrieve information about Bare Metal nodes from OpenStack.
options:
node:
description:
- Name or globally unique identifier (UUID) to identify the host.
type: str
mac:
description:
- Unique mac address that is used to attempt to identify the host.
type: str
ironic_url:
description:
- If noauth mode is utilized, this is required to be set to the
endpoint URL for the Ironic API. Use with "auth" and "auth_type"
settings set to None.
type: str
requirements:
- "python >= 3.6"
- "openstacksdk"
extends_documentation_fragment:
- openstack.cloud.openstack
'''
EXAMPLES = '''
# Gather information about all baremeal nodes
- openstack.cloud.baremetal_node_info:
cloud: "devstack"
register: result
- debug:
msg: "{{ result.baremetal_nodes }}"
# Gather information about a baremeal node
- openstack.cloud.baremetal_node_info:
cloud: "devstack"
node: "00000000-0000-0000-0000-000000000002"
register: result
- debug:
msg: "{{ result.baremetal_nodes }}"
'''
RETURN = '''
baremetal_nodes:
description: Bare Metal node list. A subset of the dictionary keys
listed below may be returned, depending on your cloud
provider.
returned: always, but can be null
type: complex
contains:
allocation_uuid:
description: The UUID of the allocation associated with the node.
If not null, will be the same as instance_uuid (the
opposite is not always true). Unlike instance_uuid,
this field is read-only. Please use the Allocation API
to remove allocations.
returned: success
type: str
automated_clean:
description: Indicates whether the node will perform automated
clean or not.
returned: success
type: bool
bios_interface:
description: The bios interface to be used for this node.
returned: success
type: str
boot_interface:
description: The boot interface for a Node, e.g. "pxe".
returned: success
type: str
boot_mode:
description: The boot mode for a node, either "uefi" or "bios"
returned: success
type: str
chassis_uuid:
description: UUID of the chassis associated with this Node. May be
empty or None.
returned: success
type: str
clean_step:
description: The current clean step.
returned: success
type: str
conductor:
description: The conductor currently servicing a node. This field
is read-only.
returned: success
type: str
conductor_group:
description: The conductor group for a node. Case-insensitive
string up to 255 characters, containing a-z, 0-9, _,
-, and ..
returned: success
type: str
console_enabled:
description: Indicates whether console access is enabled or
disabled on this node.
returned: success
type: bool
console_interface:
description: The console interface for a node, e.g. "no-console".
returned: success
type: str
created_at:
description: Bare Metal node created at timestamp.
returned: success
type: str
deploy_interface:
description: The deploy interface for a node, e.g. "direct".
returned: success
type: str
deploy_step:
description: The current deploy step.
returned: success
type: str
driver:
description: The name of the driver.
returned: success
type: str
driver_info:
description: All the metadata required by the driver to manage this
Node. List of fields varies between drivers, and can
be retrieved from the
/v1/drivers/<DRIVER_NAME>/properties resource.
returned: success
type: dict
driver_internal_info:
description: Internal metadata set and stored by the Node's driver.
returned: success
type: dict
extra:
description: A set of one or more arbitrary metadata key and value
pairs.
returned: success
type: dict
fault:
description: The fault indicates the active fault detected by
ironic, typically the Node is in "maintenance mode".
None means no fault has been detected by ironic.
"power failure" indicates ironic failed to retrieve
power state from this node. There are other possible
types, e.g., "clean failure" and "rescue abort
failure".
returned: success
type: str
id:
description: The UUID for the resource.
returned: success
type: str
inspect_interface:
description: The interface used for node inspection.
returned: success
type: str
instance_info:
description: Information used to customize the deployed image. May
include root partition size, a base 64 encoded config
drive, and other metadata. Note that this field is
erased automatically when the instance is deleted
(this is done by requesting the Node provision state
be changed to DELETED).
returned: success
type: dict
instance_uuid:
description: UUID of the Nova instance associated with this Node.
returned: success
type: str
last_error:
description: Any error from the most recent (last) transaction that
started but failed to finish.
returned: success
type: str
maintenance:
description: Whether or not this Node is currently in "maintenance
mode". Setting a Node into maintenance mode removes it
from the available resource pool and halts some
internal automation. This can happen manually (eg, via
an API request) or automatically when Ironic detects a
hardware fault that prevents communication with the
machine.
returned: success
type: bool
maintenance_reason:
description: User-settable description of the reason why this Node
was placed into maintenance mode
returned: success
type: str
management_interface:
description: Interface for out-of-band node management.
returned: success
type: str
name:
description: Human-readable identifier for the Node resource. May
be undefined. Certain words are reserved.
returned: success
type: str
network_interface:
description: Which Network Interface provider to use when plumbing
the network connections for this Node.
returned: success
type: str
owner:
description: A string or UUID of the tenant who owns the object.
returned: success
type: str
portgroups:
description: List of ironic portgroups on this node.
returned: success
type: list
elements: dict
contains:
address:
description: Physical hardware address of this Portgroup,
typically the hardware MAC address.
returned: success
type: str
created_at:
description: The UTC date and time when the resource was
created, ISO 8601 format.
returned: success
type: str
extra:
description: A set of one or more arbitrary metadata key and
value pairs.
returned: success
type: dict
id:
description: The UUID for the resource.
returned: success
type: str
internal_info:
description: Internal metadata set and stored by the Portgroup.
This field is read-only.
returned: success
type: dict
is_standalone_ports_supported:
description: Indicates whether ports that are members of this
portgroup can be used as stand-alone ports.
returned: success
type: bool
mode:
description: Mode of the port group. For possible values, refer
to https://www.kernel.org/doc/Documentation/networking/bonding.txt.
If not specified in a request to create a port
group, it will be set to the value of the
[DEFAULT]default_portgroup_mode configuration
option. When set, can not be removed from the port
group.
returned: success
type: str
name:
description: Human-readable identifier for the Portgroup
resource. May be undefined.
returned: success
type: str
node_id:
description: UUID of the Node this resource belongs to.
returned: success
type: str
ports:
description: List of port UUID's of ports belonging to this
portgroup.
returned: success
type: list
properties:
description: Key/value properties related to the port group's
configuration.
returned: success
type: dict
updated_at:
description: The UTC date and time when the resource was
updated, ISO 8601 format. May be "null".
returned: success
type: str
ports:
description: List of ironic ports on this node.
returned: success
type: list
elements: dict
contains:
address:
description: Physical hardware address of this network Port,
typically the hardware MAC address.
returned: success
type: str
created_at:
description: The UTC date and time when the resource was
created, ISO 8601 format.
returned: success
type: str
extra:
description: A set of one or more arbitrary metadata key and
value pairs.
returned: success
type: dict
id:
description: The UUID for the resource.
returned: success
type: str
internal_info:
description: Internal metadata set and stored by the Port. This
field is read-only.
returned: success
type: dict
local_link_connection:
description: The Port binding profile. If specified, must
contain switch_id (only a MAC address or an
OpenFlow based datapath_id of the switch are
accepted in this field) and port_id (identifier of
the physical port on the switch to which node's
port is connected to) fields. switch_info is an
optional string field to be used to store any
vendor-specific information.
returned: success
type: dict
name:
description: The name of the resource.
returned: success
type: str
node_uuid:
description: UUID of the Node this resource belongs to.
returned: success
type: str
physical_network:
description: The name of the physical network to which a port
is connected. May be empty.
returned: success
type: str
portgroup_uuid:
description: UUID of the Portgroup this resource belongs to.
returned: success
type: str
pxe_enabled:
description: Indicates whether PXE is enabled or disabled on
the Port.
returned: success
type: str
updated_at:
description: The UTC date and time when the resource was
updated, ISO 8601 format. May be "null".
returned: success
type: str
uuid:
description: The UUID for the resource.
returned: success
type: str
power_interface:
description: Interface used for performing power actions on the
node, e.g. "ipmitool".
returned: success
type: str
power_state:
description: The current power state of this Node. Usually, "power
on" or "power off", but may be "None" if Ironic is
unable to determine the power state (eg, due to
hardware failure).
returned: success
type: str
properties:
description: Physical characteristics of this Node. Populated by
ironic-inspector during inspection. May be edited via
the REST API at any time.
returned: success
type: dict
protected:
description: Whether the node is protected from undeploying,
rebuilding and deletion.
returned: success
type: bool
protected_reason:
description: The reason the node is marked as protected.
returned: success
type: str
provision_state:
description: The current provisioning state of this Node.
returned: success
type: str
raid_config:
description: Represents the current RAID configuration of the node.
Introduced with the cleaning feature.
returned: success
type: dict
raid_interface:
description: Interface used for configuring RAID on this node.
returned: success
type: str
rescue_interface:
description: The interface used for node rescue, e.g. "no-rescue".
returned: success
type: str
reservation:
description: The name of an Ironic Conductor host which is holding
a lock on this node, if a lock is held. Usually
"null", but this field can be useful for debugging.
returned: success
type: str
resource_class:
description: A string which can be used by external schedulers to
identify this Node as a unit of a specific type of
resource. For more details, see
https://docs.openstack.org/ironic/latest/install/configure-nova-flavors.html
returned: success
type: str
retired:
description: Whether the node is retired and can hence no longer be
provided, i.e. move from manageable to available, and
will end up in manageable after cleaning (rather than
available).
returned: success
type: bool
retired_reason:
description: The reason the node is marked as retired.
returned: success
type: str
secure_boot:
description: Indicates whether node is currently booted with
secure_boot turned on.
returned: success
type: bool
storage_interface:
description: Interface used for attaching and detaching volumes on
this node, e.g. "cinder".
returned: success
type: str
target_power_state:
description: If a power state transition has been requested, this
field represents the requested (ie, "target") state,
either "power on" or "power off".
returned: success
type: str
target_provision_state:
description: If a provisioning action has been requested, this
field represents the requested (ie, "target") state.
Note that a Node may go through several states during
its transition to this target state. For instance,
when requesting an instance be deployed to an
AVAILABLE Node, the Node may go through the following
state change progression, AVAILABLE -> DEPLOYING ->
DEPLOYWAIT -> DEPLOYING -> ACTIVE
returned: success
type: str
target_raid_config:
description: Represents the requested RAID configuration of the
node, which will be applied when the Node next
transitions through the CLEANING state. Introduced
with the cleaning feature.
returned: success
type: dict
traits:
description: List of traits for this node.
returned: success
type: list
updated_at:
description: Bare Metal node updated at timestamp.
returned: success
type: str
uuid:
description: The UUID for the resource.
returned: success
type: str
vendor_interface:
description: Interface for vendor-specific functionality on this
node, e.g. "no-vendor".
returned: success
type: str
'''
from ansible_collections.openstack.cloud.plugins.module_utils.ironic import (
IronicModule,
ironic_argument_spec,
)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
openstack_module_kwargs,
openstack_cloud_from_module
)
def cleanup_node_properties(machine, cloud):
# states are links, not useful
machine.pop('states', None)
for port in machine.ports:
# links are not useful
port.pop('links', None)
# redundant, location is in on machine as well
port.pop('location', None)
for portgroup in machine.portgroups:
# links are not useful
portgroup.pop('links', None)
# redundant, location is in on machine as well
portgroup.pop('location', None)
# links to ports are not useful, replace with list of port uuid's
portgroup['ports'] = [x.id for x in list(
cloud.baremetal.ports(portgroup=portgroup['id']))]
def get_ports_and_portgroups(cloud, machine):
machine.ports = cloud.list_nics_for_machine(machine.uuid)
machine.portgroups = [dict(x) for x in
list(cloud.baremetal.port_groups(node=machine.uuid,
details=True))]
def main():
argument_spec = ironic_argument_spec(
node=dict(required=False),
mac=dict(required=False),
)
module_kwargs = openstack_module_kwargs()
module_kwargs['supports_check_mode'] = True
module = IronicModule(argument_spec, **module_kwargs)
machine = None
machines = list()
sdk, cloud = openstack_cloud_from_module(module)
try:
if module.params['node']:
machine = cloud.get_machine(module.params['node'])
elif module.params['mac']:
machine = cloud.get_machine_by_mac(module.params['mac'])
# Fail if node not found
if (module.params['node'] or module.params['mac']) and not machine:
module.fail_json(msg='The baremetal node was not found')
if machine:
machines.append(machine)
else:
machines = cloud.list_machines()
for machine in machines:
get_ports_and_portgroups(cloud, machine)
cleanup_node_properties(machine, cloud)
module.exit_json(changed=False, baremetal_nodes=machines)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,373 @@
#!/usr/bin/python
# coding: utf-8 -*-
# Copyright (c) 2021 by Red Hat, Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
module: baremetal_port
short_description: Create/Delete Bare Metal port Resources from OpenStack
author: OpenStack Ansible SIG
description:
- Create, Update and Remove ironic ports from OpenStack.
options:
state:
description:
- Indicates desired state of the resource
choices: ['present', 'absent']
default: present
type: str
uuid:
description:
- globally unique identifier (UUID) to be given to the resource. Will
be auto-generated if not specified.
type: str
node:
description:
- UUID or Name of the Node this resource belongs to.
type: str
address:
description:
- Physical hardware address of this network Port, typically the
hardware MAC address.
type: str
portgroup:
description:
- UUID or Name of the Portgroup this resource belongs to.
type: str
local_link_connection:
description:
- The Port binding profile.
type: dict
suboptions:
switch_id:
description:
- A MAC address or an OpenFlow based datapath_id of the switch.
type: str
port_id:
description:
- Identifier of the physical port on the switch to which node's
port is connected to.
type: str
switch_info:
description:
- An optional string field to be used to store any vendor-specific
information.
type: str
is_pxe_enabled:
description:
- Whether PXE should be enabled or disabled on the Port.
type: bool
physical_network:
description:
- The name of the physical network to which a port is connected.
type: str
extra:
description:
- A set of one or more arbitrary metadata key and value pairs.
type: dict
ironic_url:
description:
- If noauth mode is utilized, this is required to be set to the
endpoint URL for the Ironic API. Use with "auth" and "auth_type"
settings set to None.
type: str
requirements:
- "python >= 3.6"
- "openstacksdk"
extends_documentation_fragment:
- openstack.cloud.openstack
'''
EXAMPLES = '''
# Create Bare Metal port
- name: Create Bare Metal port
openstack.cloud.baremetal_port:
cloud: devstack
state: present
node: bm-0
address: fa:16:3e:aa:aa:aa
pxe_enabled: True
local_link_connection:
switch_id: 0a:1b:2c:3d:4e:5f
port_id: Ethernet3/1
switch_info: switch1
extra:
something: extra
physical_network: datacenter
register: result
# Delete Bare Metal port
- name: Delete Bare Metal port
openstack.cloud.baremetal_port:
cloud: devstack
state: absent
address: fa:16:3e:aa:aa:aa
register: result
# Update Bare Metal port
- name: Update Bare Metal port
openstack.cloud.baremetal_port:
cloud: devstack
state: present
uuid: 1a85ebca-22bf-42eb-ad9e-f640789b8098
pxe_enabled: False
local_link_connection:
switch_id: a0:b1:c2:d3:e4:f5
port_id: Ethernet4/12
switch_info: switch2
'''
RETURN = '''
id:
description: Unique UUID of the port.
returned: always, but can be null
type: str
result:
description: A short text describing the result.
returned: success
type: str
changes:
description: Map showing from -> to values for properties that was changed
after port update.
returned: success
type: dict
port:
description: A port dictionary, subset of the dictionary keys listed below
may be returned, depending on your cloud provider.
returned: success
type: complex
contains:
address:
description: Physical hardware address of this network Port,
typically the hardware MAC address.
returned: success
type: str
created_at:
description: Bare Metal port created at timestamp.
returned: success
type: str
extra:
description: A set of one or more arbitrary metadata key and value
pairs.
returned: success
type: dict
id:
description: The UUID for the Baremetal Port resource.
returned: success
type: str
internal_info:
description: Internal metadata set and stored by the Port. This
field is read-only.
returned: success
type: dict
is_pxe_enabled:
description: Whether PXE is enabled or disabled on the Port.
returned: success
type: bool
local_link_connection:
description: The Port binding profile. If specified, must contain
switch_id (only a MAC address or an OpenFlow based
datapath_id of the switch are accepted in this field
and port_id (identifier of the physical port on the
switch to which node's port is connected to) fields.
switch_info is an optional string field to be used to
store any vendor-specific information.
returned: success
type: dict
location:
description: Cloud location of this resource (cloud, project,
region, zone)
returned: success
type: dict
name:
description: Bare Metal port name.
returned: success
type: str
node_id:
description: UUID of the Bare Metal Node this resource belongs to.
returned: success
type: str
physical_network:
description: The name of the physical network to which a port is
connected.
returned: success
type: str
port_group_id:
description: UUID of the Portgroup this resource belongs to.
returned: success
type: str
updated_at:
description: Bare Metal port updated at timestamp.
returned: success
type: str
'''
from ansible_collections.openstack.cloud.plugins.module_utils.ironic import (
IronicModule,
ironic_argument_spec,
)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
openstack_module_kwargs,
openstack_cloud_from_module
)
_PROP_TO_ATTR_MAP = {
'pxe_enabled': 'is_pxe_enabled',
'address': 'address',
'extra': 'extra',
'local_link_connection': 'local_link_connection',
'physical_network': 'physical_network',
'node_uuid': 'node_id',
'portgroup_uuid': 'port_group_id',
'uuid': 'id',
}
def find_port(module, cloud):
port = None
if module.params['uuid']:
port = cloud.baremetal.find_port(module.params['uuid'])
elif module.params['address']:
ports = list(cloud.baremetal.ports(address=module.params['address'],
details=True))
if ports and len(ports) == 1:
port = ports[0]
elif len(ports) > 1:
module.fail_json(
msg="Multiple ports with address {address} found. A uuid must "
"be defined in order to identify the correct port"
.format(address=module.params['address']))
return port
def add_port(module, cloud):
port = find_port(module, cloud)
if port:
update_port(module, cloud, port=port)
if not module.params['node'] or not module.params['address']:
module.fail_json(
msg="A Bare Metal node (name or uuid) and an address is required "
"to create a port")
machine = cloud.get_machine(module.params['node'])
if not machine:
module.fail_json(
msg="Bare Metal node {node} could not be found".format(
node=module.params['node']))
module.params['node_uuid'] = machine.id
props = {k: module.params[k] for k in _PROP_TO_ATTR_MAP.keys()
if k in module.params}
port = cloud.baremetal.create_port(**props)
port_dict = port.to_dict()
port_dict.pop('links', None)
module.exit_json(
changed=True,
result="Port successfully created",
changes=None,
port=port_dict,
id=port_dict['id'])
def update_port(module, cloud, port=None):
if not port:
port = find_port(module, cloud)
if module.params['node']:
machine = cloud.get_machine(module.params['node'])
if machine:
module.params['node_uuid'] = machine.id
old_props = {k: port[v] for k, v in _PROP_TO_ATTR_MAP.items()}
new_props = {k: module.params[k] for k in _PROP_TO_ATTR_MAP.keys()
if k in module.params and module.params[k] is not None}
prop_diff = {k: new_props[k] for k in _PROP_TO_ATTR_MAP.keys()
if k in new_props and old_props[k] != new_props[k]}
if not prop_diff:
port_dict = port.to_dict()
port_dict.pop('links', None)
module.exit_json(
changed=False,
result="No port update required",
changes=None,
port=port_dict,
id=port_dict['id'])
port = cloud.baremetal.update_port(port.id, **prop_diff)
port_dict = port.to_dict()
port_dict.pop('links', None)
module.exit_json(
changed=True,
result="Port successfully updated",
changes={k: {'to': new_props[k], 'from': old_props[k]}
for k in prop_diff},
port=port_dict,
id=port_dict['id'])
def remove_port(module, cloud):
if not module.params['uuid'] and not module.params['address']:
module.fail_json(
msg="A uuid or an address value must be defined in order to "
"remove a port.")
if module.params['uuid']:
port = cloud.baremetal.delete_port(module.params['uuid'])
if not port:
module.exit_json(
changed=False,
result="Port not found",
changes=None,
id=module.params['uuid'])
else:
port = find_port(module, cloud)
if not port:
module.exit_json(
changed=False,
result="Port not found",
changes=None,
id=None)
port = cloud.baremetal.delete_port(port.id)
module.exit_json(
changed=True,
result="Port successfully removed",
changes=None,
id=port.id)
def main():
argument_spec = ironic_argument_spec(
uuid=dict(required=False),
node=dict(required=False),
address=dict(required=False),
portgroup=dict(required=False),
local_link_connection=dict(required=False, type='dict'),
is_pxe_enabled=dict(required=False, type='bool'),
physical_network=dict(required=False),
extra=dict(required=False, type='dict'),
state=dict(required=False,
default='present',
choices=['present', 'absent'])
)
module_kwargs = openstack_module_kwargs()
module = IronicModule(argument_spec, **module_kwargs)
module.params['pxe_enabled'] = module.params.pop('is_pxe_enabled', None)
sdk, cloud = openstack_cloud_from_module(module)
try:
if module.params['state'] == 'present':
add_port(module, cloud)
if module.params['state'] == 'absent':
remove_port(module, cloud)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,208 @@
#!/usr/bin/python
# coding: utf-8 -*-
# Copyright (c) 2021 by Red Hat, Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
module: baremetal_port_info
short_description: Retrieve information about Bare Metal ports from OpenStack
author: OpenStack Ansible SIG
description:
- Retrieve information about Bare Metal ports from OpenStack.
options:
uuid:
description:
- Name or globally unique identifier (UUID) to identify the port.
type: str
address:
description:
- Physical hardware address of this network Port, typically the
hardware MAC address.
type: str
node:
description:
- Name or globally unique identifier (UUID) to identify a Baremetal
Node.
type: str
ironic_url:
description:
- If noauth mode is utilized, this is required to be set to the
endpoint URL for the Ironic API. Use with "auth" and "auth_type"
settings set to None.
type: str
requirements:
- "python >= 3.6"
- "openstacksdk"
extends_documentation_fragment:
- openstack.cloud.openstack
'''
EXAMPLES = '''
# Gather information about all baremetal ports
- openstack.cloud.baremetal_port_info:
cloud: devstack
register: result
# Gather information about a baremetal port by address
- openstack.cloud.baremetal_port_info:
cloud: devstack
address: fa:16:3e:aa:aa:aa
register: result
# Gather information about a baremetal port by address
- openstack.cloud.baremetal_port_info:
cloud: devstack
uuid: a2b6bd99-77b9-43f0-9ddc-826568e68dec
register: result
# Gather information about a baremetal ports associated with a baremetal node
- openstack.cloud.baremetal_port_info:
cloud: devstack
node: bm-0
register: result
'''
RETURN = '''
baremetal_ports:
description: Bare Metal port list. A subset of the dictionary keys
listed below may be returned, depending on your cloud
provider.
returned: always, but can be null
type: list
elements: dict
contains:
address:
description: Physical hardware address of this network Port,
typically the hardware MAC address.
returned: success
type: str
created_at:
description: Bare Metal port created at timestamp.
returned: success
type: str
extra:
description: A set of one or more arbitrary metadata key and
value pairs.
returned: success
type: dict
id:
description: The UUID for the Baremetal Port resource.
returned: success
type: str
internal_info:
description: Internal metadata set and stored by the Port. This
field is read-only.
returned: success
type: dict
is_pxe_enabled:
description: Whether PXE is enabled or disabled on the Port.
returned: success
type: bool
local_link_connection:
description: The Port binding profile.
returned: success
type: dict
contains:
switch_id:
description: A MAC address or an OpenFlow based datapath_id of
the switch.
type: str
port_id:
description: Identifier of the physical port on the switch to
which node's port is connected to.
type: str
switch_info:
description: An optional string field to be used to store any
vendor-specific information.
type: str
location:
description: Cloud location of this resource (cloud, project,
region, zone)
returned: success
type: dict
name:
description: Bare Metal port name.
returned: success
type: str
node_id:
description: UUID of the Bare Metal Node this resource belongs to.
returned: success
type: str
physical_network:
description: The name of the physical network to which a port is
connected.
returned: success
type: str
port_group_id:
description: UUID of the Portgroup this resource belongs to.
returned: success
type: str
updated_at:
description: Bare Metal port updated at timestamp.
returned: success
type: str
'''
from ansible_collections.openstack.cloud.plugins.module_utils.ironic import (
IronicModule,
ironic_argument_spec,
)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
openstack_module_kwargs,
openstack_cloud_from_module
)
def main():
argument_spec = ironic_argument_spec(
uuid=dict(required=False),
address=dict(required=False),
node=dict(required=False),
)
module_kwargs = openstack_module_kwargs()
module_kwargs['supports_check_mode'] = True
module = IronicModule(argument_spec, **module_kwargs)
ports = list()
sdk, cloud = openstack_cloud_from_module(module)
try:
if module.params['uuid']:
port = cloud.baremetal.find_port(module.params['uuid'])
if not port:
module.fail_json(
msg='Baremetal port with uuid {uuid} was not found'
.format(uuid=module.params['uuid']))
ports.append(port)
elif module.params['address']:
ports = list(
cloud.baremetal.ports(address=module.params['address'],
details=True))
if not ports:
module.fail_json(
msg='Baremetal port with address {address} was not found'
.format(address=module.params['address']))
elif module.params['node']:
machine = cloud.get_machine(module.params['node'])
if not machine:
module.fail_json(
msg='Baremetal node {node} was not found'
.format(node=module.params['node']))
ports = list(
cloud.baremetal.ports(node_uuid=machine.uuid, details=True))
else:
ports = list(cloud.baremetal.ports(details=True))
# Convert ports to dictionaries and cleanup properties
ports = [port.to_dict() for port in ports]
for port in ports:
# links are not useful
port.pop('links', None)
module.exit_json(changed=False, baremetal_ports=ports)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
if __name__ == "__main__":
main()

View File

@@ -26,11 +26,13 @@ options:
- Is the service enabled
type: bool
default: 'yes'
service_type:
aliases: ['is_enabled']
type:
description:
- The type of service
required: true
type: str
aliases: ['service_type']
state:
description:
- Should the resource be present or absent.
@@ -51,14 +53,14 @@ EXAMPLES = '''
cloud: mycloud
state: present
name: glance
service_type: image
type: image
description: OpenStack Image Service
# Delete a service
- openstack.cloud.catalog_service:
cloud: mycloud
state: absent
name: glance
service_type: image
type: image
'''
RETURN = '''
@@ -75,6 +77,10 @@ service:
description: Service name.
type: str
sample: "glance"
type:
description: Service type.
type: str
sample: "image"
service_type:
description: Service type.
type: str
@@ -94,95 +100,90 @@ id:
sample: "3292f020780b4d5baf27ff7e1d224c44"
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _needs_update(module, service):
if service.enabled != module.params['enabled']:
return True
if service.description is not None and \
service.description != module.params['description']:
return True
return False
def _system_state_change(module, service):
state = module.params['state']
if state == 'absent' and service:
return True
if state == 'present':
if service is None:
return True
return _needs_update(module, service)
return False
def main():
argument_spec = openstack_full_argument_spec(
class IdentityCatalogServiceModule(OpenStackModule):
argument_spec = dict(
description=dict(default=None),
enabled=dict(default=True, type='bool'),
enabled=dict(default=True, aliases=['is_enabled'], type='bool'),
name=dict(required=True),
service_type=dict(required=True),
type=dict(required=True, aliases=['service_type']),
state=dict(default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec,
supports_check_mode=True,
**module_kwargs)
module_kwargs = dict(
supports_check_mode=True
)
description = module.params['description']
enabled = module.params['enabled']
name = module.params['name']
state = module.params['state']
service_type = module.params['service_type']
def _needs_update(self, service):
for parameter in ('enabled', 'description', 'type'):
if service[parameter] != self.params[parameter]:
return True
return False
sdk, cloud = openstack_cloud_from_module(module)
try:
services = cloud.search_services(name_or_id=name,
filters=dict(type=service_type))
if len(services) > 1:
module.fail_json(msg='Service name %s and type %s are not unique' %
(name, service_type))
elif len(services) == 1:
service = services[0]
else:
service = None
if module.check_mode:
module.exit_json(changed=_system_state_change(module, service))
def _system_state_change(self, service):
state = self.params['state']
if state == 'absent' and service:
return True
if state == 'present':
if service is None:
service = cloud.create_service(name=name, description=description,
type=service_type, enabled=True)
return True
return self._needs_update(service)
return False
def run(self):
description = self.params['description']
enabled = self.params['enabled']
name = self.params['name']
state = self.params['state']
type = self.params['type']
services = self.conn.search_services(
name_or_id=name, filters=(dict(type=type) if type else None))
service = None
if len(services) > 1:
self.fail_json(
msg='Service name %s and type %s are not unique'
% (name, type))
elif len(services) == 1:
service = services[0]
if self.ansible.check_mode:
self.exit_json(changed=self._system_state_change(service))
args = {'name': name, 'enabled': enabled, 'type': type}
if description:
args['description'] = description
if state == 'present':
if service is None:
service = self.conn.create_service(**args)
changed = True
else:
if _needs_update(module, service):
service = cloud.update_service(
service.id, name=name, type=service_type, enabled=enabled,
description=description)
if self._needs_update(service):
service = self.conn.update_service(service,
**args)
changed = True
else:
changed = False
module.exit_json(changed=changed, service=service, id=service.id)
self.exit_json(changed=changed, service=service, id=service.id)
elif state == 'absent':
if service is None:
changed = False
else:
cloud.delete_service(service.id)
self.conn.identity.delete_service(service.id)
changed = True
module.exit_json(changed=changed)
self.exit_json(changed=changed)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = IdentityCatalogServiceModule()
module()
if __name__ == '__main__':

View File

@@ -206,26 +206,11 @@ EXAMPLES = '''
node_count: 5
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _parse_labels(labels):
if isinstance(labels, str):
labels_dict = {}
for kv_str in labels.split(","):
k, v = kv_str.split("=")
labels_dict[k] = v
return labels_dict
if not labels:
return {}
return labels
def main():
argument_spec = openstack_full_argument_spec(
class CoeClusterModule(OpenStackModule):
argument_spec = dict(
cluster_template_id=dict(required=True),
discovery_url=dict(default=None),
docker_volume_size=dict(type='int'),
@@ -239,35 +224,46 @@ def main():
state=dict(default='present', choices=['absent', 'present']),
timeout=dict(type='int', default=60),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec, **module_kwargs)
module_kwargs = dict()
params = module.params.copy()
def _parse_labels(self, labels):
if isinstance(labels, str):
labels_dict = {}
for kv_str in labels.split(","):
k, v = kv_str.split("=")
labels_dict[k] = v
return labels_dict
if not labels:
return {}
return labels
state = module.params['state']
name = module.params['name']
cluster_template_id = module.params['cluster_template_id']
def run(self):
params = self.params.copy()
kwargs = dict(
discovery_url=module.params['discovery_url'],
docker_volume_size=module.params['docker_volume_size'],
flavor_id=module.params['flavor_id'],
keypair=module.params['keypair'],
labels=_parse_labels(params['labels']),
master_count=module.params['master_count'],
master_flavor_id=module.params['master_flavor_id'],
node_count=module.params['node_count'],
create_timeout=module.params['timeout'],
)
state = self.params['state']
name = self.params['name']
cluster_template_id = self.params['cluster_template_id']
kwargs = dict(
discovery_url=self.params['discovery_url'],
docker_volume_size=self.params['docker_volume_size'],
flavor_id=self.params['flavor_id'],
keypair=self.params['keypair'],
labels=self._parse_labels(params['labels']),
master_count=self.params['master_count'],
master_flavor_id=self.params['master_flavor_id'],
node_count=self.params['node_count'],
create_timeout=self.params['timeout'],
)
sdk, cloud = openstack_cloud_from_module(module)
try:
changed = False
cluster = cloud.get_coe_cluster(name_or_id=name, filters={'cluster_template_id': cluster_template_id})
cluster = self.conn.get_coe_cluster(
name_or_id=name, filters={'cluster_template_id': cluster_template_id})
if state == 'present':
if not cluster:
cluster = cloud.create_coe_cluster(name, cluster_template_id=cluster_template_id, **kwargs)
cluster = self.conn.create_coe_cluster(
name, cluster_template_id=cluster_template_id, **kwargs)
changed = True
else:
changed = False
@@ -278,15 +274,18 @@ def main():
# therefore try `id` first then `uuid`.
cluster_id = cluster.get('id', cluster.get('uuid'))
cluster['id'] = cluster['uuid'] = cluster_id
module.exit_json(changed=changed, cluster=cluster, id=cluster_id)
self.exit_json(changed=changed, cluster=cluster, id=cluster_id)
elif state == 'absent':
if not cluster:
module.exit_json(changed=False)
self.exit_json(changed=False)
else:
cloud.delete_coe_cluster(name)
module.exit_json(changed=True)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e), extra_data=e.extra_data)
self.conn.delete_coe_cluster(name)
self.exit_json(changed=True)
def main():
module = CoeClusterModule()
module()
if __name__ == "__main__":

View File

@@ -281,26 +281,11 @@ EXAMPLES = '''
public: no
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _parse_labels(labels):
if isinstance(labels, str):
labels_dict = {}
for kv_str in labels.split(","):
k, v = kv_str.split("=")
labels_dict[k] = v
return labels_dict
if not labels:
return {}
return labels
def main():
argument_spec = openstack_full_argument_spec(
class CoeClusterTemplateModule(OpenStackModule):
argument_spec = dict(
coe=dict(required=True, choices=['kubernetes', 'swarm', 'mesos']),
dns_nameserver=dict(default='8.8.8.8'),
docker_storage_driver=dict(choices=['devicemapper', 'overlay', 'overlay2']),
@@ -327,61 +312,76 @@ def main():
tls_disabled=dict(type='bool', default=False),
volume_driver=dict(choices=['cinder', 'rexray']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec, **module_kwargs)
module_kwargs = dict()
params = module.params.copy()
def _parse_labels(self, labels):
if isinstance(labels, str):
labels_dict = {}
for kv_str in labels.split(","):
k, v = kv_str.split("=")
labels_dict[k] = v
return labels_dict
if not labels:
return {}
return labels
state = module.params['state']
name = module.params['name']
coe = module.params['coe']
image_id = module.params['image_id']
def run(self):
params = self.params.copy()
kwargs = dict(
dns_nameserver=module.params['dns_nameserver'],
docker_storage_driver=module.params['docker_storage_driver'],
docker_volume_size=module.params['docker_volume_size'],
external_network_id=module.params['external_network_id'],
fixed_network=module.params['fixed_network'],
fixed_subnet=module.params['fixed_subnet'],
flavor_id=module.params['flavor_id'],
floating_ip_enabled=module.params['floating_ip_enabled'],
keypair_id=module.params['keypair_id'],
labels=_parse_labels(params['labels']),
http_proxy=module.params['http_proxy'],
https_proxy=module.params['https_proxy'],
master_lb_enabled=module.params['master_lb_enabled'],
master_flavor_id=module.params['master_flavor_id'],
network_driver=module.params['network_driver'],
no_proxy=module.params['no_proxy'],
public=module.params['public'],
registry_enabled=module.params['registry_enabled'],
server_type=module.params['server_type'],
tls_disabled=module.params['tls_disabled'],
volume_driver=module.params['volume_driver'],
)
state = self.params['state']
name = self.params['name']
coe = self.params['coe']
image_id = self.params['image_id']
kwargs = dict(
dns_nameserver=self.params['dns_nameserver'],
docker_storage_driver=self.params['docker_storage_driver'],
docker_volume_size=self.params['docker_volume_size'],
external_network_id=self.params['external_network_id'],
fixed_network=self.params['fixed_network'],
fixed_subnet=self.params['fixed_subnet'],
flavor_id=self.params['flavor_id'],
floating_ip_enabled=self.params['floating_ip_enabled'],
keypair_id=self.params['keypair_id'],
labels=self._parse_labels(params['labels']),
http_proxy=self.params['http_proxy'],
https_proxy=self.params['https_proxy'],
master_lb_enabled=self.params['master_lb_enabled'],
master_flavor_id=self.params['master_flavor_id'],
network_driver=self.params['network_driver'],
no_proxy=self.params['no_proxy'],
public=self.params['public'],
registry_enabled=self.params['registry_enabled'],
server_type=self.params['server_type'],
tls_disabled=self.params['tls_disabled'],
volume_driver=self.params['volume_driver'],
)
sdk, cloud = openstack_cloud_from_module(module)
try:
changed = False
template = cloud.get_coe_cluster_template(name_or_id=name, filters={'coe': coe, 'image_id': image_id})
template = self.conn.get_coe_cluster_template(
name_or_id=name, filters={'coe': coe, 'image_id': image_id})
if state == 'present':
if not template:
template = cloud.create_coe_cluster_template(name, coe=coe, image_id=image_id, **kwargs)
template = self.conn.create_coe_cluster_template(
name, coe=coe, image_id=image_id, **kwargs)
changed = True
else:
changed = False
module.exit_json(changed=changed, cluster_template=template, id=template['uuid'])
self.exit_json(
changed=changed, cluster_template=template, id=template['uuid'])
elif state == 'absent':
if not template:
module.exit_json(changed=False)
self.exit_json(changed=False)
else:
cloud.delete_coe_cluster_template(name)
module.exit_json(changed=True)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e), extra_data=e.extra_data)
self.conn.delete_coe_cluster_template(name)
self.exit_json(changed=True)
def main():
module = CoeClusterTemplateModule()
module()
if __name__ == "__main__":

View File

@@ -160,23 +160,11 @@ flavor:
"aggregate_instance_extra_specs:pinned": false
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _system_state_change(module, flavor):
state = module.params['state']
if state == 'present' and not flavor:
return True
if state == 'absent' and flavor:
return True
return False
def main():
argument_spec = openstack_full_argument_spec(
class ComputeFlavorModule(OpenStackModule):
argument_spec = dict(
state=dict(required=False, default='present',
choices=['absent', 'present']),
name=dict(required=True),
@@ -194,25 +182,30 @@ def main():
extra_specs=dict(required=False, default=None, type='dict'),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(
argument_spec,
supports_check_mode=True,
module_kwargs = dict(
required_if=[
('state', 'present', ['ram', 'vcpus', 'disk'])
],
**module_kwargs)
supports_check_mode=True
)
state = module.params['state']
name = module.params['name']
extra_specs = module.params['extra_specs'] or {}
def _system_state_change(self, flavor):
state = self.params['state']
if state == 'present' and not flavor:
return True
if state == 'absent' and flavor:
return True
return False
sdk, cloud = openstack_cloud_from_module(module)
try:
flavor = cloud.get_flavor(name)
def run(self):
state = self.params['state']
name = self.params['name']
extra_specs = self.params['extra_specs'] or {}
if module.check_mode:
module.exit_json(changed=_system_state_change(module, flavor))
flavor = self.conn.get_flavor(name)
if self.ansible.check_mode:
self.exit_json(changed=self._system_state_change(flavor))
if state == 'present':
old_extra_specs = {}
@@ -220,26 +213,32 @@ def main():
if flavor:
old_extra_specs = flavor['extra_specs']
for param_key in ['ram', 'vcpus', 'disk', 'ephemeral', 'swap', 'rxtx_factor', 'is_public']:
if module.params[param_key] != flavor[param_key]:
if flavor['swap'] == "":
flavor['swap'] = 0
for param_key in ['ram', 'vcpus', 'disk', 'ephemeral',
'swap', 'rxtx_factor', 'is_public']:
if self.params[param_key] != flavor[param_key]:
require_update = True
break
flavorid = self.params['flavorid']
if flavor and require_update:
cloud.delete_flavor(name)
self.conn.delete_flavor(name)
old_extra_specs = {}
if flavorid == 'auto':
flavorid = flavor['id']
flavor = None
if not flavor:
flavor = cloud.create_flavor(
flavor = self.conn.create_flavor(
name=name,
ram=module.params['ram'],
vcpus=module.params['vcpus'],
disk=module.params['disk'],
flavorid=module.params['flavorid'],
ephemeral=module.params['ephemeral'],
swap=module.params['swap'],
rxtx_factor=module.params['rxtx_factor'],
is_public=module.params['is_public']
ram=self.params['ram'],
vcpus=self.params['vcpus'],
disk=self.params['disk'],
flavorid=flavorid,
ephemeral=self.params['ephemeral'],
swap=self.params['swap'],
rxtx_factor=self.params['rxtx_factor'],
is_public=self.params['is_public']
)
changed = True
else:
@@ -249,25 +248,26 @@ def main():
unset_keys = set(old_extra_specs.keys()) - set(extra_specs.keys())
if unset_keys and not require_update:
cloud.unset_flavor_specs(flavor['id'], unset_keys)
self.conn.unset_flavor_specs(flavor['id'], unset_keys)
if old_extra_specs != new_extra_specs:
cloud.set_flavor_specs(flavor['id'], extra_specs)
self.conn.set_flavor_specs(flavor['id'], extra_specs)
changed = (changed or old_extra_specs != new_extra_specs)
module.exit_json(changed=changed,
flavor=flavor,
id=flavor['id'])
self.exit_json(
changed=changed, flavor=flavor, id=flavor['id'])
elif state == 'absent':
if flavor:
cloud.delete_flavor(name)
module.exit_json(changed=True)
module.exit_json(changed=False)
self.conn.delete_flavor(name)
self.exit_json(changed=True)
self.exit_json(changed=False)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = ComputeFlavorModule()
module()
if __name__ == '__main__':

View File

@@ -126,6 +126,29 @@ openstack_flavors:
returned: success
type: str
sample: "tiny"
description:
description: Description of the flavor
returned: success
type: str
sample: "Small flavor"
is_disabled:
description: Wether the flavor is enabled or not
returned: success
type: bool
sample: False
rxtx_factor:
description: Factor to be multiplied by the rxtx_base property of
the network it is attached to in order to have a
different bandwidth cap.
returned: success
type: float
sample: 1.0
extra_specs:
description: Optional parameters to configure different flavors
options.
returned: success
type: dict
sample: "{'hw_rng:allowed': True}"
disk:
description: Size of local disk, in GB.
returned: success
@@ -158,71 +181,66 @@ openstack_flavors:
sample: true
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def main():
argument_spec = openstack_full_argument_spec(
class ComputeFlavorInfoModule(OpenStackModule):
argument_spec = dict(
name=dict(required=False, default=None),
ram=dict(required=False, default=None),
vcpus=dict(required=False, default=None),
limit=dict(required=False, default=None, type='int'),
ephemeral=dict(required=False, default=None),
)
module_kwargs = openstack_module_kwargs(
module_kwargs = dict(
mutually_exclusive=[
['name', 'ram'],
['name', 'vcpus'],
['name', 'ephemeral']
]
],
supports_check_mode=True
)
module = AnsibleModule(argument_spec, **module_kwargs)
is_old_facts = module._name == 'openstack.cloud.compute_flavor_facts'
if is_old_facts:
module.deprecate("The 'openstack.cloud.compute_flavor_facts' module has been renamed to 'openstack.cloud.compute_flavor_info', "
"and the renamed one no longer returns ansible_facts", version='2.0.0',
collection_name='openstack.cloud')
name = module.params['name']
vcpus = module.params['vcpus']
ram = module.params['ram']
ephemeral = module.params['ephemeral']
limit = module.params['limit']
deprecated_names = ('openstack.cloud.compute_flavor_facts')
filters = {}
if vcpus:
filters['vcpus'] = vcpus
if ram:
filters['ram'] = ram
if ephemeral:
filters['ephemeral'] = ephemeral
def run(self):
name = self.params['name']
vcpus = self.params['vcpus']
ram = self.params['ram']
ephemeral = self.params['ephemeral']
limit = self.params['limit']
filters = {}
if vcpus:
filters['vcpus'] = vcpus
if ram:
filters['ram'] = ram
if ephemeral:
filters['ephemeral'] = ephemeral
sdk, cloud = openstack_cloud_from_module(module)
try:
if name:
flavors = cloud.search_flavors(filters={'name': name})
# extra_specs are exposed in the flavor representation since Rocky, so we do not
# need get_extra_specs=True which is not available in OpenStack SDK 0.36 (Train)
# Ref.: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html
flavor = self.conn.compute.find_flavor(name)
flavors = [flavor] if flavor else []
else:
flavors = cloud.list_flavors()
flavors = list(self.conn.compute.flavors())
if filters:
flavors = cloud.range_search(flavors, filters)
flavors = self.conn.range_search(flavors, filters)
if limit is not None:
flavors = flavors[:limit]
if is_old_facts:
module.exit_json(changed=False,
ansible_facts=dict(openstack_flavors=flavors))
else:
module.exit_json(changed=False,
openstack_flavors=flavors)
# Transform entries to dict
flavors = [flavor.to_dict(computed=True) for flavor in flavors]
self.exit_json(changed=False, openstack_flavors=flavors)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = ComputeFlavorInfoModule()
module()
if __name__ == '__main__':

View File

@@ -0,0 +1,122 @@
#!/usr/bin/python
# Copyright (c) 2016 Hewlett-Packard Enterprise Corporation
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
---
module: compute_service_info
short_description: Retrieve information about one or more OpenStack compute services
author: OpenStack Ansible SIG
description:
- Retrieve information about nova compute services
options:
binary:
description:
- Filter by service binary type. Requires openstacksdk>=0.53.
type: str
host:
description:
- Filter by service host. Requires openstacksdk>=0.53.
type: str
requirements:
- "python >= 3.6"
- "openstacksdk"
extends_documentation_fragment:
- openstack.cloud.openstack
'''
EXAMPLES = '''
# Gather information about compute services
- openstack.cloud.compute_service_info:
cloud: awesomecloud
binary: "nova-compute"
host: "localhost"
register: result
- openstack.cloud.compute_service_info:
cloud: awesomecloud
register: result
- debug:
msg: "{{ result.openstack_compute_services }}"
'''
RETURN = '''
openstack_compute_services:
description: has all the OpenStack information about compute services
returned: always, but can be null
type: complex
contains:
id:
description: Unique UUID.
returned: success
type: str
binary:
description: The binary name of the service.
returned: success
type: str
host:
description: The name of the host.
returned: success
type: str
disabled_reason:
description: The reason why the service is disabled
returned: success and OpenStack SDK >= 0.53
type: str
disables_reason:
description: The reason why the service is disabled
returned: success and OpenStack SDK < 0.53
type: str
availability_zone:
description: The availability zone name.
returned: success
type: str
is_forced_down:
description: If the service has been forced down or nova-compute
returned: success
type: bool
name:
description: Service name
returned: success
type: str
status:
description: The status of the service. One of enabled or disabled.
returned: success
type: str
state:
description: The state of the service. One of up or down.
returned: success
type: str
update_at:
description: The date and time when the resource was updated
returned: success
type: str
'''
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
class ComputeServiceInfoModule(OpenStackModule):
argument_spec = dict(
binary=dict(required=False, default=None, min_ver='0.53.0'),
host=dict(required=False, default=None, min_ver='0.53.0'),
)
module_kwargs = dict(
supports_check_mode=True
)
def run(self):
filters = self.check_versioned(binary=self.params['binary'], host=self.params['host'])
filters = {k: v for k, v in filters.items() if v is not None}
services = self.conn.compute.services(**filters)
services = [service.to_dict(computed=True) for service in services]
self.exit_json(changed=False, openstack_compute_services=services)
def main():
module = ComputeServiceInfoModule()
module()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,176 @@
#!/usr/bin/python
# coding: utf-8 -*-
#
# Copyright (c) 2021 by Open Telekom Cloud, operated by T-Systems International GmbH
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
---
module: dns_zone_info
short_description: Getting information about dns zones
author: OpenStack Ansible SIG
description:
- Getting information about dns zones. Output can be filtered.
options:
name:
description:
- Zone name.
type: str
type:
description:
- Zone type.
choices: [primary, secondary]
type: str
email:
description:
- Email of the zone owner (only applies if zone_type is primary).
type: str
description:
description:
- Zone description.
type: str
ttl:
description:
- TTL (Time To Live) value in seconds.
type: int
requirements:
- "python >= 3.6"
- "openstacksdk"
extends_documentation_fragment:
- openstack.cloud.openstack
'''
EXAMPLES = '''
# Create a zone named "example.net"
- openstack.cloud.dns_zones:
'''
RETURN = '''
zone:
description: Dictionary describing the zone.
returned: On success when I(state) is 'present'.
type: complex
contains:
action:
description: Current action in progress on the resource.
type: str
sample: "CREATE"
attributes:
description: Key:Value pairs of information about this zone, and the pool the user would like to place \
the zone in. This information can be used by the scheduler to place zones on the correct pool.
type: dict
sample: {"tier": "gold", "ha": "true"}
created_at:
description: Date / Time when resource was created.
type: str
sample: "2014-07-07T18:25:31.275934"
description:
description: Description for this zone.
type: str
sample: "This is an example zone."
email:
description: E-mail for the zone. Used in SOA records for the zone.
type: str
sample: "test@example.org"
id:
description: ID for the resource.
type: int
sample: "a86dba58-0043-4cc6-a1bb-69d5e86f3ca3"
links:
description: Links to the resource, and other related resources. When a response has been broken into\
pages, we will include a next link that should be followed to retrieve all results.
type: dict
sample: {"self": "https://127.0.0.1:9001/v2/zones/a86dba58-0043-4cc6-a1bb-69d5e86f3ca3"}
masters:
description: Mandatory for secondary zones. The servers to slave from to get DNS information.
type: list
sample: "[]"
name:
description: DNS Name for the zone.
type: str
sample: "test.test."
pool_id:
description: ID for the pool hosting this zone.
type: str
sample: "a86dba58-0043-4cc6-a1bb-69d5e86f3ca3"
project_id:
description: ID for the project that owns the resource.
type: str
sample: "4335d1f0-f793-11e2-b778-0800200c9a66"
serial:
description: Current serial number for the zone.
type: int
sample: 1404757531
status:
description: Status of the resource.
type: str
sample: "ACTIVE"
ttl:
description: TTL (Time to Live) for the zone.
type: int
sample: 7200
type:
description: Type of zone. PRIMARY is controlled by Designate, SECONDARY zones are slaved from another\
DNS Server. Defaults to PRIMARY
type: str
sample: "PRIMARY"
updated_at:
description: Date / Time when resource last updated.
type: str
sample: "2014-07-07T18:25:31.275934"
'''
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
class DnsZoneInfoModule(OpenStackModule):
argument_spec = dict(
name=dict(required=False, type='str'),
type=dict(required=False, choices=['primary', 'secondary'], type='str'),
email=dict(required=False, type='str'),
description=dict(required=False, type='str'),
ttl=dict(required=False, type='int')
)
module_kwargs = dict(
supports_check_mode=True
)
def run(self):
name = self.params['name']
type = self.params['type']
email = self.params['email']
description = self.params['description']
ttl = self.params['ttl']
kwargs = {}
if name:
kwargs['name'] = name
if type:
kwargs['type'] = type
if email:
kwargs['email'] = email
if description:
kwargs['description'] = description
if ttl:
kwargs['ttl'] = ttl
data = [zone.to_dict(computed=False) for zone in
self.conn.dns.zones(**kwargs)]
self.exit_json(zones=data, changed=False)
def main():
module = DnsZoneInfoModule()
module()
if __name__ == '__main__':
main()

View File

@@ -81,57 +81,41 @@ endpoint:
description: Endpoint ID.
type: str
sample: 3292f020780b4d5baf27ff7e1d224c44
interface:
description: Endpoint Interface.
type: str
sample: public
enabled:
description: Service status.
type: bool
sample: True
links:
description: Links for the endpoint
type: str
sample: http://controller/identity/v3/endpoints/123
region:
description: Region Name.
description: Same as C(region_id). Deprecated.
type: str
sample: RegionOne
region_id:
description: Region ID.
type: str
sample: RegionOne
service_id:
description: Service ID.
type: str
sample: b91f1318f735494a825a55388ee118f3
interface:
description: Endpoint Interface.
type: str
sample: public
url:
description: Service URL.
type: str
sample: http://controller:9292
enabled:
description: Service status.
type: bool
sample: True
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _needs_update(module, endpoint):
if endpoint.enabled != module.params['enabled']:
return True
if endpoint.url != module.params['url']:
return True
return False
def _system_state_change(module, endpoint):
state = module.params['state']
if state == 'absent' and endpoint:
return True
if state == 'present':
if endpoint is None:
return True
return _needs_update(module, endpoint)
return False
def main():
argument_spec = openstack_full_argument_spec(
class IdentityEndpointModule(OpenStackModule):
argument_spec = dict(
service=dict(type='str', required=True),
endpoint_interface=dict(type='str', required=True, choices=['admin', 'public', 'internal']),
url=dict(type='str', required=True),
@@ -140,71 +124,94 @@ def main():
state=dict(type='str', default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec,
supports_check_mode=True,
**module_kwargs)
module_kwargs = dict(
supports_check_mode=True
)
service_name_or_id = module.params['service']
interface = module.params['endpoint_interface']
url = module.params['url']
region = module.params['region']
enabled = module.params['enabled']
state = module.params['state']
def _needs_update(self, endpoint):
if endpoint.enabled != self.params['enabled']:
return True
if endpoint.url != self.params['url']:
return True
return False
sdk, cloud = openstack_cloud_from_module(module)
try:
def _system_state_change(self, endpoint):
state = self.params['state']
if state == 'absent' and endpoint:
return True
if state == 'present':
if endpoint is None:
return True
return self._needs_update(endpoint)
return False
def run(self):
service_name_or_id = self.params['service']
interface = self.params['endpoint_interface']
url = self.params['url']
region = self.params['region']
enabled = self.params['enabled']
state = self.params['state']
service = self.conn.get_service(service_name_or_id)
service = cloud.get_service(service_name_or_id)
if service is None and state == 'absent':
module.exit_json(changed=False)
self.exit_json(changed=False)
elif service is None and state == 'present':
module.fail_json(msg='Service %s does not exist' % service_name_or_id)
if service is None and state == 'present':
self.fail_json(msg='Service %s does not exist' % service_name_or_id)
filters = dict(service_id=service.id, interface=interface)
if region is not None:
filters['region'] = region
endpoints = cloud.search_endpoints(filters=filters)
endpoints = self.conn.search_endpoints(filters=filters)
endpoint = None
if len(endpoints) > 1:
module.fail_json(msg='Service %s, interface %s and region %s are '
'not unique' %
(service_name_or_id, interface, region))
self.fail_json(msg='Service %s, interface %s and region %s are '
'not unique' %
(service_name_or_id, interface, region))
elif len(endpoints) == 1:
endpoint = endpoints[0]
else:
endpoint = None
if module.check_mode:
module.exit_json(changed=_system_state_change(module, endpoint))
if self.ansible.check_mode:
self.exit_json(changed=self._system_state_change(endpoint))
if state == 'present':
if endpoint is None:
result = cloud.create_endpoint(service_name_or_id=service,
url=url, interface=interface,
region=region, enabled=enabled)
endpoint = result[0]
args = {'url': url, 'interface': interface,
'service_name_or_id': service.id, 'enabled': enabled,
'region': region}
endpoints = self.conn.create_endpoint(**args)
# safe because endpoints contains a single item when url is
# given to self.conn.create_endpoint()
endpoint = endpoints[0]
changed = True
else:
if _needs_update(module, endpoint):
endpoint = cloud.update_endpoint(
if self._needs_update(endpoint):
endpoint = self.conn.update_endpoint(
endpoint.id, url=url, enabled=enabled)
changed = True
else:
changed = False
module.exit_json(changed=changed, endpoint=endpoint)
self.exit_json(changed=changed,
endpoint=endpoint)
elif state == 'absent':
if endpoint is None:
changed = False
else:
cloud.delete_endpoint(endpoint.id)
self.conn.delete_endpoint(endpoint.id)
changed = True
module.exit_json(changed=changed)
self.exit_json(changed=changed)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = IdentityEndpointModule()
module()
if __name__ == '__main__':

View File

@@ -72,124 +72,11 @@ EXAMPLES = '''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_module_kwargs
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_cloud_from_module
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def normalize_idp(idp):
"""
Normalizes the IDP definitions so that the outputs are consistent with the
parameters
- "enabled" (parameter) == "is_enabled" (SDK)
- "name" (parameter) == "id" (SDK)
"""
if idp is None:
return None
_idp = idp.to_dict()
_idp['enabled'] = idp['is_enabled']
_idp['name'] = idp['id']
return _idp
def delete_identity_provider(module, sdk, cloud, idp):
"""
Delete an existing Identity Provider
returns: the "Changed" state
"""
if idp is None:
return False
if module.check_mode:
return True
try:
cloud.identity.delete_identity_provider(idp)
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to delete identity provider: {0}'.format(str(ex)))
return True
def create_identity_provider(module, sdk, cloud, name):
"""
Create a new Identity Provider
returns: the "Changed" state and the new identity provider
"""
if module.check_mode:
return True, None
description = module.params.get('description')
enabled = module.params.get('enabled')
domain_id = module.params.get('domain_id')
remote_ids = module.params.get('remote_ids')
if enabled is None:
enabled = True
if remote_ids is None:
remote_ids = []
attributes = {
'domain_id': domain_id,
'enabled': enabled,
'remote_ids': remote_ids,
}
if description is not None:
attributes['description'] = description
try:
idp = cloud.identity.create_identity_provider(id=name, **attributes)
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to create identity provider: {0}'.format(str(ex)))
return (True, idp)
def update_identity_provider(module, sdk, cloud, idp):
"""
Update an existing Identity Provider
returns: the "Changed" state and the new identity provider
"""
description = module.params.get('description')
enabled = module.params.get('enabled')
domain_id = module.params.get('domain_id')
remote_ids = module.params.get('remote_ids')
attributes = {}
if (description is not None) and (description != idp.description):
attributes['description'] = description
if (enabled is not None) and (enabled != idp.is_enabled):
attributes['enabled'] = enabled
if (domain_id is not None) and (domain_id != idp.domain_id):
attributes['domain_id'] = domain_id
if (remote_ids is not None) and (remote_ids != idp.remote_ids):
attributes['remote_ids'] = remote_ids
if not attributes:
return False, idp
if module.check_mode:
return True, None
try:
new_idp = cloud.identity.update_identity_provider(idp, **attributes)
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to update identity provider: {0}'.format(str(ex)))
return (True, new_idp)
def main():
""" Module entry point """
argument_spec = openstack_full_argument_spec(
class IdentityFederationIdpModule(OpenStackModule):
argument_spec = dict(
name=dict(required=True, aliases=['id']),
state=dict(default='present', choices=['absent', 'present']),
description=dict(),
@@ -197,45 +84,136 @@ def main():
enabled=dict(type='bool', aliases=['is_enabled']),
remote_ids=dict(type='list', elements='str'),
)
module_kwargs = openstack_module_kwargs(
)
module = AnsibleModule(
argument_spec,
module_kwargs = dict(
supports_check_mode=True,
**module_kwargs
)
name = module.params.get('name')
state = module.params.get('state')
changed = False
def normalize_idp(self, idp):
"""
Normalizes the IDP definitions so that the outputs are consistent with the
parameters
sdk, cloud = openstack_cloud_from_module(module, min_version="0.44")
try:
idp = cloud.identity.get_identity_provider(name)
except sdk.exceptions.ResourceNotFound:
idp = None
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to get identity provider: {0}'.format(str(ex)))
if state == 'absent':
if idp is not None:
changed = delete_identity_provider(module, sdk, cloud, idp)
module.exit_json(changed=changed)
# state == 'present'
else:
- "enabled" (parameter) == "is_enabled" (SDK)
- "name" (parameter) == "id" (SDK)
"""
if idp is None:
if module.params.get('domain_id') is None:
module.fail_json(msg='A domain_id must be passed when creating'
' an identity provider')
(changed, idp) = create_identity_provider(module, sdk, cloud, name)
idp = normalize_idp(idp)
module.exit_json(changed=changed, identity_provider=idp)
return None
(changed, new_idp) = update_identity_provider(module, sdk, cloud, idp)
new_idp = normalize_idp(new_idp)
module.exit_json(changed=changed, identity_provider=new_idp)
_idp = idp.to_dict()
_idp['enabled'] = idp['is_enabled']
_idp['name'] = idp['id']
return _idp
def delete_identity_provider(self, idp):
"""
Delete an existing Identity Provider
returns: the "Changed" state
"""
if idp is None:
return False
if self.ansible.check_mode:
return True
self.conn.identity.delete_identity_provider(idp)
return True
def create_identity_provider(self, name):
"""
Create a new Identity Provider
returns: the "Changed" state and the new identity provider
"""
if self.ansible.check_mode:
return True, None
description = self.params.get('description')
enabled = self.params.get('enabled')
domain_id = self.params.get('domain_id')
remote_ids = self.params.get('remote_ids')
if enabled is None:
enabled = True
if remote_ids is None:
remote_ids = []
attributes = {
'domain_id': domain_id,
'enabled': enabled,
'remote_ids': remote_ids,
}
if description is not None:
attributes['description'] = description
idp = self.conn.identity.create_identity_provider(id=name, **attributes)
return (True, idp)
def update_identity_provider(self, idp):
"""
Update an existing Identity Provider
returns: the "Changed" state and the new identity provider
"""
description = self.params.get('description')
enabled = self.params.get('enabled')
domain_id = self.params.get('domain_id')
remote_ids = self.params.get('remote_ids')
attributes = {}
if (description is not None) and (description != idp.description):
attributes['description'] = description
if (enabled is not None) and (enabled != idp.is_enabled):
attributes['enabled'] = enabled
if (domain_id is not None) and (domain_id != idp.domain_id):
attributes['domain_id'] = domain_id
if (remote_ids is not None) and (remote_ids != idp.remote_ids):
attributes['remote_ids'] = remote_ids
if not attributes:
return False, idp
if self.ansible.check_mode:
return True, None
new_idp = self.conn.identity.update_identity_provider(idp, **attributes)
return (True, new_idp)
def run(self):
""" Module entry point """
name = self.params.get('name')
state = self.params.get('state')
changed = False
idp = self.conn.identity.find_identity_provider(name)
if state == 'absent':
if idp is not None:
changed = self.delete_identity_provider(idp)
self.exit_json(changed=changed)
# state == 'present'
else:
if idp is None:
if self.params.get('domain_id') is None:
self.fail_json(msg='A domain_id must be passed when creating'
' an identity provider')
(changed, idp) = self.create_identity_provider(name)
idp = self.normalize_idp(idp)
self.exit_json(changed=changed, identity_provider=idp)
(changed, new_idp) = self.update_identity_provider(idp)
new_idp = self.normalize_idp(new_idp)
self.exit_json(changed=changed, identity_provider=new_idp)
def main():
module = IdentityFederationIdpModule()
module()
if __name__ == '__main__':

View File

@@ -39,62 +39,50 @@ EXAMPLES = '''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_module_kwargs
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_cloud_from_module
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def normalize_idp(idp):
"""
Normalizes the IDP definitions so that the outputs are consistent with the
parameters
class IdentityFederationIdpInfoModule(OpenStackModule):
argument_spec = dict(
name=dict(aliases=['id']),
)
module_kwargs = dict(
supports_check_mode=True
)
- "enabled" (parameter) == "is_enabled" (SDK)
- "name" (parameter) == "id" (SDK)
"""
if idp is None:
return
def normalize_idp(self, idp):
"""
Normalizes the IDP definitions so that the outputs are consistent with the
parameters
_idp = idp.to_dict()
_idp['enabled'] = idp['is_enabled']
_idp['name'] = idp['id']
return _idp
- "enabled" (parameter) == "is_enabled" (SDK)
- "name" (parameter) == "id" (SDK)
"""
if idp is None:
return
_idp = idp.to_dict()
_idp['enabled'] = idp['is_enabled']
_idp['name'] = idp['id']
return _idp
def run(self):
""" Module entry point """
name = self.params.get('name')
if name:
idp = self.normalize_idp(self.conn.identity.get_identity_provider(name))
self.exit_json(changed=False, identity_providers=[idp])
else:
providers = list(map(self.normalize_idp, self.conn.identity.identity_providers()))
self.exit_json(changed=False, identity_providers=providers)
def main():
""" Module entry point """
argument_spec = openstack_full_argument_spec(
name=dict(aliases=['id']),
)
module_kwargs = openstack_module_kwargs(
)
module = AnsibleModule(
argument_spec,
supports_check_mode=True,
**module_kwargs
)
name = module.params.get('name')
sdk, cloud = openstack_cloud_from_module(module, min_version="0.44")
if name:
try:
idp = normalize_idp(cloud.identity.get_identity_provider(name))
except sdk.exceptions.ResourceNotFound:
module.fail_json(msg='Failed to find identity provider')
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to get identity provider: {0}'.format(str(ex)))
module.exit_json(changed=False, identity_providers=[idp])
else:
try:
providers = list(map(normalize_idp, cloud.identity.identity_providers()))
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to list identity providers: {0}'.format(str(ex)))
module.exit_json(changed=False, identity_providers=providers)
module = IdentityFederationIdpInfoModule()
module()
if __name__ == '__main__':

View File

@@ -78,93 +78,11 @@ EXAMPLES = '''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_module_kwargs
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_cloud_from_module
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def normalize_mapping(mapping):
"""
Normalizes the mapping definitions so that the outputs are consistent with
the parameters
- "name" (parameter) == "id" (SDK)
"""
if mapping is None:
return None
_mapping = mapping.to_dict()
_mapping['name'] = mapping['id']
return _mapping
def create_mapping(module, sdk, cloud, name):
"""
Attempt to create a Mapping
returns: A tuple containing the "Changed" state and the created mapping
"""
if module.check_mode:
return (True, None)
rules = module.params.get('rules')
try:
mapping = cloud.identity.create_mapping(id=name, rules=rules)
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to create mapping: {0}'.format(str(ex)))
return (True, mapping)
def delete_mapping(module, sdk, cloud, mapping):
"""
Attempt to delete a Mapping
returns: the "Changed" state
"""
if mapping is None:
return False
if module.check_mode:
return True
try:
cloud.identity.delete_mapping(mapping)
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to delete mapping: {0}'.format(str(ex)))
return True
def update_mapping(module, sdk, cloud, mapping):
"""
Attempt to delete a Mapping
returns: The "Changed" state and the the new mapping
"""
current_rules = mapping.rules
new_rules = module.params.get('rules')
# Nothing to do
if current_rules == new_rules:
return (False, mapping)
if module.check_mode:
return (True, None)
try:
new_mapping = cloud.identity.update_mapping(mapping, rules=new_rules)
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to update mapping: {0}'.format(str(ex)))
return (True, new_mapping)
def main():
""" Module entry point """
argument_spec = openstack_full_argument_spec(
class IdentityFederationMappingModule(OpenStackModule):
argument_spec = dict(
name=dict(required=True, aliases=['id']),
state=dict(default='present', choices=['absent', 'present']),
rules=dict(type='list', elements='dict', options=dict(
@@ -172,46 +90,107 @@ def main():
remote=dict(required=True, type='list', elements='dict')
)),
)
module_kwargs = openstack_module_kwargs(
required_if=[('state', 'present', ['rules'])]
)
module = AnsibleModule(
argument_spec,
supports_check_mode=True,
**module_kwargs
module_kwargs = dict(
required_if=[('state', 'present', ['rules'])],
supports_check_mode=True
)
name = module.params.get('name')
state = module.params.get('state')
changed = False
sdk, cloud = openstack_cloud_from_module(module, min_version="0.44")
try:
mapping = cloud.identity.get_mapping(name)
except sdk.exceptions.ResourceNotFound:
mapping = None
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to fetch mapping: {0}'.format(str(ex)))
if state == 'absent':
if mapping is not None:
changed = delete_mapping(module, sdk, cloud, mapping)
module.exit_json(changed=changed)
# state == 'present'
else:
if len(module.params.get('rules')) < 1:
module.fail_json(msg='At least one rule must be passed')
def normalize_mapping(self, mapping):
"""
Normalizes the mapping definitions so that the outputs are consistent with
the parameters
- "name" (parameter) == "id" (SDK)
"""
if mapping is None:
(changed, mapping) = create_mapping(module, sdk, cloud, name)
mapping = normalize_mapping(mapping)
module.exit_json(changed=changed, mapping=mapping)
return None
_mapping = mapping.to_dict()
_mapping['name'] = mapping['id']
return _mapping
def create_mapping(self, name):
"""
Attempt to create a Mapping
returns: A tuple containing the "Changed" state and the created mapping
"""
if self.ansible.check_mode:
return (True, None)
rules = self.params.get('rules')
mapping = self.conn.identity.create_mapping(id=name, rules=rules)
return (True, mapping)
def delete_mapping(self, mapping):
"""
Attempt to delete a Mapping
returns: the "Changed" state
"""
if mapping is None:
return False
if self.ansible.check_mode:
return True
self.conn.identity.delete_mapping(mapping)
return True
def update_mapping(self, mapping):
"""
Attempt to delete a Mapping
returns: The "Changed" state and the the new mapping
"""
current_rules = mapping.rules
new_rules = self.params.get('rules')
# Nothing to do
if current_rules == new_rules:
return (False, mapping)
if self.ansible.check_mode:
return (True, None)
new_mapping = self.conn.identity.update_mapping(mapping, rules=new_rules)
return (True, new_mapping)
def run(self):
""" Module entry point """
name = self.params.get('name')
state = self.params.get('state')
changed = False
mapping = self.conn.identity.find_mapping(name)
if state == 'absent':
if mapping is not None:
changed = self.delete_mapping(mapping)
self.exit_json(changed=changed)
# state == 'present'
else:
(changed, new_mapping) = update_mapping(module, sdk, cloud, mapping)
new_mapping = normalize_mapping(new_mapping)
module.exit_json(mapping=new_mapping, changed=changed)
if len(self.params.get('rules')) < 1:
self.fail_json(msg='At least one rule must be passed')
if mapping is None:
(changed, mapping) = self.create_mapping(name)
mapping = self.normalize_mapping(mapping)
self.exit_json(changed=changed, mapping=mapping)
else:
(changed, new_mapping) = self.update_mapping(mapping)
new_mapping = self.normalize_mapping(new_mapping)
self.exit_json(mapping=new_mapping, changed=changed)
def main():
module = IdentityFederationMappingModule()
module()
if __name__ == '__main__':

View File

@@ -38,60 +38,50 @@ EXAMPLES = '''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_module_kwargs
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_cloud_from_module
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def normalize_mapping(mapping):
"""
Normalizes the mapping definitions so that the outputs are consistent with the
parameters
class IdentityFederationMappingInfoModule(OpenStackModule):
argument_spec = dict(
name=dict(aliases=['id']),
)
module_kwargs = dict(
supports_check_mode=True
)
- "name" (parameter) == "id" (SDK)
"""
if mapping is None:
return None
module_min_sdk_version = "0.44"
_mapping = mapping.to_dict()
_mapping['name'] = mapping['id']
return _mapping
def normalize_mapping(self, mapping):
"""
Normalizes the mapping definitions so that the outputs are consistent with the
parameters
- "name" (parameter) == "id" (SDK)
"""
if mapping is None:
return None
_mapping = mapping.to_dict()
_mapping['name'] = mapping['id']
return _mapping
def run(self):
""" Module entry point """
name = self.params.get('name')
if name:
mapping = self.normalize_mapping(
self.conn.identity.get_mapping(name))
self.exit_json(changed=False, mappings=[mapping])
else:
mappings = list(map(
self.normalize_mapping, self.conn.identity.mappings()))
self.exit_json(changed=False, mappings=mappings)
def main():
""" Module entry point """
argument_spec = openstack_full_argument_spec(
name=dict(aliases=['id']),
)
module_kwargs = openstack_module_kwargs(
)
module = AnsibleModule(
argument_spec,
supports_check_mode=True,
**module_kwargs
)
name = module.params.get('name')
sdk, cloud = openstack_cloud_from_module(module, min_version="0.44")
if name:
try:
mapping = normalize_mapping(cloud.identity.get_mapping(name))
except sdk.exceptions.ResourceNotFound:
module.fail_json(msg='Failed to find mapping')
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to get mapping: {0}'.format(str(ex)))
module.exit_json(changed=False, mappings=[mapping])
else:
try:
mappings = list(map(normalize_mapping, cloud.identity.mappings()))
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to list mappings: {0}'.format(str(ex)))
module.exit_json(changed=False, mappings=mappings)
module = IdentityFederationMappingInfoModule()
module()
if __name__ == '__main__':

View File

@@ -11,6 +11,7 @@ short_description: Add/Remove floating IP from an instance
description:
- Add or Remove a floating IP to an instance.
- Returns the floating IP when attaching only if I(wait=true).
- When detaching a floating IP there might be a delay until an instance does not list the floating IP any more.
options:
server:
description:
@@ -24,9 +25,9 @@ options:
type: str
floating_ip_address:
description:
- A floating IP address to attach or to detach. Required only if I(state)
is absent. When I(state) is present can be used to specify a IP address
to attach.
- A floating IP address to attach or to detach. When I(state) is present
can be used to specify a IP address to attach. I(floating_ip_address)
requires I(network) to be set.
type: str
reuse:
description:
@@ -49,7 +50,7 @@ options:
wait:
description:
- When attaching a floating IP address, specify whether to wait for it to appear as attached.
- Must be set to C(yes) for the module to return the value of the floating IP.
- Must be set to C(yes) for the module to return the value of the floating IP when attaching.
type: bool
default: 'no'
timeout:
@@ -118,23 +119,12 @@ EXAMPLES = '''
server: cattle001
'''
from ansible.module_utils.basic import AnsibleModule, remove_values
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
import itertools
def _get_floating_ip(cloud, floating_ip_address):
f_ips = cloud.search_floating_ips(
filters={'floating_ip_address': floating_ip_address})
if not f_ips:
return None
return f_ips[0]
def main():
argument_spec = openstack_full_argument_spec(
class NetworkingFloatingIPModule(OpenStackModule):
argument_spec = dict(
server=dict(required=True),
state=dict(default='present', choices=['absent', 'present']),
network=dict(required=False, default=None),
@@ -148,107 +138,169 @@ def main():
purge=dict(required=False, type='bool', default=False),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec, **module_kwargs)
module_kwargs = dict(
required_if=[
['state', 'absent', ['floating_ip_address']]
],
required_by=dict(
floating_ip_address=('network',)
)
)
server_name_or_id = module.params['server']
state = module.params['state']
network = module.params['network']
floating_ip_address = module.params['floating_ip_address']
reuse = module.params['reuse']
fixed_address = module.params['fixed_address']
nat_destination = module.params['nat_destination']
wait = module.params['wait']
timeout = module.params['timeout']
purge = module.params['purge']
def _get_floating_ip(self, floating_ip_address):
f_ips = self.conn.search_floating_ips(
filters={'floating_ip_address': floating_ip_address})
sdk, cloud = openstack_cloud_from_module(module)
try:
if not f_ips:
return None
server = cloud.get_server(server_name_or_id)
if server is None:
module.fail_json(
return f_ips[0]
def _list_floating_ips(self, server):
return itertools.chain.from_iterable([
(addr['addr'] for addr in server.addresses[net] if addr['OS-EXT-IPS:type'] == 'floating')
for net in server.addresses
])
def _match_floating_ip(self, server,
floating_ip_address,
network_id,
fixed_address,
nat_destination):
if floating_ip_address:
return self._get_floating_ip(floating_ip_address)
elif not fixed_address and nat_destination:
nat_destination_name = self.conn.get_network(nat_destination)['name']
return next(
(self._get_floating_ip(addr['addr'])
for addr in server.addresses.get(nat_destination_name, [])
if addr['OS-EXT-IPS:type'] == 'floating'),
None)
else:
# not floating_ip_address and (fixed_address or not nat_destination)
# get any of the floating ips that matches fixed_address and/or network
f_ip_addrs = self._list_floating_ips(server)
f_ips = [f_ip for f_ip in self.conn.list_floating_ips() if f_ip['floating_ip_address'] in f_ip_addrs]
return next(
(f_ip for f_ip in f_ips
if ((fixed_address and f_ip.fixed_ip_address == fixed_address) or not fixed_address)
and ((network_id and f_ip.network == network_id) or not network_id)),
None)
def run(self):
server_name_or_id = self.params['server']
state = self.params['state']
network = self.params['network']
floating_ip_address = self.params['floating_ip_address']
reuse = self.params['reuse']
fixed_address = self.params['fixed_address']
nat_destination = self.params['nat_destination']
wait = self.params['wait']
timeout = self.params['timeout']
purge = self.params['purge']
server = self.conn.get_server(server_name_or_id)
if not server:
self.fail_json(
msg="server {0} not found".format(server_name_or_id))
# Extract floating ips from server
f_ip_addrs = self._list_floating_ips(server)
# Get details about requested floating ip
f_ip = self._get_floating_ip(floating_ip_address) if floating_ip_address else None
if network:
network_id = self.conn.get_network(name_or_id=network)["id"]
else:
network_id = None
if state == 'present':
# If f_ip already assigned to server, check that it matches
# requirements.
public_ip = cloud.get_server_public_ip(server)
f_ip = _get_floating_ip(cloud, public_ip) if public_ip else public_ip
if f_ip:
if network:
network_id = cloud.get_network(name_or_id=network)["id"]
else:
network_id = None
# check if we have floating ip on given nat_destination network
if nat_destination:
nat_floating_addrs = [
addr for addr in server.addresses.get(
cloud.get_network(nat_destination)['name'], [])
if addr['addr'] == public_ip
and addr['OS-EXT-IPS:type'] == 'floating'
]
if floating_ip_address and f_ip and floating_ip_address in f_ip_addrs:
# Floating ip address has been assigned to server
self.exit_json(changed=False, floating_ip=f_ip)
if len(nat_floating_addrs) == 0:
module.fail_json(msg="server {server} already has a "
"floating-ip on a different "
"nat-destination than '{nat_destination}'"
.format(server=server_name_or_id,
nat_destination=nat_destination))
if f_ip and f_ip['attached'] and floating_ip_address not in f_ip_addrs:
# Requested floating ip has been attached to different server
self.fail_json(msg="floating-ip {floating_ip_address} already has been attached to different server"
.format(floating_ip_address=floating_ip_address))
if all([fixed_address, f_ip.fixed_ip_address == fixed_address,
network, f_ip.network != network_id]):
# Current state definitely conflicts with requirements
module.fail_json(msg="server {server} already has a "
"floating-ip on requested "
"interface but it doesn't match "
"requested network {network}: {fip}"
.format(server=server_name_or_id,
network=network,
fip=remove_values(f_ip,
module.no_log_values)))
if not network or f_ip.network == network_id:
# Requirements are met
module.exit_json(changed=False, floating_ip=f_ip)
if not floating_ip_address:
# No specific floating ip requested, i.e. if any floating ip is already assigned to server,
# check that it matches requirements.
# Requirements are vague enough to ignore existing f_ip and try
# to create a new f_ip to the server.
if not fixed_address and nat_destination:
# Check if we have any floating ip on the given nat_destination network
nat_destination_name = self.conn.get_network(nat_destination)['name']
for addr in server.addresses.get(nat_destination_name, []):
if addr['OS-EXT-IPS:type'] == 'floating':
# A floating ip address has been assigned to the requested nat_destination
f_ip = self._get_floating_ip(addr['addr'])
self.exit_json(changed=False, floating_ip=f_ip)
# else fixed_address or not nat_destination, hence an
# analysis of all floating ips of server is required
f_ips = [f_ip for f_ip in self.conn.list_floating_ips() if f_ip['floating_ip_address'] in f_ip_addrs]
for f_ip in f_ips:
if network_id and f_ip.network != network_id:
# requested network does not match network of floating ip
continue
server = cloud.add_ips_to_server(
server=server, ips=floating_ip_address, ip_pool=network,
reuse=reuse, fixed_address=fixed_address, wait=wait,
if not fixed_address and not nat_destination:
# any floating ip will fullfil these requirements
self.exit_json(changed=False, floating_ip=f_ip)
if fixed_address and f_ip.fixed_ip_address == fixed_address:
# a floating ip address has been assigned that points to the requested fixed_address
self.exit_json(changed=False, floating_ip=f_ip)
if floating_ip_address and not f_ip:
# openstacksdk's create_ip requires floating_ip_address and floating_network_id to be set
self.conn.network.create_ip(floating_ip_address=floating_ip_address, floating_network_id=network_id)
# Else floating ip either does not exist or has not been attached yet
# Both floating_ip_address and network are mutually exclusive in add_ips_to_server, i.e.
# add_ips_to_server will ignore floating_ip_address if network is set
# Ref.: https://github.com/openstack/openstacksdk/blob/a6b0ece2821ea79330c4067100295f6bdcbe456e/openstack/cloud/_floating_ip.py#L987
server = self.conn.add_ips_to_server(
server=server,
ips=floating_ip_address,
ip_pool=network if not floating_ip_address else None,
reuse=reuse,
fixed_address=fixed_address,
wait=wait,
timeout=timeout, nat_destination=nat_destination)
fip_address = cloud.get_server_public_ip(server)
# Update the floating IP status
f_ip = _get_floating_ip(cloud, fip_address)
module.exit_json(changed=True, floating_ip=f_ip)
# Update the floating ip status
f_ip = self._match_floating_ip(server, floating_ip_address, network_id, fixed_address, nat_destination)
self.exit_json(changed=True, floating_ip=f_ip)
elif state == 'absent':
if floating_ip_address is None:
if not server_name_or_id:
module.fail_json(msg="either server or floating_ip_address are required")
server = cloud.get_server(server_name_or_id)
floating_ip_address = cloud.get_server_public_ip(server)
f_ip = _get_floating_ip(cloud, floating_ip_address)
f_ip = self._match_floating_ip(server, floating_ip_address, network_id, fixed_address, nat_destination)
if not f_ip:
# Nothing to detach
module.exit_json(changed=False)
self.exit_json(changed=False)
changed = False
if f_ip["fixed_ip_address"]:
cloud.detach_ip_from_server(
server_id=server['id'], floating_ip_id=f_ip['id'])
# Update the floating IP status
f_ip = cloud.get_floating_ip(id=f_ip['id'])
changed = True
if purge:
cloud.delete_floating_ip(f_ip['id'])
module.exit_json(changed=True)
module.exit_json(changed=changed, floating_ip=f_ip)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e), extra_data=e.extra_data)
if f_ip["fixed_ip_address"]:
self.conn.detach_ip_from_server(server_id=server['id'], floating_ip_id=f_ip['id'])
# OpenStackSDK sets {"port_id": None} to detach a floating ip from an instance,
# but there might be a delay until a server does not list it in addresses any more.
# Update the floating IP status
f_ip = self.conn.get_floating_ip(id=f_ip['id'])
changed = True
if purge:
self.conn.delete_floating_ip(f_ip['id'])
self.exit_json(changed=True)
self.exit_json(changed=changed, floating_ip=f_ip)
def main():
module = NetworkingFloatingIPModule()
module()
if __name__ == '__main__':

View File

@@ -0,0 +1,206 @@
#!/usr/bin/python
# coding: utf-8 -*-
#
# Copyright (c) 2021 by Open Telekom Cloud, operated by T-Systems International GmbH
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
---
module: floating_ip_info
short_description: Get information about floating ips
author: OpenStack Ansible SIG
description:
- Get a generator of floating ips.
options:
description:
description:
- The description of a floating IP.
type: str
fixed_ip_address:
description:
- The fixed IP address associated with a floating IP address.
type: str
floating_ip_address:
description:
- The IP address of a floating IP.
type: str
floating_network:
description:
- The name or id of the network associated with a floating IP.
type: str
port:
description:
- The name or id of the port to which a floating IP is associated.
type: str
project_id:
description:
- The ID of the project a floating IP is associated with.
type: str
router:
description:
- The name or id of an associated router.
type: str
status:
description:
- The status of a floating IP, which can be ``ACTIVE``or ``DOWN``.
choices: ['active', 'down']
type: str
requirements:
- "python >= 3.6"
- "openstacksdk"
extends_documentation_fragment:
- openstack.cloud.openstack
'''
RETURN = '''
floating_ips:
description: The floating ip objects list.
type: complex
returned: On Success.
contains:
created_at:
description: Timestamp at which the floating IP was assigned.
type: str
description:
description: The description of a floating IP.
type: str
dns_domain:
description: The DNS domain.
type: str
dns_name:
description: The DNS name.
type: str
fixed_ip_address:
description: The fixed IP address associated with a floating IP address.
type: str
floating_ip_address:
description: The IP address of a floating IP.
type: str
floating_network_id:
description: The id of the network associated with a floating IP.
type: str
id:
description: Id of the floating ip.
type: str
name:
description: Name of the floating ip.
type: str
port_details:
description: The details of the port that this floating IP associates \
with. Present if ``fip-port-details`` extension is loaded.
type: str
port_id:
description: The port ID floating ip associated with.
type: str
project_id:
description: The ID of the project this floating IP is associated with.
type: str
qos_policy_id:
description: The ID of the QoS policy attached to the floating IP.
type: str
revision_number:
description: Revision number.
type: str
router_id:
description: The id of the router floating ip associated with.
type: str
status:
description: The status of a floating IP, which can be ``ACTIVE``or ``DOWN``.\
Can be 'ACTIVE' and 'DOWN'.
type: str
subnet_id:
description: The id of the subnet the floating ip associated with.
type: str
tags:
description: List of tags.
type: str
updated_at:
description: Timestamp at which the floating IP was last updated.
type: str
'''
EXAMPLES = '''
# Getting all floating ips
- openstack.cloud.floating_ip_info:
register: fips
# Getting fip by associated fixed IP address.
- openstack.cloud.floating_ip_info:
fixed_ip_address: 192.168.10.8
register: fip
# Getting fip by associated router.
- openstack.cloud.floating_ip_info:
router: my-router
register: fip
'''
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
class FloatingIPInfoModule(OpenStackModule):
argument_spec = dict(
description=dict(required=False),
fixed_ip_address=dict(required=False),
floating_ip_address=dict(required=False),
floating_network=dict(required=False),
port=dict(required=False),
project_id=dict(required=False),
router=dict(required=False),
status=dict(required=False, choices=['active', 'down']),
)
module_kwargs = dict(
supports_check_mode=True
)
def run(self):
description = self.params['description']
fixed_ip_address = self.params['fixed_ip_address']
floating_ip_address = self.params['floating_ip_address']
floating_network = self.params['floating_network']
port = self.params['port']
project_id = self.params['project_id']
router = self.params['router']
status = self.params['status']
query = {}
if description:
query['description'] = description
if fixed_ip_address:
query['fixed_ip_address'] = fixed_ip_address
if floating_ip_address:
query['floating_ip_address'] = floating_ip_address
if floating_network:
try:
query['floating_network_id'] = self.conn.network.find_network(name_or_id=floating_network,
ignore_missing=False).id
except self.sdk.exceptions.ResourceNotFound:
self.fail_json(msg="floating_network not found")
if port:
try:
query['port_id'] = self.conn.network.find_port(name_or_id=port, ignore_missing=False).id
except self.sdk.exceptions.ResourceNotFound:
self.fail_json(msg="port not found")
if project_id:
query['project_id'] = project_id
if router:
try:
query['router_id'] = self.conn.network.find_router(name_or_id=router, ignore_missing=False).id
except self.sdk.exceptions.ResourceNotFound:
self.fail_json(msg="router not found")
if status:
query['status'] = status.upper()
ips = [ip.to_dict(computed=False) for ip in self.conn.network.ips(**query)]
self.exit_json(changed=False, floating_ips=ips)
def main():
module = FloatingIPInfoModule()
module()
if __name__ == '__main__':
main()

View File

@@ -42,58 +42,54 @@ EXAMPLES = '''
group: demo
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _system_state_change(state, in_group):
if state == 'present' and not in_group:
return True
if state == 'absent' and in_group:
return True
return False
def main():
argument_spec = openstack_full_argument_spec(
class IdentityGroupAssignment(OpenStackModule):
argument_spec = dict(
user=dict(required=True),
group=dict(required=True),
state=dict(default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec,
supports_check_mode=True,
**module_kwargs)
module_kwargs = dict(
supports_check_mode=True
)
user = module.params['user']
group = module.params['group']
state = module.params['state']
def _system_state_change(self, state, in_group):
if state == 'present' and not in_group:
return True
if state == 'absent' and in_group:
return True
return False
sdk, cloud = openstack_cloud_from_module(module)
try:
in_group = cloud.is_user_in_group(user, group)
def run(self):
user = self.params['user']
group = self.params['group']
state = self.params['state']
if module.check_mode:
module.exit_json(changed=_system_state_change(state, in_group))
in_group = self.conn.is_user_in_group(user, group)
if self.ansible.check_mode:
self.exit_json(changed=self._system_state_change(state, in_group))
changed = False
if state == 'present':
if not in_group:
cloud.add_user_to_group(user, group)
self.conn.add_user_to_group(user, group)
changed = True
elif state == 'absent':
if in_group:
cloud.remove_user_from_group(user, group)
self.conn.remove_user_from_group(user, group)
changed = True
module.exit_json(changed=changed)
self.exit_json(changed=changed)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e), extra_data=e.extra_data)
def main():
module = IdentityGroupAssignment()
module()
if __name__ == '__main__':

View File

@@ -73,73 +73,43 @@ EXAMPLES = '''
name: db_aggregate
'''
RETURN = '''
RETURN = r'''
aggregate:
description: A host aggregate resource.
type: complex
returned: On success, when I(state) is present
contains:
availability_zone:
description: Availability zone of the aggregate
type: str
returned: always
deleted:
description: Whether or not the resource is deleted
type: bool
returned: always
hosts:
description: Hosts belonging to the aggregate
type: str
returned: always
id:
description: The UUID of the aggregate.
type: str
returned: always
metadata:
description: Metadata attached to the aggregate
type: str
returned: always
name:
description: Name of the aggregate
type: str
returned: always
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _needs_update(module, aggregate):
new_metadata = (module.params['metadata'] or {})
if module.params['availability_zone'] is not None:
new_metadata['availability_zone'] = module.params['availability_zone']
if module.params['name'] != aggregate.name:
return True
if module.params['hosts'] is not None:
if module.params['purge_hosts']:
if set(module.params['hosts']) != set(aggregate.hosts):
return True
else:
intersection = set(module.params['hosts']).intersection(set(aggregate.hosts))
if set(module.params['hosts']) != intersection:
return True
if module.params['availability_zone'] is not None:
if module.params['availability_zone'] != aggregate.availability_zone:
return True
if module.params['metadata'] is not None:
if new_metadata != aggregate.metadata:
return True
return False
def _system_state_change(module, aggregate):
state = module.params['state']
if state == 'absent' and aggregate:
return True
if state == 'present':
if aggregate is None:
return True
return _needs_update(module, aggregate)
return False
def _update_hosts(cloud, aggregate, hosts, purge_hosts):
if hosts is None:
return
hosts_to_add = set(hosts) - set(aggregate.hosts)
for i in hosts_to_add:
cloud.add_host_to_aggregate(aggregate.id, i)
if not purge_hosts:
return
hosts_to_remove = set(aggregate.hosts) - set(hosts)
for i in hosts_to_remove:
cloud.remove_host_from_aggregate(aggregate.id, i)
def main():
argument_spec = openstack_full_argument_spec(
class ComputeHostAggregateModule(OpenStackModule):
argument_spec = dict(
name=dict(required=True),
metadata=dict(required=False, default=None, type='dict'),
availability_zone=dict(required=False, default=None),
@@ -148,71 +118,118 @@ def main():
state=dict(default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec,
supports_check_mode=True,
**module_kwargs)
name = module.params['name']
metadata = module.params['metadata']
availability_zone = module.params['availability_zone']
hosts = module.params['hosts']
purge_hosts = module.params['purge_hosts']
state = module.params['state']
if metadata is not None:
metadata.pop('availability_zone', None)
sdk, cloud = openstack_cloud_from_module(module)
try:
aggregates = cloud.search_aggregates(name_or_id=name)
module_kwargs = dict(
supports_check_mode=True
)
def _find_aggregate(self, name_or_id):
aggregates = self.conn.search_aggregates(name_or_id=name_or_id)
if len(aggregates) == 1:
aggregate = aggregates[0]
return aggregates[0]
elif len(aggregates) == 0:
aggregate = None
else:
raise Exception("Should not happen")
return None
raise Exception("Aggregate is not unique, this should be impossible")
if module.check_mode:
module.exit_json(changed=_system_state_change(module, aggregate))
def _needs_update(self, aggregate):
new_metadata = self.params['metadata'] or {}
if self.params['availability_zone'] is not None:
new_metadata['availability_zone'] = self.params['availability_zone']
if self.params['hosts'] is not None:
if self.params['purge_hosts']:
if set(self.params['hosts']) != set(aggregate.hosts):
return True
else:
intersection = set(self.params['hosts']).intersection(set(aggregate.hosts))
if set(self.params['hosts']) != intersection:
return True
for param in ('availability_zone', 'metadata'):
if self.params[param] is not None and \
self.params[param] != aggregate[param]:
return True
return False
def _system_state_change(self, aggregate):
state = self.params['state']
if state == 'absent' and aggregate:
return True
if state == 'present':
if aggregate is None:
aggregate = cloud.create_aggregate(name=name,
availability_zone=availability_zone)
_update_hosts(cloud, aggregate, hosts, False)
if metadata:
cloud.set_aggregate_metadata(aggregate.id, metadata)
changed = True
else:
if _needs_update(module, aggregate):
if availability_zone is not None:
aggregate = cloud.update_aggregate(aggregate.id, name=name,
availability_zone=availability_zone)
if metadata is not None:
metas = metadata
for i in (set(aggregate.metadata.keys()) - set(metadata.keys())):
if i != 'availability_zone':
metas[i] = None
cloud.set_aggregate_metadata(aggregate.id, metas)
_update_hosts(cloud, aggregate, hosts, purge_hosts)
changed = True
else:
changed = False
module.exit_json(changed=changed)
return True
return self._needs_update(aggregate)
elif state == 'absent':
return False
def _update_hosts(self, aggregate, hosts, purge_hosts):
if hosts is None:
return
hosts_to_add = set(hosts) - set(aggregate['hosts'] or [])
for host in hosts_to_add:
self.conn.add_host_to_aggregate(aggregate.id, host)
if not purge_hosts:
return
hosts_to_remove = set(aggregate["hosts"] or []) - set(hosts)
for host in hosts_to_remove:
self.conn.remove_host_from_aggregate(aggregate.id, host)
def run(self):
name = self.params['name']
metadata = self.params['metadata']
availability_zone = self.params['availability_zone']
hosts = self.params['hosts']
purge_hosts = self.params['purge_hosts']
state = self.params['state']
if metadata is not None:
metadata.pop('availability_zone', None)
aggregate = self._find_aggregate(name)
if self.ansible.check_mode:
self.exit_json(changed=self._system_state_change(aggregate))
changed = False
if state == 'present':
if aggregate is None:
changed = False
else:
_update_hosts(cloud, aggregate, [], True)
cloud.delete_aggregate(aggregate.id)
aggregate = self.conn.create_aggregate(
name=name, availability_zone=availability_zone)
self._update_hosts(aggregate, hosts, False)
if metadata:
self.conn.set_aggregate_metadata(aggregate.id, metadata)
changed = True
module.exit_json(changed=changed)
elif self._needs_update(aggregate):
if availability_zone is not None:
aggregate = self.conn.update_aggregate(
aggregate.id, name=name,
availability_zone=availability_zone)
if metadata is not None:
metas = metadata
for i in set(aggregate.metadata.keys() - set(metadata.keys())):
if i != 'availability_zone':
metas[i] = None
self.conn.set_aggregate_metadata(aggregate.id, metas)
self._update_hosts(aggregate, hosts, purge_hosts)
changed = True
aggregate = self._find_aggregate(name)
self.exit_json(changed=changed, aggregate=aggregate)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
elif state == 'absent' and aggregate is not None:
self._update_hosts(aggregate, [], True)
self.conn.delete_aggregate(aggregate.id)
changed = True
self.exit_json(changed=changed)
def main():
module = ComputeHostAggregateModule()
module()
if __name__ == '__main__':

View File

@@ -85,92 +85,90 @@ id:
sample: "474acfe5-be34-494c-b339-50f06aa143e4"
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _needs_update(module, domain):
if module.params['description'] is not None and \
domain.description != module.params['description']:
return True
if domain.enabled != module.params['enabled']:
return True
return False
def _system_state_change(module, domain):
state = module.params['state']
if state == 'absent' and domain:
return True
if state == 'present':
if domain is None:
return True
return _needs_update(module, domain)
return False
def main():
argument_spec = openstack_full_argument_spec(
class IdentityDomainModule(OpenStackModule):
argument_spec = dict(
name=dict(required=True),
description=dict(default=None),
enabled=dict(default=True, type='bool'),
state=dict(default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec,
supports_check_mode=True,
**module_kwargs)
module_kwargs = dict(
supports_check_mode=True
)
name = module.params['name']
description = module.params['description']
enabled = module.params['enabled']
state = module.params['state']
def _needs_update(self, domain):
if self.params['description'] is not None and \
domain.description != self.params['description']:
return True
if domain.get(
"is_enabled", domain.get("enabled")) != self.params['enabled']:
return True
return False
sdk, cloud = openstack_cloud_from_module(module)
try:
def _system_state_change(self, domain):
state = self.params['state']
if state == 'absent' and domain:
return True
domains = cloud.search_domains(filters=dict(name=name))
if state == 'present':
if domain is None:
return True
return self._needs_update(domain)
return False
def run(self):
name = self.params['name']
description = self.params['description']
enabled = self.params['enabled']
state = self.params['state']
domains = list(self.conn.identity.domains(name=name))
if len(domains) > 1:
module.fail_json(msg='Domain name %s is not unique' % name)
self.fail_json(msg='Domain name %s is not unique' % name)
elif len(domains) == 1:
domain = domains[0]
else:
domain = None
if module.check_mode:
module.exit_json(changed=_system_state_change(module, domain))
if self.ansible.check_mode:
self.exit_json(changed=self._system_state_change(domain))
if state == 'present':
if domain is None:
domain = cloud.create_domain(
domain = self.conn.create_domain(
name=name, description=description, enabled=enabled)
changed = True
else:
if _needs_update(module, domain):
domain = cloud.update_domain(
if self._needs_update(domain):
domain = self.conn.update_domain(
domain.id, name=name, description=description,
enabled=enabled)
changed = True
else:
changed = False
module.exit_json(changed=changed, domain=domain, id=domain.id)
if hasattr(domain, "to_dict"):
domain = domain.to_dict()
domain.pop("location")
self.exit_json(changed=changed, domain=domain, id=domain['id'])
elif state == 'absent':
if domain is None:
changed = False
else:
cloud.delete_domain(domain.id)
self.conn.delete_domain(domain.id)
changed = True
module.exit_json(changed=changed)
self.exit_json(changed=changed)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = IdentityDomainModule()
module()
if __name__ == '__main__':

View File

@@ -18,7 +18,7 @@ options:
type: str
filters:
description:
- A dictionary of meta data to use for further filtering. Elements of
- A dictionary of meta data to use for filtering. Elements of
this dictionary may be additional dictionaries.
type: dict
requirements:
@@ -61,7 +61,8 @@ RETURN = '''
openstack_domains:
description: has all the OpenStack information about domains
returned: always, but can be null
type: complex
type: list
elements: dict
contains:
id:
description: Unique UUID.
@@ -81,53 +82,37 @@ openstack_domains:
type: bool
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def main():
argument_spec = openstack_full_argument_spec(
class IdentityDomainInfoModule(OpenStackModule):
argument_spec = dict(
name=dict(required=False, default=None),
filters=dict(required=False, type='dict', default=None),
)
module_kwargs = openstack_module_kwargs(
mutually_exclusive=[
['name', 'filters'],
]
module_kwargs = dict(
supports_check_mode=True
)
module = AnsibleModule(argument_spec, **module_kwargs)
is_old_facts = module._name == 'openstack.cloud.identity_domain_facts'
if is_old_facts:
module.deprecate("The 'openstack.cloud.identity_domain_facts' module has been renamed to 'openstack.cloud.identity_domain_info', "
"and the renamed one no longer returns ansible_facts", version='2.0.0',
collection_name='openstack.cloud')
sdk, opcloud = openstack_cloud_from_module(module)
try:
name = module.params['name']
filters = module.params['filters']
deprecated_names = ('openstack.cloud.identity_domain_facts')
def run(self):
name = self.params['name']
filters = self.params['filters'] or {}
args = {}
if name:
# Let's suppose user is passing domain ID
try:
domains = opcloud.get_domain(name)
except Exception:
domains = opcloud.search_domains(filters={'name': name})
args['name_or_id'] = name
args['filters'] = filters
else:
domains = opcloud.search_domains(filters)
domains = self.conn.search_domains(**args)
self.exit_json(changed=False, openstack_domains=domains)
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_domains=domains))
else:
module.exit_json(changed=False, openstack_domains=domains)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = IdentityDomainInfoModule()
module()
if __name__ == '__main__':

View File

@@ -86,75 +86,71 @@ group:
sample: "default"
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _system_state_change(state, description, group):
if state == 'present' and not group:
return True
if state == 'present' and description is not None and group.description != description:
return True
if state == 'absent' and group:
return True
return False
def main():
argument_spec = openstack_full_argument_spec(
class IdentityGroupModule(OpenStackModule):
argument_spec = dict(
name=dict(required=True),
description=dict(required=False, default=None),
domain_id=dict(required=False, default=None),
state=dict(default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec,
supports_check_mode=True,
**module_kwargs)
module_kwargs = dict(
supports_check_mode=True
)
name = module.params.get('name')
description = module.params.get('description')
state = module.params.get('state')
def _system_state_change(self, state, description, group):
if state == 'present' and not group:
return True
if state == 'present' and description is not None and group.description != description:
return True
if state == 'absent' and group:
return True
return False
domain_id = module.params.pop('domain_id')
def run(self):
name = self.params.get('name')
description = self.params.get('description')
state = self.params.get('state')
domain_id = self.params.pop('domain_id')
sdk, cloud = openstack_cloud_from_module(module)
try:
if domain_id:
group = cloud.get_group(name, filters={'domain_id': domain_id})
group = self.conn.get_group(name, filters={'domain_id': domain_id})
else:
group = cloud.get_group(name)
group = self.conn.get_group(name)
if module.check_mode:
module.exit_json(changed=_system_state_change(state, description, group))
if self.ansible.check_mode:
self.exit_json(changed=self._system_state_change(state, description, group))
if state == 'present':
if group is None:
group = cloud.create_group(
group = self.conn.create_group(
name=name, description=description, domain=domain_id)
changed = True
else:
if description is not None and group.description != description:
group = cloud.update_group(
group = self.conn.update_group(
group.id, description=description)
changed = True
else:
changed = False
module.exit_json(changed=changed, group=group)
self.exit_json(changed=changed, group=group)
elif state == 'absent':
if group is None:
changed = False
else:
cloud.delete_group(group.id)
self.conn.delete_group(group.id)
changed = True
module.exit_json(changed=changed)
self.exit_json(changed=changed)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = IdentityGroupModule()
module()
if __name__ == '__main__':

View File

@@ -89,7 +89,7 @@ EXAMPLES = '''
RETURN = '''
openstack_groups:
description: Dictionary describing all the matching groups.
returned: always, but can be null
returned: always, but can be an empty list
type: complex
contains:
name:
@@ -110,48 +110,40 @@ openstack_groups:
type: bool
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec, openstack_cloud_from_module
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def main():
argument_spec = openstack_full_argument_spec(
class IdentityGroupInfoModule(OpenStackModule):
argument_spec = dict(
name=dict(required=False, default=None),
domain=dict(required=False, default=None),
filters=dict(required=False, type='dict', default=None),
)
module_kwargs = dict(
supports_check_mode=True
)
module = AnsibleModule(argument_spec)
sdk, opcloud = openstack_cloud_from_module(module)
try:
name = module.params['name']
domain = module.params['domain']
filters = module.params['filters']
def run(self):
name = self.params['name']
domain = self.params['domain']
filters = self.params['filters'] or {}
args = {}
if domain:
try:
# We assume admin is passing domain id
dom = opcloud.get_domain(domain)['id']
domain = dom
except Exception:
# If we fail, maybe admin is passing a domain name.
# Note that domains have unique names, just like id.
dom = opcloud.search_domains(filters={'name': domain})
if dom:
domain = dom[0]['id']
else:
module.fail_json(msg='Domain name or ID does not exist')
dom = self.conn.identity.find_domain(domain)
if dom:
args['domain_id'] = dom['id']
else:
self.fail_json(msg='Domain name or ID does not exist')
if not filters:
filters = {}
groups = self.conn.search_groups(name, filters, **args)
# groups is for backward (and forward) compatibility
self.exit_json(changed=False, groups=groups, openstack_groups=groups)
groups = opcloud.search_groups(name, filters, domain_id=domain)
module.exit_json(changed=False, groups=groups)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = IdentityGroupInfoModule()
module()
if __name__ == '__main__':

View File

@@ -49,6 +49,10 @@ role:
returned: On success when I(state) is 'present'.
type: complex
contains:
domain_id:
description: Domain to which the role belongs
type: str
sample: default
id:
description: Unique role ID.
type: str
@@ -59,58 +63,50 @@ role:
sample: "demo"
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _system_state_change(state, role):
if state == 'present' and not role:
return True
if state == 'absent' and role:
return True
return False
def main():
argument_spec = openstack_full_argument_spec(
class IdentityRoleModule(OpenStackModule):
argument_spec = dict(
name=dict(required=True),
state=dict(default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec,
supports_check_mode=True,
**module_kwargs)
module_kwargs = dict(
supports_check_mode=True
)
name = module.params.get('name')
state = module.params.get('state')
def _system_state_change(self, state, role):
if state == 'present' and not role:
return True
if state == 'absent' and role:
return True
return False
sdk, cloud = openstack_cloud_from_module(module)
try:
role = cloud.get_role(name)
def run(self):
name = self.params.get('name')
state = self.params.get('state')
if module.check_mode:
module.exit_json(changed=_system_state_change(state, role))
role = self.conn.get_role(name)
if self.ansible.check_mode:
self.exit_json(changed=self._system_state_change(state, role))
changed = False
if state == 'present':
if role is None:
role = cloud.create_role(name)
role = self.conn.create_role(name=name)
changed = True
else:
changed = False
module.exit_json(changed=changed, role=role)
elif state == 'absent':
if role is None:
changed = False
else:
cloud.delete_role(name)
changed = True
module.exit_json(changed=changed)
self.exit_json(changed=changed, role=role)
elif state == 'absent' and role is not None:
self.conn.identity.delete_role(role['id'])
changed = True
self.exit_json(changed=changed)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = IdentityRoleModule()
module()
if __name__ == '__main__':

View File

@@ -7,19 +7,19 @@
DOCUMENTATION = '''
---
module: identity_role_info
short_description: Retrive information about roles
short_description: Retrieve information about roles
author: OpenStack Ansible SIG
description:
- Get information about identity roles in Openstack
options:
domain_id:
description:
- List roles in specified domain only
- Domain ID which owns the role
type: str
required: false
name:
description:
- List role speficied by name
- Name or ID of the role
type: str
required: false
@@ -37,21 +37,19 @@ openstack_roles:
returned: always
type: list
elements: dict
sample:
- domain_id: None
id: 19bf514fdda84f808ccee8463bd85c1a
location:
cloud: mycloud
project:
domain_id: None
domain_name: None
id: None
name: None
region_name: None
zone: None
name: member
properties:
contains:
id:
description: Unique ID for the role
returned: success
type: str
name:
description: Unique role name, within the owning domain.
returned: success
type: str
domain_id:
description: References the domain ID which owns the role.
returned: success
type: str
'''
EXAMPLES = '''
@@ -75,23 +73,24 @@ from ansible_collections.openstack.cloud.plugins.module_utils.openstack import O
class IdentityRoleInfoModule(OpenStackModule):
argument_spec = dict(
domain_id=dict(type='str', required=False),
name=dict(type='str', required=False),
)
module_kwargs = dict(
supports_check_mode=True,
)
def run(self):
roles = self.conn.list_roles(domain_id=self.params['domain_id'])
# Dictionaries are supported from Train release
roles = [item if isinstance(item, dict) else item.to_dict() for item in roles]
# Filtering by name is supported from Wallaby release
if self.params['name']:
roles = [item for item in roles if self.params['name'] in (item['id'], item['name'])]
self.results.update({'openstack_roles': roles})
params = {
'domain_id': self.params['domain_id'],
'name_or_id': self.params['name'],
}
params = {k: v for k, v in params.items() if v is not None}
roles = self.conn.search_roles(**params)
self.exit_json(changed=False, openstack_roles=roles)
def main():

View File

@@ -26,6 +26,7 @@ options:
update_password:
required: false
choices: ['always', 'on_create']
default: on_create
description:
- C(always) will attempt to update password. C(on_create) will only
set the password for newly created users.
@@ -108,77 +109,53 @@ RETURN = '''
user:
description: Dictionary describing the user.
returned: On success when I(state) is 'present'
type: complex
type: dict
contains:
default_project_id:
description: User default project ID. Only present with Keystone >= v3.
returned: success
type: str
sample: "4427115787be45f08f0ec22a03bfc735"
description:
description: The description of this user
returned: success
type: str
sample: "a user"
domain_id:
description: User domain ID. Only present with Keystone >= v3.
returned: success
type: str
sample: "default"
email:
description: User email address
returned: success
type: str
sample: "demo@example.com"
id:
description: User ID
returned: success
type: str
sample: "f59382db809c43139982ca4189404650"
enabled:
description: Indicates whether the user is enabled
type: bool
name:
description: User name
description: Unique user name, within the owning domain
returned: success
type: str
sample: "demouser"
username:
description: Username with Identity API v2 (OpenStack Pike or earlier) else Null
returned: success
type: str
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def _needs_update(params_dict, user):
for k in params_dict:
if k not in ('password', 'update_password') and user[k] != params_dict[k]:
return True
# We don't get password back in the user object, so assume any supplied
# password is a change.
if (
params_dict['password'] is not None
and params_dict['update_password'] == 'always'
):
return True
return False
def _get_domain_id(cloud, domain):
try:
# We assume admin is passing domain id
domain_id = cloud.get_domain(domain)['id']
except Exception:
# If we fail, maybe admin is passing a domain name.
# Note that domains have unique names, just like id.
try:
domain_id = cloud.search_domains(filters={'name': domain})[0]['id']
except Exception:
# Ok, let's hope the user is non-admin and passing a sane id
domain_id = domain
return domain_id
def _get_default_project_id(cloud, default_project, domain_id, module):
project = cloud.get_project(default_project, domain_id=domain_id)
if not project:
module.fail_json(msg='Default project %s is not valid' % default_project)
return project['id']
def main():
argument_spec = openstack_full_argument_spec(
class IdentityUserModule(OpenStackModule):
argument_spec = dict(
name=dict(required=True),
password=dict(required=False, default=None, no_log=True),
email=dict(required=False, default=None),
@@ -187,106 +164,99 @@ def main():
domain=dict(required=False, default=None),
enabled=dict(default=True, type='bool'),
state=dict(default='present', choices=['absent', 'present']),
update_password=dict(default=None, choices=['always', 'on_create']),
update_password=dict(default='on_create', choices=['always', 'on_create']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(
argument_spec,
**module_kwargs)
module_kwargs = dict()
name = module.params['name']
password = module.params.get('password')
email = module.params['email']
default_project = module.params['default_project']
domain = module.params['domain']
enabled = module.params['enabled']
state = module.params['state']
update_password = module.params['update_password']
description = module.params['description']
def _needs_update(self, params_dict, user):
for k in params_dict:
# We don't get password back in the user object, so assume any supplied
# password is a change.
if k == 'password':
return True
if k == 'default_project':
if user['default_project_id'] != params_dict['default_project']:
return True
else:
continue
if user[k] != params_dict[k]:
return True
return False
def _get_domain_id(self, domain):
dom_obj = self.conn.identity.find_domain(domain)
if dom_obj is None:
# Ok, let's hope the user is non-admin and passing a sane id
return domain
return dom_obj.id
def _get_default_project_id(self, default_project, domain_id):
project = self.conn.identity.find_project(default_project, domain_id=domain_id)
if not project:
self.fail_json(msg='Default project %s is not valid' % default_project)
return project['id']
def run(self):
name = self.params['name']
password = self.params.get('password')
email = self.params['email']
default_project = self.params['default_project']
domain = self.params['domain']
enabled = self.params['enabled']
state = self.params['state']
update_password = self.params['update_password']
description = self.params['description']
sdk, cloud = openstack_cloud_from_module(module)
try:
domain_id = None
if domain:
domain_id = _get_domain_id(cloud, domain)
user = cloud.get_user(name, domain_id=domain_id)
domain_id = self._get_domain_id(domain)
user = self.conn.get_user(name, domain_id=domain_id)
else:
user = cloud.get_user(name)
domain_id = None
user = self.conn.get_user(name)
changed = False
if state == 'present':
if update_password in ('always', 'on_create'):
if not password:
msg = "update_password is %s but a password value is missing" % update_password
module.fail_json(msg=msg)
default_project_id = None
user_args = {
'name': name,
'email': email,
'domain_id': domain_id,
'description': description,
'enabled': enabled,
}
if default_project:
default_project_id = _get_default_project_id(cloud, default_project, domain_id, module)
default_project_id = self._get_default_project_id(
default_project, domain_id)
user_args['default_project'] = default_project_id
user_args = {k: v for k, v in user_args.items() if v is not None}
changed = False
if user is None:
if description is not None:
user = cloud.create_user(
name=name, password=password, email=email,
default_project=default_project_id, domain_id=domain_id,
enabled=enabled, description=description)
else:
user = cloud.create_user(
name=name, password=password, email=email,
default_project=default_project_id, domain_id=domain_id,
enabled=enabled)
if password:
user_args['password'] = password
user = self.conn.create_user(**user_args)
changed = True
else:
params_dict = {'email': email, 'enabled': enabled,
'password': password,
'update_password': update_password}
if description is not None:
params_dict['description'] = description
if domain_id is not None:
params_dict['domain_id'] = domain_id
if default_project_id is not None:
params_dict['default_project_id'] = default_project_id
if update_password == 'always':
if not password:
self.fail_json(msg="update_password is always but a password value is missing")
user_args['password'] = password
if _needs_update(params_dict, user):
if update_password == 'always':
if description is not None:
user = cloud.update_user(
user['id'], password=password, email=email,
default_project=default_project_id,
domain_id=domain_id, enabled=enabled, description=description)
else:
user = cloud.update_user(
user['id'], password=password, email=email,
default_project=default_project_id,
domain_id=domain_id, enabled=enabled)
else:
if description is not None:
user = cloud.update_user(
user['id'], email=email,
default_project=default_project_id,
domain_id=domain_id, enabled=enabled, description=description)
else:
user = cloud.update_user(
user['id'], email=email,
default_project=default_project_id,
domain_id=domain_id, enabled=enabled)
if self._needs_update(user_args, user):
user = self.conn.update_user(user['id'], **user_args)
changed = True
else:
changed = False
module.exit_json(changed=changed, user=user)
elif state == 'absent':
if user is None:
changed = False
else:
if domain:
cloud.delete_user(user['id'], domain_id=domain_id)
else:
cloud.delete_user(user['id'])
changed = True
module.exit_json(changed=changed)
self.exit_json(changed=changed, user=user)
elif state == 'absent' and user is not None:
self.conn.identity.delete_user(user['id'])
changed = True
self.exit_json(changed=changed)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e), extra_data=e.extra_data)
def main():
module = IdentityUserModule()
module()
if __name__ == '__main__':

View File

@@ -74,95 +74,79 @@ EXAMPLES = '''
RETURN = '''
openstack_users:
description: has all the OpenStack information about users
returned: always, but can be null
type: complex
returned: always
type: list
elements: dict
contains:
id:
description: Unique UUID.
returned: success
type: str
name:
description: Name given to the user.
returned: success
type: str
enabled:
description: Flag to indicate if the user is enabled
returned: success
type: bool
domain_id:
description: Domain ID containing the user
description: Username of the user.
returned: success
type: str
default_project_id:
description: Default project ID of the user
returned: success
type: str
description:
description: The description of this user
returned: success
type: str
domain_id:
description: Domain ID containing the user
returned: success
type: str
email:
description: Email of the user
returned: success
type: str
enabled:
description: Flag to indicate if the user is enabled
returned: success
type: bool
username:
description: Username of the user
description: Username with Identity API v2 (OpenStack Pike or earlier) else Null
returned: success
type: str
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
openstack_full_argument_spec,
openstack_cloud_from_module,
)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def main():
argument_spec = openstack_full_argument_spec(
class IdentityUserInfoModule(OpenStackModule):
argument_spec = dict(
name=dict(required=False, default=None),
domain=dict(required=False, default=None),
filters=dict(required=False, type='dict', default=None),
)
module_kwargs = dict(
supports_check_mode=True
)
module = AnsibleModule(argument_spec)
is_old_facts = module._name == 'openstack.cloud.identity_user_facts'
if is_old_facts:
module.deprecate("The 'openstack.cloud.identity_user_facts' module has been renamed to 'openstack.cloud.identity_user_info', "
"and the renamed one no longer returns ansible_facts", version='2.0.0',
collection_name='openstack.cloud')
deprecated_names = ('openstack.cloud.identity_user_facts')
sdk, opcloud = openstack_cloud_from_module(module)
try:
name = module.params['name']
domain = module.params['domain']
filters = module.params['filters']
def run(self):
name = self.params['name']
domain = self.params['domain']
filters = self.params['filters']
args = {}
if domain:
try:
# We assume admin is passing domain id
dom = opcloud.get_domain(domain)['id']
domain = dom
except Exception:
# If we fail, maybe admin is passing a domain name.
# Note that domains have unique names, just like id.
dom = opcloud.search_domains(filters={'name': domain})
if dom:
domain = dom[0]['id']
else:
module.fail_json(msg='Domain name or ID does not exist')
dom_obj = self.conn.identity.find_domain(domain)
if dom_obj is None:
self.fail_json(
msg="Domain name or ID '{0}' does not exist".format(domain))
args['domain_id'] = dom_obj.id
if not filters:
filters = {}
users = self.conn.search_users(name, filters, **args)
self.exit_json(changed=False, openstack_users=users)
filters['domain_id'] = domain
users = opcloud.search_users(name, filters)
if is_old_facts:
module.exit_json(changed=False, ansible_facts=dict(
openstack_users=users))
else:
module.exit_json(changed=False, openstack_users=users)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
def main():
module = IdentityUserInfoModule()
module()
if __name__ == '__main__':

View File

@@ -40,9 +40,15 @@ options:
default: bare
choices: ['ami', 'aki', 'ari', 'bare', 'ovf', 'ova', 'docker']
type: str
owner:
project:
description:
- The owner of the image
- The name or ID of the project owning the image
type: str
aliases: ['owner']
project_domain:
description:
- The domain the project owning the image belongs to
- May be used to identify a unique project when providing a name to the project argument and multiple projects with such name exist
type: str
min_disk:
description:
@@ -61,7 +67,7 @@ options:
description:
- Prevent image from being deleted
type: bool
default: 'no'
default: false
filename:
description:
- The path to the file which has to be uploaded
@@ -85,6 +91,12 @@ options:
choices: [present, absent]
default: present
type: str
tags:
description:
- List of tags to be applied to the image
default: []
type: list
elements: str
volume:
description:
- ID of a volume to create an image from.
@@ -115,6 +127,8 @@ EXAMPLES = '''
filename: cirros-0.3.0-x86_64-disk.img
kernel: cirros-vmlinuz
ramdisk: cirros-initrd
tags:
- custom
properties:
cpu_arch: x86_64
distro: ubuntu
@@ -147,95 +161,110 @@ EXAMPLES = '''
name: myvol_image
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec,
openstack_module_kwargs,
openstack_cloud_from_module)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def main():
class ImageModule(OpenStackModule):
argument_spec = openstack_full_argument_spec(
name=dict(required=True),
id=dict(default=None),
checksum=dict(default=None),
disk_format=dict(default='qcow2', choices=['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', 'vdi', 'iso', 'vhdx', 'ploop']),
deprecated_names = ('os_image', 'openstack.cloud.os_image')
argument_spec = dict(
name=dict(required=True, type='str'),
id=dict(type='str'),
checksum=dict(type='str'),
disk_format=dict(default='qcow2',
choices=['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', 'vdi', 'iso', 'vhdx', 'ploop']),
container_format=dict(default='bare', choices=['ami', 'aki', 'ari', 'bare', 'ovf', 'ova', 'docker']),
owner=dict(default=None),
project=dict(type='str', aliases=['owner']),
project_domain=dict(type='str'),
min_disk=dict(type='int', default=0),
min_ram=dict(type='int', default=0),
is_public=dict(type='bool', default=False),
protected=dict(type='bool', default=False),
filename=dict(default=None),
ramdisk=dict(default=None),
kernel=dict(default=None),
filename=dict(type='str'),
ramdisk=dict(type='str'),
kernel=dict(type='str'),
properties=dict(type='dict', default={}),
volume=dict(default=None),
volume=dict(type='str'),
tags=dict(type='list', default=[], elements='str'),
state=dict(default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs(
module_kwargs = dict(
mutually_exclusive=[['filename', 'volume']],
)
module = AnsibleModule(argument_spec, **module_kwargs)
sdk, cloud = openstack_cloud_from_module(module)
try:
def run(self):
changed = False
if module.params['id']:
image = cloud.get_image(name_or_id=module.params['id'])
elif module.params['checksum']:
image = cloud.get_image(name_or_id=module.params['name'], filters={'checksum': module.params['checksum']})
if self.params['id']:
image = self.conn.get_image(name_or_id=self.params['id'])
elif self.params['checksum']:
image = self.conn.get_image(name_or_id=self.params['name'], filters={'checksum': self.params['checksum']})
else:
image = cloud.get_image(name_or_id=module.params['name'])
image = self.conn.get_image(name_or_id=self.params['name'])
if module.params['state'] == 'present':
if self.params['state'] == 'present':
if not image:
kwargs = {}
if module.params['id'] is not None:
kwargs['id'] = module.params['id']
image = cloud.create_image(
name=module.params['name'],
filename=module.params['filename'],
disk_format=module.params['disk_format'],
container_format=module.params['container_format'],
wait=module.params['wait'],
timeout=module.params['timeout'],
is_public=module.params['is_public'],
protected=module.params['protected'],
min_disk=module.params['min_disk'],
min_ram=module.params['min_ram'],
volume=module.params['volume'],
if self.params['id'] is not None:
kwargs['id'] = self.params['id']
if self.params['project']:
project_domain = {'id': None}
if self.params['project_domain']:
project_domain = self.conn.get_domain(name_or_id=self.params['project_domain'])
if not project_domain or project_domain['id'] is None:
self.fail(msg='Project domain %s could not be found' % self.params['project_domain'])
project = self.conn.get_project(name_or_id=self.params['project'], domain_id=project_domain['id'])
if not project:
self.fail(msg='Project %s could not be found' % self.params['project'])
kwargs['owner'] = project['id']
image = self.conn.create_image(
name=self.params['name'],
filename=self.params['filename'],
disk_format=self.params['disk_format'],
container_format=self.params['container_format'],
wait=self.params['wait'],
timeout=self.params['timeout'],
is_public=self.params['is_public'],
protected=self.params['protected'],
min_disk=self.params['min_disk'],
min_ram=self.params['min_ram'],
volume=self.params['volume'],
tags=self.params['tags'],
**kwargs
)
changed = True
if not module.params['wait']:
module.exit_json(changed=changed, image=image, id=image.id)
if not self.params['wait']:
self.exit(changed=changed, image=image, id=image.id)
cloud.update_image_properties(
self.conn.update_image_properties(
image=image,
kernel=module.params['kernel'],
ramdisk=module.params['ramdisk'],
protected=module.params['protected'],
**module.params['properties'])
image = cloud.get_image(name_or_id=image.id)
module.exit_json(changed=changed, image=image, id=image.id)
kernel=self.params['kernel'],
ramdisk=self.params['ramdisk'],
protected=self.params['protected'],
**self.params['properties'])
if self.params['tags']:
self.conn.image.update_image(image.id, tags=self.params['tags'])
image = self.conn.get_image(name_or_id=image.id)
self.exit(changed=changed, image=image, id=image.id)
elif module.params['state'] == 'absent':
elif self.params['state'] == 'absent':
if not image:
changed = False
else:
cloud.delete_image(
name_or_id=module.params['name'],
wait=module.params['wait'],
timeout=module.params['timeout'])
self.conn.delete_image(
name_or_id=self.params['name'],
wait=self.params['wait'],
timeout=self.params['timeout'])
changed = True
module.exit_json(changed=changed)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e), extra_data=e.extra_data)
self.exit(changed=changed)
if __name__ == "__main__":
def main():
module = ImageModule()
module()
if __name__ == '__main__':
main()

View File

@@ -4,6 +4,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
---
module: image_info
short_description: Retrieve information about an image within OpenStack.
author: OpenStack Ansible SIG
@@ -17,11 +18,12 @@ options:
- Name or ID of the image
required: false
type: str
properties:
filters:
description:
- Dict of properties of the images used for query
type: dict
required: false
aliases: ['properties']
requirements:
- "python >= 3.6"
- "openstacksdk"
@@ -43,7 +45,7 @@ EXAMPLES = '''
- name: Show openstack information
debug:
msg: "{{ result.openstack_image }}"
msg: "{{ result.image }}"
# Show all available Openstack images
- name: Retrieve all available Openstack images
@@ -52,22 +54,22 @@ EXAMPLES = '''
- name: Show images
debug:
msg: "{{ result.openstack_image }}"
msg: "{{ result.image }}"
# Show images matching requested properties
- name: Retrieve images having properties with desired values
openstack.cloud.image_facts:
properties:
filters:
some_property: some_value
OtherProp: OtherVal
- name: Show images
debug:
msg: "{{ result.openstack_image }}"
msg: "{{ result.image }}"
'''
RETURN = '''
openstack_image:
openstack_images:
description: has all the openstack information about the image
returned: always, but can be null
type: complex
@@ -88,14 +90,14 @@ openstack_image:
description: Image created at timestamp.
returned: success
type: str
deleted:
description: Image deleted flag.
returned: success
type: bool
container_format:
description: Container format of the image.
returned: success
type: str
direct_url:
description: URL to access the image file kept in external store.
returned: success
type: str
min_ram:
description: Min amount of RAM required for this image.
returned: success
@@ -104,19 +106,39 @@ openstack_image:
description: Disk format of the image.
returned: success
type: str
file:
description: The URL for the virtual machine image file.
returned: success
type: str
os_hidden:
description: Controls whether an image is displayed in the default image-list response
returned: success
type: bool
locations:
description: A list of URLs to access the image file in external store.
returned: success
type: str
metadata:
description: The location metadata.
returned: success
type: str
schema:
description: URL for the schema describing a virtual machine image.
returned: success
type: str
updated_at:
description: Image updated at timestamp.
returned: success
type: str
properties:
description: Additional properties associated with the image.
virtual_size:
description: The virtual size of the image.
returned: success
type: dict
type: str
min_disk:
description: Min amount of disk space required for this image.
returned: success
type: int
protected:
is_protected:
description: Image protected flag.
returned: success
type: bool
@@ -128,20 +150,19 @@ openstack_image:
description: Owner for the image.
returned: success
type: str
is_public:
description: Is public flag of the image.
returned: success
type: bool
deleted_at:
description: Image deleted at timestamp.
visibility:
description: Indicates who has access to the image.
returned: success
type: str
size:
description: Size of the image.
returned: success
type: int
tags:
description: List of tags assigned to the image
returned: success
type: list
'''
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
@@ -151,17 +172,27 @@ class ImageInfoModule(OpenStackModule):
argument_spec = dict(
image=dict(type='str', required=False),
properties=dict(type='dict', required=False),
filters=dict(type='dict', required=False, aliases=['properties']),
)
module_kwargs = dict(
supports_check_mode=True
)
def run(self):
args = {
'name_or_id': self.params['image'],
'filters': self.params['filters'],
}
args = {k: v for k, v in args.items() if v is not None}
images = self.conn.search_images(**args)
if self.params['image']:
image = self.conn.get_image(self.params['image'])
self.exit(changed=False, openstack_image=image)
# for backward compatibility
if 'name_or_id' in args:
image = images[0] if images else None
else:
images = self.conn.search_images(filters=self.params['properties'])
self.exit(changed=False, openstack_image=images)
image = images
self.exit(changed=False, openstack_images=images, image=image)
def main():

View File

@@ -54,7 +54,8 @@ RETURN = '''
openstack_keypairs:
description:
- Lists keypairs that are associated with the account.
type: complex
type: list
elements: dict
returned: always
contains:
created_at:
@@ -115,33 +116,20 @@ class KeyPairInfoModule(OpenStackModule):
limit=dict(type='int', required=False),
marker=dict(type='str', required=False)
)
module_kwargs = dict(
supports_check_mode=True
)
def run(self):
name = self.params['name']
user_id = self.params['user_id']
limit = self.params['limit']
marker = self.params['marker']
filters = {}
data = []
if user_id:
filters['user_id'] = user_id
if limit:
filters['limit'] = limit
if marker:
filters['marker'] = marker
result = self.conn.search_keypairs(name_or_id=name,
filters=filters)
raws = [raw if isinstance(raw, dict) else raw.to_dict()
for raw in result]
for raw in raws:
raw.pop('location')
data.append(raw)
self.exit(changed=False, openstack_keypairs=data)
filters = {k: self.params[k] for k in
['user_id', 'name', 'limit', 'marker']
if self.params[k] is not None}
keypairs = self.conn.search_keypairs(name_or_id=self.params['name'],
filters=filters)
# self.conn.search_keypairs() returned munch.Munch objects before Train
result = [raw if isinstance(raw, dict) else raw.to_dict(computed=False)
for raw in keypairs]
self.exit(changed=False, openstack_keypairs=result)
def main():

View File

@@ -60,151 +60,127 @@ EXAMPLES = '''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_module_kwargs
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_cloud_from_module
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def normalize_protocol(protocol):
"""
Normalizes the protocol definitions so that the outputs are consistent with the
parameters
- "name" (parameter) == "id" (SDK)
"""
if protocol is None:
return None
_protocol = protocol.to_dict()
_protocol['name'] = protocol['id']
# As of 0.44 SDK doesn't copy the URI parameters over, so let's add them
_protocol['idp_id'] = protocol['idp_id']
return _protocol
def delete_protocol(module, sdk, cloud, protocol):
"""
Delete an existing Protocol
returns: the "Changed" state
"""
if protocol is None:
return False
if module.check_mode:
return True
try:
cloud.identity.delete_federation_protocol(None, protocol)
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to delete protocol: {0}'.format(str(ex)))
return True
def create_protocol(module, sdk, cloud, name):
"""
Create a new Protocol
returns: the "Changed" state and the new protocol
"""
if module.check_mode:
return True, None
idp_name = module.params.get('idp_id')
mapping_id = module.params.get('mapping_id')
attributes = {
'idp_id': idp_name,
'mapping_id': mapping_id,
}
try:
protocol = cloud.identity.create_federation_protocol(id=name, **attributes)
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to create protocol: {0}'.format(str(ex)))
return (True, protocol)
def update_protocol(module, sdk, cloud, protocol):
"""
Update an existing Protocol
returns: the "Changed" state and the new protocol
"""
mapping_id = module.params.get('mapping_id')
attributes = {}
if (mapping_id is not None) and (mapping_id != protocol.mapping_id):
attributes['mapping_id'] = mapping_id
if not attributes:
return False, protocol
if module.check_mode:
return True, None
try:
new_protocol = cloud.identity.update_federation_protocol(None, protocol, **attributes)
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to update protocol: {0}'.format(str(ex)))
return (True, new_protocol)
def main():
""" Module entry point """
argument_spec = openstack_full_argument_spec(
class IdentityFederationProtocolModule(OpenStackModule):
argument_spec = dict(
name=dict(required=True, aliases=['id']),
state=dict(default='present', choices=['absent', 'present']),
idp_id=dict(required=True, aliases=['idp_name']),
mapping_id=dict(aliases=['mapping_name']),
)
module_kwargs = openstack_module_kwargs(
)
module = AnsibleModule(
argument_spec,
supports_check_mode=True,
**module_kwargs
module_kwargs = dict(
supports_check_mode=True
)
name = module.params.get('name')
state = module.params.get('state')
idp = module.params.get('idp_id')
changed = False
def normalize_protocol(self, protocol):
"""
Normalizes the protocol definitions so that the outputs are consistent with the
parameters
sdk, cloud = openstack_cloud_from_module(module, min_version="0.44")
try:
protocol = cloud.identity.get_federation_protocol(idp, name)
except sdk.exceptions.ResourceNotFound:
protocol = None
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to get protocol: {0}'.format(str(ex)))
if state == 'absent':
if protocol is not None:
changed = delete_protocol(module, sdk, cloud, protocol)
module.exit_json(changed=changed)
# state == 'present'
else:
- "name" (parameter) == "id" (SDK)
"""
if protocol is None:
if module.params.get('mapping_id') is None:
module.fail_json(msg='A mapping_id must be passed when creating'
' a protocol')
(changed, protocol) = create_protocol(module, sdk, cloud, name)
protocol = normalize_protocol(protocol)
module.exit_json(changed=changed, protocol=protocol)
return None
_protocol = protocol.to_dict()
_protocol['name'] = protocol['id']
# As of 0.44 SDK doesn't copy the URI parameters over, so let's add them
_protocol['idp_id'] = protocol['idp_id']
return _protocol
def delete_protocol(self, protocol):
"""
Delete an existing Protocol
returns: the "Changed" state
"""
if protocol is None:
return False
if self.ansible.check_mode:
return True
self.conn.identity.delete_federation_protocol(None, protocol)
return True
def create_protocol(self, name):
"""
Create a new Protocol
returns: the "Changed" state and the new protocol
"""
if self.ansible.check_mode:
return True, None
idp_name = self.params.get('idp_id')
mapping_id = self.params.get('mapping_id')
attributes = {
'idp_id': idp_name,
'mapping_id': mapping_id,
}
protocol = self.conn.identity.create_federation_protocol(id=name, **attributes)
return (True, protocol)
def update_protocol(self, protocol):
"""
Update an existing Protocol
returns: the "Changed" state and the new protocol
"""
mapping_id = self.params.get('mapping_id')
attributes = {}
if (mapping_id is not None) and (mapping_id != protocol.mapping_id):
attributes['mapping_id'] = mapping_id
if not attributes:
return False, protocol
if self.ansible.check_mode:
return True, None
new_protocol = self.conn.identity.update_federation_protocol(None, protocol, **attributes)
return (True, new_protocol)
def run(self):
""" Module entry point """
name = self.params.get('name')
state = self.params.get('state')
idp = self.params.get('idp_id')
changed = False
protocol = self.conn.identity.find_federation_protocol(idp, name)
if state == 'absent':
if protocol is not None:
changed = self.delete_protocol(protocol)
self.exit_json(changed=changed)
# state == 'present'
else:
(changed, new_protocol) = update_protocol(module, sdk, cloud, protocol)
new_protocol = normalize_protocol(new_protocol)
module.exit_json(changed=changed, protocol=new_protocol)
if protocol is None:
if self.params.get('mapping_id') is None:
self.fail_json(
msg='A mapping_id must be passed when creating'
' a protocol')
(changed, protocol) = self.create_protocol(name)
protocol = self.normalize_protocol(protocol)
self.exit_json(changed=changed, protocol=protocol)
else:
(changed, new_protocol) = self.update_protocol(protocol)
new_protocol = self.normalize_protocol(new_protocol)
self.exit_json(changed=changed, protocol=new_protocol)
def main():
module = IdentityFederationProtocolModule()
module()
if __name__ == '__main__':

View File

@@ -45,65 +45,53 @@ EXAMPLES = '''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_module_kwargs
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_cloud_from_module
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
def normalize_protocol(protocol):
"""
Normalizes the protocol definitions so that the outputs are consistent with the
parameters
- "name" (parameter) == "id" (SDK)
"""
if protocol is None:
return None
_protocol = protocol.to_dict()
_protocol['name'] = protocol['id']
# As of 0.44 SDK doesn't copy the URI parameters over, so let's add them
_protocol['idp_id'] = protocol['idp_id']
return _protocol
def main():
""" Module entry point """
argument_spec = openstack_full_argument_spec(
class IdentityFederationProtocolInfoModule(OpenStackModule):
argument_spec = dict(
name=dict(aliases=['id']),
idp_id=dict(required=True, aliases=['idp_name']),
)
module_kwargs = openstack_module_kwargs(
)
module = AnsibleModule(
argument_spec,
supports_check_mode=True,
**module_kwargs
module_kwargs = dict(
supports_check_mode=True
)
name = module.params.get('name')
idp = module.params.get('idp_id')
def normalize_protocol(self, protocol):
"""
Normalizes the protocol definitions so that the outputs are consistent with the
parameters
sdk, cloud = openstack_cloud_from_module(module, min_version="0.44")
- "name" (parameter) == "id" (SDK)
"""
if protocol is None:
return None
if name:
try:
protocol = cloud.identity.get_federation_protocol(idp, name)
protocol = normalize_protocol(protocol)
except sdk.exceptions.ResourceNotFound:
module.fail_json(msg='Failed to find protocol')
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to get protocol: {0}'.format(str(ex)))
module.exit_json(changed=False, protocols=[protocol])
_protocol = protocol.to_dict()
_protocol['name'] = protocol['id']
# As of 0.44 SDK doesn't copy the URI parameters over, so let's add them
_protocol['idp_id'] = protocol['idp_id']
return _protocol
else:
try:
protocols = list(map(normalize_protocol, cloud.identity.federation_protocols(idp)))
except sdk.exceptions.OpenStackCloudException as ex:
module.fail_json(msg='Failed to list protocols: {0}'.format(str(ex)))
module.exit_json(changed=False, protocols=protocols)
def run(self):
""" Module entry point """
name = self.params.get('name')
idp = self.params.get('idp_id')
if name:
protocol = self.conn.identity.get_federation_protocol(idp, name)
protocol = self.normalize_protocol(protocol)
self.exit_json(changed=False, protocols=[protocol])
else:
protocols = list(map(self.normalize_protocol, self.conn.identity.federation_protocols(idp)))
self.exit_json(changed=False, protocols=protocols)
def main():
module = IdentityFederationProtocolInfoModule()
module()
if __name__ == '__main__':

View File

@@ -45,7 +45,7 @@ options:
- The number of successful checks before changing the operating status of the member to ONLINE.
max_retries_down:
type: 'str'
default: 3
default: '3'
description:
- The number of allowed check failures before changing the operating status of the member to ERROR. A valid value is from 1 to 10. The default is 3.
resp_timeout:
@@ -60,7 +60,7 @@ options:
type: bool
expected_codes:
type: 'str'
default: 200
default: '200'
description:
- The list of HTTP status codes expected in response from the member to declare it healthy. Specify one of the following values
A single value, such as 200
@@ -223,10 +223,10 @@ class HealthMonitorModule(OpenStackModule):
expected_codes=dict(required=False, default="200"),
admin_state_up=dict(required=False, default=True, type='bool'),
state=dict(default='present', choices=['absent', 'present']),
http_method=dict(default="GET", requried=False, choices=["GET", "CONNECT", "DELETE",
http_method=dict(default="GET", required=False, choices=["GET", "CONNECT", "DELETE",
"HEAD", "OPTIONS", "PATCH",
"POST", "PUT", "TRACE"]),
url_path=dict(default="/", requires=False),
url_path=dict(default="/", required=False),
type=dict(default='HTTP',
choices=['HTTP', 'HTTPS', 'PING', 'SCTP', 'TCP', 'TLS-HELLO', 'UDP-CONNECT']))

Some files were not shown because too many files have changed in this diff Show More