mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-07-28 02:34:30 +00:00
Compare commits
171 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2419b6e30c | ||
|
|
0ada05ec10 | ||
|
|
c81422e3f6 | ||
|
|
2a062cb82e | ||
|
|
6ec9548850 | ||
|
|
8d8cf1d6a7 | ||
|
|
616f71341e | ||
|
|
a4c6d4ba3a | ||
|
|
84580110ec | ||
|
|
42e2503ee1 | ||
|
|
1f0ced6952 | ||
|
|
338534eab2 | ||
|
|
737ca4fed7 | ||
|
|
603b6e2d2b | ||
|
|
13dadf4129 | ||
|
|
94bb10a5ee | ||
|
|
7644aeaf32 | ||
|
|
836d7410b2 | ||
|
|
382a43c461 | ||
|
|
bcac650895 | ||
|
|
c3cd0d2838 | ||
|
|
143c959f7d | ||
|
|
0e6e281316 | ||
|
|
a02bba1152 | ||
|
|
80557dae33 | ||
|
|
d4a77620cc | ||
|
|
b3e1cdd730 | ||
|
|
9e7332ffff | ||
|
|
e545283299 | ||
|
|
885fadb31e | ||
|
|
da833ac8dc | ||
|
|
b1932e1b06 | ||
|
|
09a4e4248d | ||
|
|
ccec4d07b3 | ||
|
|
1387aec1db | ||
|
|
04b70b99da | ||
|
|
ed4c4036af | ||
|
|
e2ebc1c8d0 | ||
|
|
99eb60f7dc | ||
|
|
e90fd7a915 | ||
|
|
b3a31eb6d5 | ||
|
|
1bc4f648fb | ||
|
|
1a654a9c38 | ||
|
|
af4d72a3bb | ||
|
|
67b7ec5e58 | ||
|
|
b1e4d4b714 | ||
|
|
a4ed67b054 | ||
|
|
70128d6230 | ||
|
|
1dc367b566 | ||
|
|
86d9e2e00a | ||
|
|
f0e0388159 | ||
|
|
dbc6f7d44a | ||
|
|
a178493281 | ||
|
|
b2aac80b41 | ||
|
|
ae6e48be00 | ||
|
|
e06a61f97a | ||
|
|
3c0a9f2d94 | ||
|
|
b1ecd54a5d | ||
|
|
4a3460e727 | ||
|
|
c9887b3a23 | ||
|
|
e84ebb0773 | ||
|
|
eef8368e6f | ||
|
|
f584c54dfd | ||
|
|
3901000119 | ||
|
|
556208fc3c | ||
|
|
3ac95541da | ||
|
|
59b5b33557 | ||
|
|
3d7948a4e4 | ||
|
|
6cb5ed4b84 | ||
|
|
283c342b10 | ||
|
|
2a5fb584e2 | ||
|
|
762fee2bad | ||
|
|
9d92897522 | ||
|
|
df0b57a3c6 | ||
|
|
5a6f5084dd | ||
|
|
c988b3bcbf | ||
|
|
437438e33c | ||
|
|
3fd79d342c | ||
|
|
98bb212ae4 | ||
|
|
08d8cd8c25 | ||
|
|
41cf92df99 | ||
|
|
5494d153b1 | ||
|
|
fef560eb5b | ||
|
|
1ce7dd8b5f | ||
|
|
438bbea34b | ||
|
|
239c45c78f | ||
|
|
e065818024 | ||
|
|
0764e671a9 | ||
|
|
5f4db3583e | ||
|
|
6262474c94 | ||
|
|
f9fcd35018 | ||
|
|
5dbf47cb49 | ||
|
|
57c63e7918 | ||
|
|
ed5829d462 | ||
|
|
b025e7c356 | ||
|
|
782340833e | ||
|
|
73aab9e80c | ||
|
|
ae7e8260a3 | ||
|
|
030df96dc0 | ||
|
|
c5d0d3ec82 | ||
|
|
0cff7eb3a2 | ||
|
|
29e3f3dac8 | ||
|
|
d18ea87091 | ||
|
|
529c1e8dcc | ||
|
|
99b7af529c | ||
|
|
2ed3ffe1d0 | ||
|
|
ae5dbf0fc0 | ||
|
|
4074db1bd0 | ||
|
|
3248ba9960 | ||
|
|
2d5ca42629 | ||
|
|
83456005fc | ||
|
|
5b61019a34 | ||
|
|
630dac3787 | ||
|
|
54c2257376 | ||
|
|
c843feb338 | ||
|
|
28541ee158 | ||
|
|
c09029ada0 | ||
|
|
903eeb7db7 | ||
|
|
03ebbaed93 | ||
|
|
8d9b8b9a35 | ||
|
|
fef5e127d4 | ||
|
|
01d3011895 | ||
|
|
d4f25d2282 | ||
|
|
3df5c38ca6 | ||
|
|
474b3804eb | ||
|
|
5a8ad4cdf0 | ||
|
|
e742016861 | ||
|
|
40a384214c | ||
|
|
1188af2486 | ||
|
|
e42e21f621 | ||
|
|
e6379e3038 | ||
|
|
e0dc4776bb | ||
|
|
22941e86d1 | ||
|
|
b089d56136 | ||
|
|
536fe731f7 | ||
|
|
4a8214b196 | ||
|
|
d1b77a3546 | ||
|
|
8aefe5dc3a | ||
|
|
217e965357 | ||
|
|
94afde008b | ||
|
|
032a5222c1 | ||
|
|
fa6eb547ab | ||
|
|
23290a568b | ||
|
|
69801f268f | ||
|
|
0c6aee5378 | ||
|
|
fb258ababa | ||
|
|
4c186a2ae6 | ||
|
|
598cc2d743 | ||
|
|
e0139fe940 | ||
|
|
bc65d42f52 | ||
|
|
ac4d105813 | ||
|
|
747c4d23bc | ||
|
|
93d51498e9 | ||
|
|
cfd2d1f773 | ||
|
|
e009f80ffc | ||
|
|
08c93cf9b1 | ||
|
|
fff978d273 | ||
|
|
9fb544d94a | ||
|
|
94ed95c8b6 | ||
|
|
4ab054790c | ||
|
|
2c68080758 | ||
|
|
6e680d594b | ||
|
|
b25e93dbdd | ||
|
|
0aedc268f1 | ||
|
|
9b47cb4b59 | ||
|
|
8612171af3 | ||
|
|
8f321eaeb2 | ||
|
|
147ad6c452 | ||
|
|
407369da6e | ||
|
|
0a371445eb | ||
|
|
2808d1c155 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -4,3 +4,7 @@ ansible_collections
|
|||||||
FILES.json
|
FILES.json
|
||||||
MANIFEST.json
|
MANIFEST.json
|
||||||
importer_result.json
|
importer_result.json
|
||||||
|
|
||||||
|
**/__pycache__
|
||||||
|
.venv
|
||||||
|
.python-version
|
||||||
|
|||||||
194
.zuul.yaml
194
.zuul.yaml
@@ -47,6 +47,8 @@
|
|||||||
devstack_services:
|
devstack_services:
|
||||||
designate: true
|
designate: true
|
||||||
neutron-dns: true
|
neutron-dns: true
|
||||||
|
neutron-trunk: true
|
||||||
|
neutron-segments: true
|
||||||
zuul_copy_output:
|
zuul_copy_output:
|
||||||
'{{ devstack_log_dir }}/test_output.log': 'logs'
|
'{{ devstack_log_dir }}/test_output.log': 'logs'
|
||||||
extensions_to_txt:
|
extensions_to_txt:
|
||||||
@@ -94,6 +96,39 @@
|
|||||||
c-bak: false
|
c-bak: false
|
||||||
tox_extra_args: -vv --skip-missing-interpreters=false -- coe_cluster coe_cluster_template
|
tox_extra_args: -vv --skip-missing-interpreters=false -- coe_cluster coe_cluster_template
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: ansible-collections-openstack-functional-devstack-manila-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 devstack with Manila plugin enabled
|
||||||
|
# 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/manila
|
||||||
|
- openstack/python-manilaclient
|
||||||
|
files:
|
||||||
|
- ^ci/roles/share_type/.*$
|
||||||
|
- ^plugins/modules/share_type.py
|
||||||
|
- ^plugins/modules/share_type_info.py
|
||||||
|
timeout: 10800
|
||||||
|
vars:
|
||||||
|
devstack_localrc:
|
||||||
|
MANILA_ENABLED_BACKENDS: generic
|
||||||
|
MANILA_OPTGROUP_generic_driver_handles_share_servers: true
|
||||||
|
MANILA_OPTGROUP_generic_connect_share_server_to_tenant_network: true
|
||||||
|
MANILA_USE_SERVICE_INSTANCE_PASSWORD: true
|
||||||
|
devstack_plugins:
|
||||||
|
manila: https://opendev.org/openstack/manila
|
||||||
|
devstack_services:
|
||||||
|
manila: true
|
||||||
|
m-api: true
|
||||||
|
m-sch: true
|
||||||
|
m-shr: true
|
||||||
|
m-dat: true
|
||||||
|
tox_extra_args: -vv --skip-missing-interpreters=false -- share_type share_type_info
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-functional-devstack-magnum
|
name: ansible-collections-openstack-functional-devstack-magnum
|
||||||
parent: ansible-collections-openstack-functional-devstack-magnum-base
|
parent: ansible-collections-openstack-functional-devstack-magnum-base
|
||||||
@@ -103,6 +138,15 @@
|
|||||||
with Magnum plugin enabled, using master of openstacksdk and latest
|
with Magnum plugin enabled, using master of openstacksdk and latest
|
||||||
ansible release. Run it only on coe_cluster{,_template} changes.
|
ansible release. Run it only on coe_cluster{,_template} changes.
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: ansible-collections-openstack-functional-devstack-manila
|
||||||
|
parent: ansible-collections-openstack-functional-devstack-manila-base
|
||||||
|
branches: master
|
||||||
|
description: |
|
||||||
|
Run openstack collections functional tests against a master devstack
|
||||||
|
with Manila plugin enabled, using master of openstacksdk and latest
|
||||||
|
ansible release. Run it only on share_type{,_info} changes.
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-functional-devstack-octavia-base
|
name: ansible-collections-openstack-functional-devstack-octavia-base
|
||||||
parent: ansible-collections-openstack-functional-devstack-base
|
parent: ansible-collections-openstack-functional-devstack-base
|
||||||
@@ -162,50 +206,48 @@
|
|||||||
tox_constraints_file: '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/constraints-openstacksdk-1.x.x.txt'
|
tox_constraints_file: '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/constraints-openstacksdk-1.x.x.txt'
|
||||||
tox_install_siblings: false
|
tox_install_siblings: false
|
||||||
|
|
||||||
# Job with Ansible 2.9 for checking backward compatibility
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-functional-devstack-ansible-2.9
|
name: ansible-collections-openstack-functional-devstack-ansible-2.18
|
||||||
parent: ansible-collections-openstack-functional-devstack-base
|
parent: ansible-collections-openstack-functional-devstack-base
|
||||||
branches: master
|
branches: master
|
||||||
description: |
|
description: |
|
||||||
Run openstack collections functional tests against a master devstack
|
Run openstack collections functional tests against a master devstack
|
||||||
using master of openstacksdk and stable 2.9 branch of ansible
|
using master of openstacksdk and stable 2.18 branch of ansible
|
||||||
required-projects:
|
required-projects:
|
||||||
- name: github.com/ansible/ansible
|
- name: github.com/ansible/ansible
|
||||||
override-checkout: stable-2.9
|
override-checkout: stable-2.18
|
||||||
vars:
|
vars:
|
||||||
tox_envlist: ansible_2_9
|
tox_envlist: ansible_2_18
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-functional-devstack-ansible-2.11
|
name: ansible-collections-openstack-functional-devstack-ansible-2.19
|
||||||
parent: ansible-collections-openstack-functional-devstack-base
|
parent: ansible-collections-openstack-functional-devstack-base
|
||||||
branches: master
|
branches: master
|
||||||
description: |
|
description: |
|
||||||
Run openstack collections functional tests against a master devstack
|
Run openstack collections functional tests against a master devstack
|
||||||
using master of openstacksdk and stable 2.12 branch of ansible
|
using master of openstacksdk and stable 2.19 branch of ansible
|
||||||
required-projects:
|
required-projects:
|
||||||
- name: github.com/ansible/ansible
|
- name: github.com/ansible/ansible
|
||||||
override-checkout: stable-2.11
|
override-checkout: stable-2.19
|
||||||
vars:
|
vars:
|
||||||
tox_envlist: ansible_2_11
|
tox_envlist: ansible_2_19
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-functional-devstack-ansible-2.12
|
name: ansible-collections-openstack-functional-devstack-ansible-2.20
|
||||||
parent: ansible-collections-openstack-functional-devstack-base
|
parent: ansible-collections-openstack-functional-devstack-base
|
||||||
branches: master
|
branches: master
|
||||||
description: |
|
description: |
|
||||||
Run openstack collections functional tests against a master devstack
|
Run openstack collections functional tests against a master devstack
|
||||||
using master of openstacksdk and stable 2.12 branch of ansible
|
using master of openstacksdk and stable 2.20 branch of ansible
|
||||||
required-projects:
|
required-projects:
|
||||||
- name: github.com/ansible/ansible
|
- name: github.com/ansible/ansible
|
||||||
override-checkout: stable-2.12
|
override-checkout: stable-2.20
|
||||||
vars:
|
vars:
|
||||||
tox_envlist: ansible_2_12
|
tox_envlist: ansible_2_20
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-functional-devstack-ansible-devel
|
name: ansible-collections-openstack-functional-devstack-ansible-devel
|
||||||
parent: ansible-collections-openstack-functional-devstack-base
|
parent: ansible-collections-openstack-functional-devstack-base
|
||||||
nodeset: openstack-single-node-jammy
|
|
||||||
branches: master
|
branches: master
|
||||||
description: |
|
description: |
|
||||||
Run openstack collections functional tests against a master devstack
|
Run openstack collections functional tests against a master devstack
|
||||||
@@ -234,34 +276,58 @@
|
|||||||
- job:
|
- job:
|
||||||
name: openstack-tox-linters-ansible-devel
|
name: openstack-tox-linters-ansible-devel
|
||||||
parent: openstack-tox-linters-ansible
|
parent: openstack-tox-linters-ansible
|
||||||
nodeset: ubuntu-jammy
|
nodeset: ubuntu-noble
|
||||||
description: |
|
description: |
|
||||||
Run openstack collections linter tests using the devel branch of ansible
|
Run openstack collections linter tests using the devel branch of ansible
|
||||||
# non-voting because we can't prevent ansible devel from breaking us
|
# non-voting because we can't prevent ansible devel from breaking us
|
||||||
voting: false
|
voting: false
|
||||||
vars:
|
vars:
|
||||||
python_version: '3.10'
|
python_version: '3.12'
|
||||||
bindep_profile: test py310
|
bindep_profile: test py310
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: openstack-tox-linters-ansible-2.12
|
name: openstack-tox-linters-ansible-2.18
|
||||||
parent: openstack-tox-linters-ansible
|
parent: openstack-tox-linters-ansible
|
||||||
nodeset: ubuntu-focal
|
|
||||||
description: |
|
description: |
|
||||||
Run openstack collections linter tests using the 2.12 branch of ansible
|
Run openstack collections linter tests using the 2.18 branch of ansible
|
||||||
required-projects:
|
required-projects:
|
||||||
- name: github.com/ansible/ansible
|
- name: github.com/ansible/ansible
|
||||||
override-checkout: stable-2.12
|
override-checkout: stable-2.18
|
||||||
vars:
|
vars:
|
||||||
ensure_tox_version: '<4'
|
tox_envlist: linters_2_18
|
||||||
tox_envlist: linters_2_12
|
python_version: "3.12"
|
||||||
python_version: 3.8
|
bindep_profile: test py312
|
||||||
bindep_profile: test py38
|
|
||||||
|
- job:
|
||||||
|
name: openstack-tox-linters-ansible-2.19
|
||||||
|
parent: openstack-tox-linters-ansible
|
||||||
|
description: |
|
||||||
|
Run openstack collections linter tests using the 2.19 branch of ansible
|
||||||
|
required-projects:
|
||||||
|
- name: github.com/ansible/ansible
|
||||||
|
override-checkout: stable-2.19
|
||||||
|
vars:
|
||||||
|
tox_envlist: linters_2_19
|
||||||
|
python_version: "3.12"
|
||||||
|
bindep_profile: test py312
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: openstack-tox-linters-ansible-2.20
|
||||||
|
parent: openstack-tox-linters-ansible
|
||||||
|
description: |
|
||||||
|
Run openstack collections linter tests using the 2.20 branch of ansible
|
||||||
|
required-projects:
|
||||||
|
- name: github.com/ansible/ansible
|
||||||
|
override-checkout: stable-2.20
|
||||||
|
vars:
|
||||||
|
tox_envlist: linters_2_20
|
||||||
|
python_version: "3.12"
|
||||||
|
bindep_profile: test py312
|
||||||
|
|
||||||
# Cross-checks with other projects
|
# Cross-checks with other projects
|
||||||
- job:
|
- job:
|
||||||
name: bifrost-collections-src
|
name: bifrost-collections-src
|
||||||
parent: bifrost-integration-tinyipa-ubuntu-focal
|
parent: bifrost-integration-on-ubuntu-noble
|
||||||
required-projects:
|
required-projects:
|
||||||
- openstack/ansible-collections-openstack
|
- openstack/ansible-collections-openstack
|
||||||
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
|
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
|
||||||
@@ -272,7 +338,7 @@
|
|||||||
override-checkout: master
|
override-checkout: master
|
||||||
- job:
|
- job:
|
||||||
name: bifrost-keystone-collections-src
|
name: bifrost-keystone-collections-src
|
||||||
parent: bifrost-integration-tinyipa-keystone-ubuntu-focal
|
parent: bifrost-integration-keystone-on-ubuntu-noble
|
||||||
required-projects:
|
required-projects:
|
||||||
- openstack/ansible-collections-openstack
|
- openstack/ansible-collections-openstack
|
||||||
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
|
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
|
||||||
@@ -284,7 +350,7 @@
|
|||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-release
|
name: ansible-collections-openstack-release
|
||||||
parent: base
|
parent: openstack-tox-linters-ansible
|
||||||
run: ci/publish/publish_collection.yml
|
run: ci/publish/publish_collection.yml
|
||||||
secrets:
|
secrets:
|
||||||
- ansible_galaxy_info
|
- ansible_galaxy_info
|
||||||
@@ -294,79 +360,71 @@
|
|||||||
data:
|
data:
|
||||||
url: https://galaxy.ansible.com
|
url: https://galaxy.ansible.com
|
||||||
token: !encrypted/pkcs1-oaep
|
token: !encrypted/pkcs1-oaep
|
||||||
- lZFzfoCbuwqV1k6qRfl/VS7E+knUW7+zpg7BptrenK4n0g7UY0HtdVkYq0pV0Tj/LbhzG
|
- K93hOZo1B5z248H04COB1N2HCkGbFPo2EUr+0W7qFzsrdvmbsAI86Hl9bUCfEENGrwvfV
|
||||||
jHD0mehcV1iS6B7ORKg4criJkdDfEx09BD8z8yv0EleiIMmhlrCoMcY593OZMBtVbGi0D
|
0j9CE5iO0tyqal3r6ucMhGT44MgQWL3MBeRvK89yAJpSNMU7R7rEY/zbjZMoC9YElcHEv
|
||||||
CwQtNO98QIsfZogChfLfvRNiBmUV98mEb/p6p3EtGx8J7qcAsqfWxc/CzB8GCleLAHHHT
|
GEDZSA/0gQHCHpZVDlx4JMGwrnd+Nz9ha3c12BYeZS8rS/dQl7EmZ867OsozmNdG9UkkC
|
||||||
FuikMM03ZnV0ew7E+TPkHbzzPhBZOqS5HYF0HtgttHwIXdfIWp/XdTuEEk7uRRgYZ2Iao
|
0vP/dkenUQNvoZOSWgZztRBlbAyI1nc5iEEw9vvpLh19HcY9+S2iAZkgSq4jOOO4wn7gE
|
||||||
ifWRzoKaOQmhM++e1ydCqw9D4y9dZEFNMQLwSqcrvtb8cNwT1kl7SCFqYNE2lbutj4ne6
|
XAZPr0HRdwS2m4Hw0Pusrg7SdC3+2O0N/fvFGnvvKXHcSgQk3rPLn6HfKzOJoPWc4WlDX
|
||||||
PTBQRsKegMB4Y3ena14fNF6tCynvJLPhF/cjPH2Jhs+B19XQhWkL3TgiOY02W24YHwRcP
|
MA79jYloNBXjOaeXOoiwYzzshWK53F6Ci+3leq1cYuFyHSi2ds2mYXat7YndZSsmsk5um
|
||||||
+LdkM8inAvyVi3DEbEqdjBPO9OFJcBOKPlCdkGvuwdNCuEpEwctWs0gV3voflG2CDKzmJ
|
hj0+Ddy9Om1uYy3nhHyZLULE7UDUmduA9EPkvdyWlcW0yZL2kXcrDTHlSp4PaJg9iKVys
|
||||||
wu9JJOAWnq/0l1WpuDqWreKeQ/BUGZC2Gb4xRAqofulgvhs4WuYoEccjH4EJFIZ90S1EP
|
0aOOo9CNMwhyXAOGiFCYF/m7Efbnp50zUQhHN9+7LeVzXZuiH98C8kNvWfE0qrkrrgQ1n
|
||||||
R/ZLadqZaEhmjwGM5sMWbBbjT23XsRgg0Tzt9m8DENYMuYDqkMdRbt2jYZa+32p4hyxVe
|
78UMqGcGpdw4ZSlWrDTbrbd4v0bRnsJ+IAWISnT5OXaeJgGZwXRuBHtTXqbjoosBeX/8w
|
||||||
Y6H/pqYq5b9uOzumnShaK4WlmkQyXcNPkoSlMC1h4OGvqX/WUixpI38jyMA5Tc=
|
YKb0lx7E5ZtSw7+Y6LNDGihGTmVg1nkZUWo85CxyF/RiWHuNvpkzzqXmdGS1bg=
|
||||||
|
|
||||||
- project:
|
- project:
|
||||||
check:
|
check:
|
||||||
jobs:
|
jobs:
|
||||||
- tox-pep8
|
- tox-pep8
|
||||||
- openstack-tox-linters-ansible-devel
|
- openstack-tox-linters-ansible-devel
|
||||||
- openstack-tox-linters-ansible-2.12
|
- openstack-tox-linters-ansible-2.18
|
||||||
- ansible-collections-openstack-functional-devstack:
|
- openstack-tox-linters-ansible-2.19
|
||||||
dependencies: &deps_unit_lint
|
- openstack-tox-linters-ansible-2.20
|
||||||
- tox-pep8
|
- ansible-collections-openstack-functional-devstack
|
||||||
- openstack-tox-linters-ansible-2.12
|
- ansible-collections-openstack-functional-devstack-releases
|
||||||
|
- ansible-collections-openstack-functional-devstack-ansible-2.18
|
||||||
- ansible-collections-openstack-functional-devstack-releases:
|
- ansible-collections-openstack-functional-devstack-ansible-2.19
|
||||||
dependencies: *deps_unit_lint
|
- ansible-collections-openstack-functional-devstack-ansible-2.20
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-2.9:
|
- ansible-collections-openstack-functional-devstack-ansible-devel
|
||||||
dependencies: *deps_unit_lint
|
- ansible-collections-openstack-functional-devstack-magnum
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-2.12:
|
- ansible-collections-openstack-functional-devstack-manila
|
||||||
dependencies: *deps_unit_lint
|
- ansible-collections-openstack-functional-devstack-octavia
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-devel:
|
|
||||||
dependencies: *deps_unit_lint
|
|
||||||
- ansible-collections-openstack-functional-devstack-magnum:
|
|
||||||
dependencies: *deps_unit_lint
|
|
||||||
- ansible-collections-openstack-functional-devstack-octavia:
|
|
||||||
dependencies: *deps_unit_lint
|
|
||||||
|
|
||||||
- bifrost-collections-src:
|
- bifrost-collections-src:
|
||||||
voting: false
|
voting: false
|
||||||
dependencies: *deps_unit_lint
|
|
||||||
irrelevant-files: *ignore_files
|
irrelevant-files: *ignore_files
|
||||||
- bifrost-keystone-collections-src:
|
- bifrost-keystone-collections-src:
|
||||||
voting: false
|
voting: false
|
||||||
dependencies: *deps_unit_lint
|
|
||||||
irrelevant-files: *ignore_files
|
irrelevant-files: *ignore_files
|
||||||
|
|
||||||
gate:
|
gate:
|
||||||
jobs:
|
jobs:
|
||||||
- tox-pep8
|
- tox-pep8
|
||||||
- openstack-tox-linters-ansible-2.12
|
- openstack-tox-linters-ansible-2.18
|
||||||
# - ansible-collections-openstack-functional-devstack
|
- openstack-tox-linters-ansible-2.19
|
||||||
|
- openstack-tox-linters-ansible-2.20
|
||||||
- ansible-collections-openstack-functional-devstack-releases
|
- ansible-collections-openstack-functional-devstack-releases
|
||||||
# - ansible-collections-openstack-functional-devstack-ansible-2.9
|
|
||||||
# - ansible-collections-openstack-functional-devstack-ansible-2.12
|
|
||||||
- ansible-collections-openstack-functional-devstack-magnum
|
- ansible-collections-openstack-functional-devstack-magnum
|
||||||
|
- ansible-collections-openstack-functional-devstack-manila
|
||||||
- ansible-collections-openstack-functional-devstack-octavia
|
- ansible-collections-openstack-functional-devstack-octavia
|
||||||
|
|
||||||
periodic:
|
periodic:
|
||||||
jobs:
|
jobs:
|
||||||
- openstack-tox-linters-ansible-devel
|
- openstack-tox-linters-ansible-devel
|
||||||
- openstack-tox-linters-ansible-2.12
|
- openstack-tox-linters-ansible-2.18
|
||||||
|
- openstack-tox-linters-ansible-2.19
|
||||||
|
- openstack-tox-linters-ansible-2.20
|
||||||
- ansible-collections-openstack-functional-devstack
|
- ansible-collections-openstack-functional-devstack
|
||||||
- ansible-collections-openstack-functional-devstack-releases
|
- ansible-collections-openstack-functional-devstack-releases
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-2.9
|
- ansible-collections-openstack-functional-devstack-ansible-2.18
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-2.12
|
- ansible-collections-openstack-functional-devstack-ansible-2.19
|
||||||
|
- ansible-collections-openstack-functional-devstack-ansible-2.20
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-devel
|
- ansible-collections-openstack-functional-devstack-ansible-devel
|
||||||
- bifrost-collections-src
|
- bifrost-collections-src
|
||||||
- bifrost-keystone-collections-src
|
- bifrost-keystone-collections-src
|
||||||
- ansible-collections-openstack-functional-devstack-magnum
|
- ansible-collections-openstack-functional-devstack-magnum
|
||||||
|
- ansible-collections-openstack-functional-devstack-manila
|
||||||
- ansible-collections-openstack-functional-devstack-octavia
|
- ansible-collections-openstack-functional-devstack-octavia
|
||||||
|
|
||||||
experimental:
|
|
||||||
jobs:
|
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-2.11
|
|
||||||
|
|
||||||
tag:
|
tag:
|
||||||
jobs:
|
jobs:
|
||||||
- ansible-collections-openstack-release
|
- ansible-collections-openstack-release
|
||||||
|
|||||||
228
CHANGELOG.rst
228
CHANGELOG.rst
@@ -4,6 +4,234 @@ Ansible OpenStack Collection Release Notes
|
|||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
v2.6.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
New modules for Bare Metal port groups and Neutron network segments, plus image/project enhancements and bugfixes.
|
||||||
|
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add support for setting the shard key on a baremetal node.
|
||||||
|
- image - Add support for image ID reservation and queued image creation
|
||||||
|
- project - Support updating extra_specs
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Fix Ansible errors
|
||||||
|
- Fixed compatability with openstacksdk version 4.15.0
|
||||||
|
|
||||||
|
New Modules
|
||||||
|
-----------
|
||||||
|
|
||||||
|
- openstack.cloud.baremetal_port_group - Create/Delete Bare Metal port group resources from OpenStack
|
||||||
|
- openstack.cloud.compute_service - Update OpenStack Compute (Nova) services
|
||||||
|
- openstack.cloud.network_segment - Creates/removes network segments from OpenStack
|
||||||
|
- openstack.cloud.volume_image_metadata - Manage OpenStack Cinder volume image metadata
|
||||||
|
- openstack.cloud.volume_retype - Retype (change the volume type of) a Cinder block storage volume
|
||||||
|
|
||||||
|
v2.5.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Bugfixes and minor changes
|
||||||
|
|
||||||
|
Major Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add import_method to module
|
||||||
|
- Add object_containers_info module
|
||||||
|
- Add support for filters in inventory
|
||||||
|
- Add volume_manage module
|
||||||
|
- Introduce share_type modules
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Allow role_assignment module to work cross domain
|
||||||
|
- Don't compare current state for `reboot_*` actions
|
||||||
|
- Fix disable_gateway_ip for subnet
|
||||||
|
- Fix example in the dns_zone_info module doc
|
||||||
|
- Fix router module external IPs when only subnet specified
|
||||||
|
- Fix the bug reporting url
|
||||||
|
- Let clouds_yaml_path behave as documented (Override path to clouds.yaml file)
|
||||||
|
- Shows missing data in `stack_info` module output
|
||||||
|
|
||||||
|
v2.4.1
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Bugfixes and minor changes
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Update tags when changing server
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Fix missed client_cert in OpenStackModule
|
||||||
|
|
||||||
|
v2.4.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
New trait module and minor changes
|
||||||
|
|
||||||
|
Major Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add trait module
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add loadbalancer quota options
|
||||||
|
- Allow create instance with tags
|
||||||
|
|
||||||
|
New Modules
|
||||||
|
-----------
|
||||||
|
|
||||||
|
- openstack.cloud.trait - Add or Delete a trait from OpenStack
|
||||||
|
|
||||||
|
v2.3.3
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Bugfixes and minor changes
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add test to only_ipv4 in inventory
|
||||||
|
- add an option to use only IPv4 only for ansible_host and ansible_ssh_host
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- CI - Fix deprecated ANSIBLE_COLLECTIONS_PATHS variable
|
||||||
|
|
||||||
|
v2.3.2
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Bugfixes and minor changes
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Drop compat implementations for tests
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Fix openstack.cloud.port module failure in check mode
|
||||||
|
|
||||||
|
v2.3.1
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Client TLS certificate support
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add ability to pass client tls certificate
|
||||||
|
|
||||||
|
v2.3.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Bugfixes and new modules
|
||||||
|
|
||||||
|
Major Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add Neutron trunk module
|
||||||
|
- Add application_credential module
|
||||||
|
- Add module to filter available volume services
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add inactive state for the images
|
||||||
|
- Add insecure_registry property to coe_cluster_templates
|
||||||
|
- Add support for creation of the default external networks
|
||||||
|
- Add target_all_project option
|
||||||
|
- Add vlan_tranparency for creation networks
|
||||||
|
- Allow munch results in server_info module
|
||||||
|
- Allow to specify multiple allocation pools when creating a subnet
|
||||||
|
- CI - Disable auto-discovery for setuptools
|
||||||
|
- CI - Don't create port with binding profile
|
||||||
|
- CI - Fix CI in collection
|
||||||
|
- CI - Fix linters-devel and devstack tests
|
||||||
|
- CI - Fix regression in quota module
|
||||||
|
- CI - Fix test for server shelve
|
||||||
|
- CI - Migrate Bifrost jobs to Ubuntu Jammy
|
||||||
|
- CI - Remove 2.9 jobs from Zuul config
|
||||||
|
- CI - Run functional testing regardless of pep8/linter results
|
||||||
|
- Enable glance-direct interop image import
|
||||||
|
- Ensure coe_cluster_template compare labels properly
|
||||||
|
- Wait for deleted server to disappear from results
|
||||||
|
- router - Allow specifying external network name in a different project
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Allow wait false when auto_ip is false
|
||||||
|
- Fix exception when creating object from file
|
||||||
|
- Fix exception when updating container with metadata
|
||||||
|
- Fix typo in openstack.cloud.lb_pool
|
||||||
|
- Fix typo in parameter description
|
||||||
|
- fix subnet module - allow cidr option with subnet_pool
|
||||||
|
|
||||||
|
New Modules
|
||||||
|
-----------
|
||||||
|
|
||||||
|
- openstack.cloud.application_credential - Manage OpenStack Identity (Keystone) application credentials
|
||||||
|
- openstack.cloud.trunk - Add or delete trunks from an OpenStack cloud
|
||||||
|
- openstack.cloud.volume_service_info - Fetch OpenStack Volume (Cinder) services
|
||||||
|
|
||||||
|
v2.2.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
New module for volume_type and bugfixes
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add volume_encryption_type modules
|
||||||
|
- Add volume_type modules
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Fix image module filter
|
||||||
|
- Fix port module idempotency
|
||||||
|
- Fix router module idempotency
|
||||||
|
|
||||||
v2.1.0
|
v2.1.0
|
||||||
======
|
======
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ Thank you for your interest in our Ansible OpenStack collection ☺️
|
|||||||
There are many ways in which you can participate in the project, for example:
|
There are many ways in which you can participate in the project, for example:
|
||||||
|
|
||||||
- [Report and verify bugs and help with solving issues](
|
- [Report and verify bugs and help with solving issues](
|
||||||
https://storyboard.openstack.org/#!/project/openstack/ansible-collections-openstack).
|
https://bugs.launchpad.net/ansible-collections-openstack).
|
||||||
- [Submit and review patches](
|
- [Submit and review patches](
|
||||||
https://review.opendev.org/#/q/project:openstack/ansible-collections-openstack).
|
https://review.opendev.org/#/q/project:openstack/ansible-collections-openstack).
|
||||||
- Follow OpenStack's [How To Contribute](https://wiki.openstack.org/wiki/How_To_Contribute) guide.
|
- Follow OpenStack's [How To Contribute](https://wiki.openstack.org/wiki/How_To_Contribute) guide.
|
||||||
|
|||||||
@@ -515,3 +515,153 @@ releases:
|
|||||||
- Highlight our mode of operation more prominently
|
- Highlight our mode of operation more prominently
|
||||||
release_summary: New module for Ironic and bugfixes
|
release_summary: New module for Ironic and bugfixes
|
||||||
release_date: '2023-04-19'
|
release_date: '2023-04-19'
|
||||||
|
2.2.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Fix image module filter
|
||||||
|
- Fix port module idempotency
|
||||||
|
- Fix router module idempotency
|
||||||
|
minor_changes:
|
||||||
|
- Add volume_encryption_type modules
|
||||||
|
- Add volume_type modules
|
||||||
|
release_summary: New module for volume_type and bugfixes
|
||||||
|
release_date: '2023-12-01'
|
||||||
|
2.3.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Allow wait false when auto_ip is false
|
||||||
|
- Fix exception when creating object from file
|
||||||
|
- Fix exception when updating container with metadata
|
||||||
|
- Fix typo in openstack.cloud.lb_pool
|
||||||
|
- Fix typo in parameter description
|
||||||
|
- fix subnet module - allow cidr option with subnet_pool
|
||||||
|
major_changes:
|
||||||
|
- Add Neutron trunk module
|
||||||
|
- Add application_credential module
|
||||||
|
- Add module to filter available volume services
|
||||||
|
minor_changes:
|
||||||
|
- Add inactive state for the images
|
||||||
|
- Add insecure_registry property to coe_cluster_templates
|
||||||
|
- Add support for creation of the default external networks
|
||||||
|
- Add target_all_project option
|
||||||
|
- Add vlan_tranparency for creation networks
|
||||||
|
- Allow munch results in server_info module
|
||||||
|
- Allow to specify multiple allocation pools when creating a subnet
|
||||||
|
- CI - Disable auto-discovery for setuptools
|
||||||
|
- CI - Don't create port with binding profile
|
||||||
|
- CI - Fix CI in collection
|
||||||
|
- CI - Fix linters-devel and devstack tests
|
||||||
|
- CI - Fix regression in quota module
|
||||||
|
- CI - Fix test for server shelve
|
||||||
|
- CI - Migrate Bifrost jobs to Ubuntu Jammy
|
||||||
|
- CI - Remove 2.9 jobs from Zuul config
|
||||||
|
- CI - Run functional testing regardless of pep8/linter results
|
||||||
|
- Enable glance-direct interop image import
|
||||||
|
- Ensure coe_cluster_template compare labels properly
|
||||||
|
- Wait for deleted server to disappear from results
|
||||||
|
- router - Allow specifying external network name in a different project
|
||||||
|
release_summary: Bugfixes and new modules
|
||||||
|
modules:
|
||||||
|
- description: Manage OpenStack Identity (Keystone) application credentials
|
||||||
|
name: application_credential
|
||||||
|
namespace: ''
|
||||||
|
- description: Add or delete trunks from an OpenStack cloud
|
||||||
|
name: trunk
|
||||||
|
namespace: ''
|
||||||
|
- description: Fetch OpenStack Volume (Cinder) services
|
||||||
|
name: volume_service_info
|
||||||
|
namespace: ''
|
||||||
|
release_date: '2024-11-28'
|
||||||
|
2.3.1:
|
||||||
|
changes:
|
||||||
|
minor_changes:
|
||||||
|
- Add ability to pass client tls certificate
|
||||||
|
release_summary: Client TLS certificate support
|
||||||
|
release_date: '2024-12-18'
|
||||||
|
2.3.2:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Fix openstack.cloud.port module failure in check mode
|
||||||
|
minor_changes:
|
||||||
|
- Drop compat implementations for tests
|
||||||
|
release_summary: Bugfixes and minor changes
|
||||||
|
release_date: '2024-12-20'
|
||||||
|
2.3.3:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- CI - Fix deprecated ANSIBLE_COLLECTIONS_PATHS variable
|
||||||
|
minor_changes:
|
||||||
|
- Add test to only_ipv4 in inventory
|
||||||
|
- add an option to use only IPv4 only for ansible_host and ansible_ssh_host
|
||||||
|
release_summary: Bugfixes and minor changes
|
||||||
|
release_date: '2024-12-22'
|
||||||
|
2.4.0:
|
||||||
|
changes:
|
||||||
|
major_changes:
|
||||||
|
- Add trait module
|
||||||
|
minor_changes:
|
||||||
|
- Add loadbalancer quota options
|
||||||
|
- Allow create instance with tags
|
||||||
|
release_summary: New trait module and minor changes
|
||||||
|
modules:
|
||||||
|
- description: Add or Delete a trait from OpenStack
|
||||||
|
name: trait
|
||||||
|
namespace: ''
|
||||||
|
release_date: '2025-01-15'
|
||||||
|
2.4.1:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Fix missed client_cert in OpenStackModule
|
||||||
|
minor_changes:
|
||||||
|
- Update tags when changing server
|
||||||
|
release_summary: Bugfixes and minor changes
|
||||||
|
release_date: '2024-01-20'
|
||||||
|
2.5.0:
|
||||||
|
changes:
|
||||||
|
major_changes:
|
||||||
|
- Add import_method to module
|
||||||
|
- Add object_containers_info module
|
||||||
|
- Add support for filters in inventory
|
||||||
|
- Add volume_manage module
|
||||||
|
- Introduce share_type modules
|
||||||
|
minor_changes:
|
||||||
|
- Allow role_assignment module to work cross domain
|
||||||
|
- Don't compare current state for `reboot_*` actions
|
||||||
|
- Fix disable_gateway_ip for subnet
|
||||||
|
- Fix example in the dns_zone_info module doc
|
||||||
|
- Fix router module external IPs when only subnet specified
|
||||||
|
- Fix the bug reporting url
|
||||||
|
- Let clouds_yaml_path behave as documented (Override path to clouds.yaml file)
|
||||||
|
- Shows missing data in `stack_info` module output
|
||||||
|
release_summary: Bugfixes and minor changes
|
||||||
|
release_date: '2025-10-24'
|
||||||
|
2.6.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Fix Ansible errors
|
||||||
|
- Fixed compatability with openstacksdk version 4.15.0
|
||||||
|
minor_changes:
|
||||||
|
- Add support for setting the shard key on a baremetal node.
|
||||||
|
- image - Add support for image ID reservation and queued image creation
|
||||||
|
- project - Support updating extra_specs
|
||||||
|
release_summary: New modules for Bare Metal port groups and Neutron network
|
||||||
|
segments, plus image/project enhancements and bugfixes.
|
||||||
|
fragments:
|
||||||
|
- add_shard_key_field_for_baremetal_node.yaml
|
||||||
|
modules:
|
||||||
|
- description: Create/Delete Bare Metal port group resources from OpenStack
|
||||||
|
name: baremetal_port_group
|
||||||
|
namespace: ''
|
||||||
|
- description: Update OpenStack Compute (Nova) services
|
||||||
|
name: compute_service
|
||||||
|
namespace: ''
|
||||||
|
- description: Creates/removes network segments from OpenStack
|
||||||
|
name: network_segment
|
||||||
|
namespace: ''
|
||||||
|
- description: Manage OpenStack Cinder volume image metadata
|
||||||
|
name: volume_image_metadata
|
||||||
|
namespace: ''
|
||||||
|
- description: Retype (change the volume type of) a Cinder block storage volume
|
||||||
|
name: volume_retype
|
||||||
|
namespace: ''
|
||||||
|
release_date: '2026-06-10'
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
vars:
|
vars:
|
||||||
collection_path: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
collection_path: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
||||||
build_collection_path: /tmp/collection_built/
|
build_collection_path: /tmp/collection_built/
|
||||||
ansible_galaxy_path: "~/.local/bin/ansible-galaxy"
|
ansible_virtualenv_path: /tmp/ansible_venv
|
||||||
|
ansible_galaxy_path: "{{ ansible_virtualenv_path }}/bin/ansible-galaxy"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
@@ -11,9 +12,15 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: ensure-pip
|
name: ensure-pip
|
||||||
|
|
||||||
- name: Install ansible
|
- name: Install Ansible in virtualenv
|
||||||
pip:
|
pip:
|
||||||
name: ansible-core<2.12
|
name: ansible-core<2.19
|
||||||
|
virtualenv: "{{ ansible_virtualenv_path }}"
|
||||||
|
virtualenv_command: "{{ ensure_pip_virtualenv_command }}"
|
||||||
|
|
||||||
|
- name: Detect ansible version
|
||||||
|
command: "{{ ansible_virtualenv_path }}/bin/ansible --version"
|
||||||
|
register: ansible_version
|
||||||
|
|
||||||
- name: Discover tag version
|
- name: Discover tag version
|
||||||
set_fact:
|
set_fact:
|
||||||
|
|||||||
9
ci/roles/application_credential/defaults/main.yml
Normal file
9
ci/roles/application_credential/defaults/main.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
expected_fields:
|
||||||
|
- description
|
||||||
|
- expires_at
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
- project_id
|
||||||
|
- roles
|
||||||
|
- secret
|
||||||
|
- unrestricted
|
||||||
61
ci/roles/application_credential/tasks/main.yml
Normal file
61
ci/roles/application_credential/tasks/main.yml
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Create application credentials
|
||||||
|
openstack.cloud.application_credential:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_creds
|
||||||
|
description: dummy description
|
||||||
|
register: appcred
|
||||||
|
|
||||||
|
- name: Assert return values of application_credential module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- appcred is changed
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(appcred.application_credential.keys())|length == 0
|
||||||
|
|
||||||
|
- name: Create the application credential again
|
||||||
|
openstack.cloud.application_credential:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_creds
|
||||||
|
description: dummy description
|
||||||
|
register: appcred
|
||||||
|
|
||||||
|
- name: Assert return values of ansible_credential module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
# credentials are immutable so creating twice will cause delete and create
|
||||||
|
- appcred is changed
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(appcred.application_credential.keys())|length == 0
|
||||||
|
|
||||||
|
- name: Update the application credential again
|
||||||
|
openstack.cloud.application_credential:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_creds
|
||||||
|
description: new description
|
||||||
|
register: appcred
|
||||||
|
|
||||||
|
- name: Assert application credential changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- appcred is changed
|
||||||
|
- appcred.application_credential.description == 'new description'
|
||||||
|
|
||||||
|
- name: Get list of all keypairs using application credential
|
||||||
|
openstack.cloud.keypair_info:
|
||||||
|
cloud: "{{ appcred.cloud }}"
|
||||||
|
|
||||||
|
- name: Delete application credential
|
||||||
|
openstack.cloud.application_credential:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: ansible_creds
|
||||||
|
register: appcred
|
||||||
|
|
||||||
|
- name: Assert application credential changed
|
||||||
|
assert:
|
||||||
|
that: appcred is changed
|
||||||
@@ -46,6 +46,7 @@ expected_fields:
|
|||||||
- reservation
|
- reservation
|
||||||
- resource_class
|
- resource_class
|
||||||
- retired_reason
|
- retired_reason
|
||||||
|
- shard
|
||||||
- states
|
- states
|
||||||
- storage_interface
|
- storage_interface
|
||||||
- target_power_state
|
- target_power_state
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ expected_fields:
|
|||||||
- reservation
|
- reservation
|
||||||
- resource_class
|
- resource_class
|
||||||
- retired_reason
|
- retired_reason
|
||||||
|
- shard
|
||||||
- states
|
- states
|
||||||
- storage_interface
|
- storage_interface
|
||||||
- target_power_state
|
- target_power_state
|
||||||
|
|||||||
12
ci/roles/baremetal_port_group/defaults/main.yml
Normal file
12
ci/roles/baremetal_port_group/defaults/main.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
expected_fields:
|
||||||
|
- address
|
||||||
|
- created_at
|
||||||
|
- extra
|
||||||
|
- id
|
||||||
|
- links
|
||||||
|
- mode
|
||||||
|
- name
|
||||||
|
- node_id
|
||||||
|
- properties
|
||||||
|
- standalone_ports_supported
|
||||||
|
- updated_at
|
||||||
100
ci/roles/baremetal_port_group/tasks/main.yml
Normal file
100
ci/roles/baremetal_port_group/tasks/main.yml
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
---
|
||||||
|
# TODO: Actually run this role in CI. Atm we do not have DevStack's ironic plugin enabled.
|
||||||
|
- name: Create baremetal node
|
||||||
|
openstack.cloud.baremetal_node:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
driver_info:
|
||||||
|
ipmi_address: "1.2.3.4"
|
||||||
|
ipmi_username: "admin"
|
||||||
|
ipmi_password: "secret"
|
||||||
|
name: ansible_baremetal_node
|
||||||
|
nics:
|
||||||
|
- mac: "aa:bb:cc:aa:bb:cc"
|
||||||
|
state: present
|
||||||
|
register: node
|
||||||
|
|
||||||
|
- name: Create baremetal port group
|
||||||
|
openstack.cloud.baremetal_port_group:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_baremetal_port_group
|
||||||
|
node: ansible_baremetal_node
|
||||||
|
address: fa:16:3e:aa:aa:ab
|
||||||
|
mode: active-backup
|
||||||
|
standalone_ports_supported: true
|
||||||
|
extra:
|
||||||
|
test: created
|
||||||
|
properties:
|
||||||
|
miimon: '100'
|
||||||
|
register: port_group
|
||||||
|
|
||||||
|
- debug: var=port_group
|
||||||
|
|
||||||
|
- name: Assert return values of baremetal_port_group module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(port_group.port_group.keys())|length == 0
|
||||||
|
- port_group.port_group.name == "ansible_baremetal_port_group"
|
||||||
|
- port_group.port_group.node_id == node.node.id
|
||||||
|
|
||||||
|
- name: Update baremetal port group
|
||||||
|
openstack.cloud.baremetal_port_group:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
id: "{{ port_group.port_group.id }}"
|
||||||
|
mode: 802.3ad
|
||||||
|
standalone_ports_supported: false
|
||||||
|
extra:
|
||||||
|
test: updated
|
||||||
|
register: updated_port_group
|
||||||
|
|
||||||
|
- name: Assert return values of updated baremetal port group
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- updated_port_group is changed
|
||||||
|
- updated_port_group.port_group.id == port_group.port_group.id
|
||||||
|
- updated_port_group.port_group.mode == "802.3ad"
|
||||||
|
- not updated_port_group.port_group.standalone_ports_supported
|
||||||
|
- updated_port_group.port_group.extra.test == "updated"
|
||||||
|
|
||||||
|
- name: Update baremetal port group again
|
||||||
|
openstack.cloud.baremetal_port_group:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
id: "{{ port_group.port_group.id }}"
|
||||||
|
mode: 802.3ad
|
||||||
|
standalone_ports_supported: false
|
||||||
|
extra:
|
||||||
|
test: updated
|
||||||
|
register: updated_port_group
|
||||||
|
|
||||||
|
- name: Assert idempotency for baremetal port group module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- updated_port_group is not changed
|
||||||
|
- updated_port_group.port_group.id == port_group.port_group.id
|
||||||
|
|
||||||
|
- name: Delete baremetal port group
|
||||||
|
openstack.cloud.baremetal_port_group:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
id: "{{ port_group.port_group.id }}"
|
||||||
|
|
||||||
|
- name: Delete baremetal port group again
|
||||||
|
openstack.cloud.baremetal_port_group:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
id: "{{ port_group.port_group.id }}"
|
||||||
|
register: deleted_port_group
|
||||||
|
|
||||||
|
- name: Assert idempotency for deleted baremetal port group
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- deleted_port_group is not changed
|
||||||
|
|
||||||
|
- name: Delete baremetal node
|
||||||
|
openstack.cloud.baremetal_node:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_baremetal_node
|
||||||
|
state: absent
|
||||||
@@ -72,6 +72,8 @@
|
|||||||
image_id: '{{ image_id }}'
|
image_id: '{{ image_id }}'
|
||||||
is_floating_ip_enabled: true
|
is_floating_ip_enabled: true
|
||||||
keypair_id: '{{ keypair.keypair.id }}'
|
keypair_id: '{{ keypair.keypair.id }}'
|
||||||
|
flavor_id: 'm1.small'
|
||||||
|
master_flavor_id: 'm1.small'
|
||||||
name: k8s
|
name: k8s
|
||||||
state: present
|
state: present
|
||||||
register: coe_cluster_template
|
register: coe_cluster_template
|
||||||
|
|||||||
@@ -26,6 +26,9 @@
|
|||||||
keypair_id: '{{ keypair.keypair.id }}'
|
keypair_id: '{{ keypair.keypair.id }}'
|
||||||
name: k8s
|
name: k8s
|
||||||
state: present
|
state: present
|
||||||
|
labels:
|
||||||
|
docker_volume_size: 10
|
||||||
|
cloud_provider_tag: v1.23.1
|
||||||
register: coe_cluster_template
|
register: coe_cluster_template
|
||||||
|
|
||||||
- name: Assert return values of coe_cluster_template module
|
- name: Assert return values of coe_cluster_template module
|
||||||
@@ -43,6 +46,9 @@
|
|||||||
keypair_id: '{{ keypair.keypair.id }}'
|
keypair_id: '{{ keypair.keypair.id }}'
|
||||||
name: k8s
|
name: k8s
|
||||||
state: present
|
state: present
|
||||||
|
labels:
|
||||||
|
docker_volume_size: 10
|
||||||
|
cloud_provider_tag: v1.23.1
|
||||||
register: coe_cluster_template
|
register: coe_cluster_template
|
||||||
|
|
||||||
- name: Assert return values of coe_cluster_template module
|
- name: Assert return values of coe_cluster_template module
|
||||||
|
|||||||
@@ -21,3 +21,50 @@
|
|||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- compute_services.compute_services | length > 0
|
- compute_services.compute_services | length > 0
|
||||||
|
|
||||||
|
- name: Disable compute service on a node
|
||||||
|
openstack.cloud.compute_service:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
host: "{{ compute_services.compute_services[0].host }}"
|
||||||
|
binary: 'nova-compute'
|
||||||
|
status: 'disabled'
|
||||||
|
disabled_reason: 'maintenance'
|
||||||
|
register: compute_service_disabled
|
||||||
|
|
||||||
|
- name: Assert service being "disabled"
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- compute_service_disabled.compute_services | map(attribute='status') | unique | length == 1
|
||||||
|
- compute_service_disabled.compute_services | map(attribute='disabled_reason') | unique | length == 1
|
||||||
|
- compute_service_disabled.compute_services[0].status == "disabled"
|
||||||
|
- compute_service_disabled.compute_services[0].disabled_reason == "maintenance"
|
||||||
|
- compute_service_disabled is changed
|
||||||
|
|
||||||
|
- name: Disable compute service on a node again
|
||||||
|
openstack.cloud.compute_service:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
host: "{{ compute_services.compute_services[0].host }}"
|
||||||
|
binary: 'nova-compute'
|
||||||
|
status: 'disabled'
|
||||||
|
disabled_reason: 'maintenance'
|
||||||
|
register: compute_service_disabled_again
|
||||||
|
|
||||||
|
- name: Assert idempotency of service disable
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- compute_service_disabled_again is not changed
|
||||||
|
|
||||||
|
- name: Re-enable compute service
|
||||||
|
openstack.cloud.compute_service:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
host: "{{ compute_services.compute_services[0].host }}"
|
||||||
|
binary: 'nova-compute'
|
||||||
|
status: 'enabled'
|
||||||
|
register: compute_service_enabled
|
||||||
|
|
||||||
|
- name: Assert service being "disabled"
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- compute_service_enabled.compute_services | map(attribute='status') | unique | length == 1
|
||||||
|
- compute_service_enabled.compute_services[0].status == "enabled"
|
||||||
|
- compute_service_enabled is changed
|
||||||
|
|||||||
@@ -27,6 +27,12 @@
|
|||||||
name: ansible_external
|
name: ansible_external
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
|
- name: Gather information about external network
|
||||||
|
openstack.cloud.networks_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_external
|
||||||
|
register: external_network
|
||||||
|
|
||||||
- name: Create external subnet
|
- name: Create external subnet
|
||||||
openstack.cloud.subnet:
|
openstack.cloud.subnet:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -98,6 +104,17 @@
|
|||||||
- ip_address: 10.7.7.102
|
- ip_address: 10.7.7.102
|
||||||
register: port3
|
register: port3
|
||||||
|
|
||||||
|
- name: Create internal port 4
|
||||||
|
openstack.cloud.port:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_internal_port4
|
||||||
|
network: ansible_internal
|
||||||
|
fixed_ips:
|
||||||
|
- ip_address: 10.7.7.103
|
||||||
|
- ip_address: 10.7.7.104
|
||||||
|
register: port4
|
||||||
|
|
||||||
- name: Create router 1
|
- name: Create router 1
|
||||||
openstack.cloud.router:
|
openstack.cloud.router:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -136,10 +153,31 @@
|
|||||||
selectattr('floating_network_id', '==', public_network.networks.0.id)|
|
selectattr('floating_network_id', '==', public_network.networks.0.id)|
|
||||||
list|length > 0 }}"
|
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)
|
- 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
|
when: not public_network_had_fips
|
||||||
|
block:
|
||||||
|
- name: Create a floating ip on public network
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
network: public
|
||||||
|
register: public_fip_result
|
||||||
|
|
||||||
|
- name: Verify floating ip got created
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- public_fip_result.floating_ip.floating_network_id == public_network.networks.0.id
|
||||||
|
|
||||||
|
- name: Create a floating ip on public network again
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
network: public
|
||||||
|
register: public_fip_result
|
||||||
|
|
||||||
|
- name: Verify idempotency
|
||||||
|
assert:
|
||||||
|
that: public_fip_result is not changed
|
||||||
|
|
||||||
# TODO: Replace with appropriate Ansible module once available
|
# TODO: Replace with appropriate Ansible module once available
|
||||||
- name: Create floating ip 1 on external network
|
- name: Create floating ip 1 on external network
|
||||||
@@ -151,6 +189,90 @@
|
|||||||
when: fips.floating_ips|length == 0 or
|
when: fips.floating_ips|length == 0 or
|
||||||
"10.6.6.150" not in fips.floating_ips|map(attribute="floating_ip_address")|list
|
"10.6.6.150" not in fips.floating_ips|map(attribute="floating_ip_address")|list
|
||||||
|
|
||||||
|
- name: Create floating ip 2 on external network
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
network: ansible_external
|
||||||
|
floating_ip_address: 10.6.6.151
|
||||||
|
register: external_fip2_result
|
||||||
|
|
||||||
|
- name: Verify floating ip got created
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- external_fip2_result.floating_ip.floating_network_id == external_network.networks.0.id
|
||||||
|
|
||||||
|
- name: Update floating ip 2 on external network
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
network: ansible_external
|
||||||
|
floating_ip_address: 10.6.6.151
|
||||||
|
nat_destination: ansible_internal
|
||||||
|
fixed_address: 10.7.7.104
|
||||||
|
register: external_fip2_result
|
||||||
|
|
||||||
|
- name: Verify floating ip got updated
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- external_fip2_result is changed
|
||||||
|
- external_fip2_result.floating_ip.floating_ip_address == "10.6.6.151"
|
||||||
|
- external_fip2_result.floating_ip.port_id == port4.port.id
|
||||||
|
- external_fip2_result.floating_ip.fixed_ip_address == "10.7.7.104"
|
||||||
|
|
||||||
|
- name: Update floating ip 2 on external network again
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
network: ansible_external
|
||||||
|
floating_ip_address: 10.6.6.151
|
||||||
|
nat_destination: ansible_internal
|
||||||
|
fixed_address: 10.7.7.104
|
||||||
|
register: external_fip2_result
|
||||||
|
|
||||||
|
- name: Verify idempotency
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- external_fip2_result is not changed
|
||||||
|
|
||||||
|
- name: Detatch floating ip 2 on external network from port
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
network: ansible_external
|
||||||
|
floating_ip_address: 10.6.6.151
|
||||||
|
|
||||||
|
- name: Get floating ip 2 info
|
||||||
|
openstack.cloud.floating_ip_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
floating_ip_address: 10.6.6.151
|
||||||
|
register: external_fip2_result
|
||||||
|
|
||||||
|
- name: Verify floating ip got detached
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- external_fip2_result.floating_ips.0.floating_ip_address == "10.6.6.151"
|
||||||
|
- external_fip2_result.floating_ips.0.fixed_ip_address == none
|
||||||
|
- external_fip2_result.floating_ips.0.port_id == none
|
||||||
|
|
||||||
|
- name: Detatch floating ip 2 on external network from port again
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
network: ansible_external
|
||||||
|
floating_ip_address: 10.6.6.151
|
||||||
|
|
||||||
|
- name: Get floating ip 2 info
|
||||||
|
openstack.cloud.floating_ip_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
floating_ip_address: 10.6.6.151
|
||||||
|
register: external_fip2_result
|
||||||
|
|
||||||
|
- name: Verify idempotency
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- external_fip2_result is not changed
|
||||||
|
|
||||||
- name: Create server 1 with one nic
|
- name: Create server 1 with one nic
|
||||||
openstack.cloud.server:
|
openstack.cloud.server:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -241,7 +363,7 @@
|
|||||||
that:
|
that:
|
||||||
- server1_fips is success
|
- server1_fips is success
|
||||||
- server1_fips is not changed
|
- server1_fips is not changed
|
||||||
- server1_fips.floating_ips
|
- server1_fips.floating_ips|length > 0
|
||||||
# allow new fields to be introduced but prevent fields from being removed
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
- expected_fields|difference(server1_fips.floating_ips[0].keys())|length == 0
|
- expected_fields|difference(server1_fips.floating_ips[0].keys())|length == 0
|
||||||
|
|
||||||
@@ -260,7 +382,7 @@
|
|||||||
- name: Assert return values of floating_ip module
|
- name: Assert return values of floating_ip module
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- floating_ip.floating_ip
|
- floating_ip.floating_ip|length > 0
|
||||||
# allow new fields to be introduced but prevent fields from being removed
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
- expected_fields|difference(floating_ip.floating_ip.keys())|length == 0
|
- expected_fields|difference(floating_ip.floating_ip.keys())|length == 0
|
||||||
|
|
||||||
@@ -312,7 +434,7 @@
|
|||||||
- name: Assert floating ip attached to server 2
|
- name: Assert floating ip attached to server 2
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- server2_fip.floating_ip
|
- server2_fip.floating_ip|length > 0
|
||||||
|
|
||||||
- name: Find all floating ips for debugging
|
- name: Find all floating ips for debugging
|
||||||
openstack.cloud.floating_ip_info:
|
openstack.cloud.floating_ip_info:
|
||||||
@@ -433,18 +555,41 @@
|
|||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
register: fips
|
register: fips
|
||||||
|
|
||||||
# TODO: Replace with appropriate Ansible module once available
|
|
||||||
- name: Delete floating ip on public network if we created it
|
- name: Delete floating ip on public network if we created it
|
||||||
when: not public_network_had_fips
|
when: not public_network_had_fips
|
||||||
command: >
|
openstack.cloud.floating_ip:
|
||||||
openstack --os-cloud={{ cloud }} floating ip delete
|
cloud: "{{ cloud }}"
|
||||||
{{ fips.floating_ips|selectattr('floating_network_id', '==', public_network.networks.0.id)|
|
state: absent
|
||||||
map(attribute="floating_ip_address")|list|join(' ') }}
|
purge: true
|
||||||
|
floating_ip_address: "{{ public_fip }}"
|
||||||
|
network: public
|
||||||
|
loop: >-
|
||||||
|
{{
|
||||||
|
fips.floating_ips |
|
||||||
|
selectattr('floating_network_id', '==', public_network.networks.0.id) |
|
||||||
|
map(attribute="floating_ip_address") |
|
||||||
|
list
|
||||||
|
}}
|
||||||
|
loop_control:
|
||||||
|
loop_var: public_fip
|
||||||
|
|
||||||
# TODO: Replace with appropriate Ansible module once available
|
|
||||||
- name: Delete floating ip 1
|
- 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
|
when: fips.floating_ips|length > 0 and "10.6.6.150" in fips.floating_ips|map(attribute="floating_ip_address")|list
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
purge: true
|
||||||
|
floating_ip_address: 10.6.6.150
|
||||||
|
network: ansible_external
|
||||||
|
|
||||||
|
- name: Delete floating ip 2
|
||||||
|
when: fips.floating_ips|length > 0 and "10.6.6.151" in fips.floating_ips|map(attribute="floating_ip_address")|list
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
purge: true
|
||||||
|
floating_ip_address: 10.6.6.151
|
||||||
|
network: ansible_external
|
||||||
|
|
||||||
- name: Get remaining floating ips on external network
|
- name: Get remaining floating ips on external network
|
||||||
openstack.cloud.floating_ip_info:
|
openstack.cloud.floating_ip_info:
|
||||||
@@ -452,14 +597,24 @@
|
|||||||
floating_network: ansible_external
|
floating_network: ansible_external
|
||||||
register: fips
|
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.
|
# 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.
|
# This floating ip must be removed before external network can be deleted.
|
||||||
- name: Delete remaining floating ips on external network
|
- name: Delete remaining floating ips on external network
|
||||||
when: fips.floating_ips|length > 0
|
when: fips.floating_ips|length > 0
|
||||||
command: >
|
openstack.cloud.floating_ip:
|
||||||
openstack --os-cloud={{ cloud }} floating ip delete
|
cloud: "{{ cloud }}"
|
||||||
{{ fips.floating_ips|map(attribute="floating_ip_address")|list|join(' ') }}
|
state: absent
|
||||||
|
purge: true
|
||||||
|
floating_ip_address: "{{ external_fip }}"
|
||||||
|
network: ansible_external
|
||||||
|
loop: >-
|
||||||
|
{{
|
||||||
|
fips.floating_ips |
|
||||||
|
map(attribute="floating_ip_address") |
|
||||||
|
list
|
||||||
|
}}
|
||||||
|
loop_control:
|
||||||
|
loop_var: external_fip
|
||||||
|
|
||||||
# Remove routers after floating ips have been detached and disassociated else removal fails with
|
# Remove routers after floating ips have been detached and disassociated else removal fails with
|
||||||
# Error detaching interface from router ***: Client Error for url: ***,
|
# Error detaching interface from router ***: Client Error for url: ***,
|
||||||
@@ -478,6 +633,12 @@
|
|||||||
state: absent
|
state: absent
|
||||||
name: ansible_router1
|
name: ansible_router1
|
||||||
|
|
||||||
|
- name: Delete internal port 4
|
||||||
|
openstack.cloud.port:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: ansible_internal_port4
|
||||||
|
|
||||||
- name: Delete internal port 3
|
- name: Delete internal port 3
|
||||||
openstack.cloud.port:
|
openstack.cloud.port:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
|
|||||||
@@ -24,6 +24,13 @@
|
|||||||
path: '{{ tmp_file.path }}'
|
path: '{{ tmp_file.path }}'
|
||||||
size: 1M
|
size: 1M
|
||||||
|
|
||||||
|
- name: Calculating file checksum
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ tmp_file.path }}"
|
||||||
|
checksum_algorithm: sha512
|
||||||
|
get_checksum: true
|
||||||
|
register: image_details
|
||||||
|
|
||||||
- name: Ensure mock kernel and ramdisk images (defaults)
|
- name: Ensure mock kernel and ramdisk images (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -42,6 +49,7 @@
|
|||||||
name: ansible_image
|
name: ansible_image
|
||||||
filename: "{{ tmp_file.path }}"
|
filename: "{{ tmp_file.path }}"
|
||||||
is_protected: true
|
is_protected: true
|
||||||
|
checksum: "{{ image_details.stat.checksum }}"
|
||||||
disk_format: raw
|
disk_format: raw
|
||||||
tags:
|
tags:
|
||||||
- test
|
- test
|
||||||
@@ -168,6 +176,34 @@
|
|||||||
- image is changed
|
- image is changed
|
||||||
- image.image.name == 'ansible_image-changed'
|
- image.image.name == 'ansible_image-changed'
|
||||||
|
|
||||||
|
- name: Deactivate raw image
|
||||||
|
openstack.cloud.image:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: inactive
|
||||||
|
id: "{{ image.image.id }}"
|
||||||
|
name: 'ansible_image-changed'
|
||||||
|
register: image
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- image is changed
|
||||||
|
- image.image.status == 'deactivated'
|
||||||
|
|
||||||
|
- name: Reactivate raw image
|
||||||
|
openstack.cloud.image:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
id: "{{ image.image.id }}"
|
||||||
|
name: 'ansible_image-changed'
|
||||||
|
register: image
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- image is changed
|
||||||
|
- image.image.status == 'active'
|
||||||
|
|
||||||
- name: Rename back raw image (defaults)
|
- name: Rename back raw image (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
|
|||||||
@@ -279,6 +279,11 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
cache: "{{ cache.content | b64decode | from_yaml }}"
|
cache: "{{ cache.content | b64decode | from_yaml }}"
|
||||||
|
|
||||||
|
- name: Further process Ansible 2.19+ cache
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
cache: "{{ cache.__payload__ | from_yaml }}"
|
||||||
|
when: cache.__payload__ is defined
|
||||||
|
|
||||||
- name: Check Ansible's cache
|
- name: Check Ansible's cache
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
@@ -303,6 +308,25 @@
|
|||||||
that:
|
that:
|
||||||
- inventory.all.children.RegionOne.hosts.keys() | sort == ['ansible_server1', 'ansible_server2'] | sort
|
- inventory.all.children.RegionOne.hosts.keys() | sort == ['ansible_server1', 'ansible_server2'] | sort
|
||||||
|
|
||||||
|
- name: List servers with inventory plugin with IPv4 only
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: ansible-inventory --list --yaml --extra-vars only_ipv4=true --inventory-file openstack.yaml
|
||||||
|
chdir: "{{ tmp_dir.path }}"
|
||||||
|
environment:
|
||||||
|
ANSIBLE_INVENTORY_CACHE: "True"
|
||||||
|
ANSIBLE_INVENTORY_CACHE_PLUGIN: "jsonfile"
|
||||||
|
ANSIBLE_CACHE_PLUGIN_CONNECTION: "{{ tmp_dir.path }}/.cache/"
|
||||||
|
register: inventory
|
||||||
|
|
||||||
|
- name: Read YAML output from inventory plugin again
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
inventory: "{{ inventory.stdout | from_yaml }}"
|
||||||
|
|
||||||
|
- name: Check YAML output from inventory plugin again
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- inventory.all.children.RegionOne.hosts.keys() | sort == ['ansible_server1', 'ansible_server2'] | sort
|
||||||
|
|
||||||
- name: Delete server 2
|
- name: Delete server 2
|
||||||
openstack.cloud.resource:
|
openstack.cloud.resource:
|
||||||
service: compute
|
service: compute
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
- name: Ensure public key is returned
|
- name: Ensure public key is returned
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- keypair.keypair.public_key is defined and keypair.keypair.public_key
|
- keypair.keypair.public_key is defined and keypair.keypair.public_key|length > 0
|
||||||
|
|
||||||
- name: Create another keypair
|
- name: Create another keypair
|
||||||
openstack.cloud.keypair:
|
openstack.cloud.keypair:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
- name: Check output of creating network
|
- name: Check output of creating network
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- infonet.network
|
- infonet.network is defined
|
||||||
- item in infonet.network
|
- item in infonet.network
|
||||||
loop: "{{ expected_fields }}"
|
loop: "{{ expected_fields }}"
|
||||||
|
|
||||||
@@ -69,6 +69,9 @@
|
|||||||
external: false
|
external: false
|
||||||
mtu: "{{ mtu }}"
|
mtu: "{{ mtu }}"
|
||||||
port_security_enabled: "{{ port_security_enabled }}"
|
port_security_enabled: "{{ port_security_enabled }}"
|
||||||
|
tags:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
register: result_create_nw_with_new_params
|
register: result_create_nw_with_new_params
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
@@ -85,6 +88,8 @@
|
|||||||
- result_newparams.networks.0.mtu == mtu
|
- result_newparams.networks.0.mtu == mtu
|
||||||
- "'is_port_security_enabled' in result_newparams.networks.0"
|
- "'is_port_security_enabled' in result_newparams.networks.0"
|
||||||
- result_newparams.networks.0['is_port_security_enabled'] == port_security_enabled
|
- result_newparams.networks.0['is_port_security_enabled'] == port_security_enabled
|
||||||
|
- "'foo' in result_newparams.networks.0.tags"
|
||||||
|
- "'bar' in result_newparams.networks.0.tags"
|
||||||
|
|
||||||
- name: Delete network - generic and with new SDK params
|
- name: Delete network - generic and with new SDK params
|
||||||
openstack.cloud.network:
|
openstack.cloud.network:
|
||||||
@@ -115,6 +120,9 @@
|
|||||||
external: false
|
external: false
|
||||||
mtu: "{{ mtu }}"
|
mtu: "{{ mtu }}"
|
||||||
port_security_enabled: "{{ port_security_enabled }}"
|
port_security_enabled: "{{ port_security_enabled }}"
|
||||||
|
tags:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
register: result_create_nw_for_updates
|
register: result_create_nw_for_updates
|
||||||
|
|
||||||
- name: Update network - update failure
|
- name: Update network - update failure
|
||||||
@@ -147,6 +155,11 @@
|
|||||||
mtu: "{{ mtu - 50 }}"
|
mtu: "{{ mtu - 50 }}"
|
||||||
# NOTE: This property should be updated
|
# NOTE: This property should be updated
|
||||||
port_security_enabled: "{{ not port_security_enabled }}"
|
port_security_enabled: "{{ not port_security_enabled }}"
|
||||||
|
# NOTE: This property should be updated
|
||||||
|
tags:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
|
- baz
|
||||||
register: result_nw_update_success
|
register: result_nw_update_success
|
||||||
|
|
||||||
- name: Gather networks info - updates
|
- name: Gather networks info - updates
|
||||||
@@ -162,6 +175,29 @@
|
|||||||
- result_network_updates_info.networks.0.name == network_name_updates
|
- result_network_updates_info.networks.0.name == network_name_updates
|
||||||
- result_network_updates_info.networks.0.mtu == mtu - 50
|
- result_network_updates_info.networks.0.mtu == mtu - 50
|
||||||
- result_network_updates_info.networks.0['is_port_security_enabled'] == (not port_security_enabled)
|
- result_network_updates_info.networks.0['is_port_security_enabled'] == (not port_security_enabled)
|
||||||
|
- "'foo' in result_network_updates_info.networks.0.tags"
|
||||||
|
- "'bar' in result_network_updates_info.networks.0.tags"
|
||||||
|
- "'baz' in result_network_updates_info.networks.0.tags"
|
||||||
|
|
||||||
|
- name: Update network - no change
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ network_name_updates }}"
|
||||||
|
state: present
|
||||||
|
shared: "{{ network_shared }}"
|
||||||
|
external: false
|
||||||
|
mtu: "{{ mtu - 50 }}"
|
||||||
|
port_security_enabled: "{{ not port_security_enabled }}"
|
||||||
|
tags:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
|
- baz
|
||||||
|
register: result_nw_update_no_change
|
||||||
|
|
||||||
|
- name: Verify networks info - no change
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result_nw_update_no_change is not changed
|
||||||
|
|
||||||
- name: Delete network - updates
|
- name: Delete network - updates
|
||||||
openstack.cloud.network:
|
openstack.cloud.network:
|
||||||
|
|||||||
17
ci/roles/network_segment/defaults/main.yml
Normal file
17
ci/roles/network_segment/defaults/main.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
expected_fields:
|
||||||
|
- description
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
- network_id
|
||||||
|
- network_type
|
||||||
|
- physical_network
|
||||||
|
- segmentation_id
|
||||||
|
|
||||||
|
network_name: segment_network
|
||||||
|
segment_name: example_segment
|
||||||
|
network_type: vlan
|
||||||
|
segmentation_id: 999
|
||||||
|
physical_network: public
|
||||||
|
initial_description: "example segment description"
|
||||||
|
updated_description: "updated segment description"
|
||||||
72
ci/roles/network_segment/tasks/main.yml
Normal file
72
ci/roles/network_segment/tasks/main.yml
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
---
|
||||||
|
- name: Create network {{ network_name }}
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ network_name }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create segment {{ segment_name }}
|
||||||
|
openstack.cloud.network_segment:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ segment_name }}"
|
||||||
|
description: "{{ initial_description }}"
|
||||||
|
network: "{{ network_name }}"
|
||||||
|
network_type: "{{ network_type }}"
|
||||||
|
segmentation_id: "{{ segmentation_id }}"
|
||||||
|
physical_network: "{{ physical_network }}"
|
||||||
|
state: present
|
||||||
|
register: segment
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that: segment is changed
|
||||||
|
|
||||||
|
- name: Assert segment fields
|
||||||
|
assert:
|
||||||
|
that: item in segment.network_segment
|
||||||
|
loop: "{{ expected_fields }}"
|
||||||
|
|
||||||
|
- name: Update segment {{ segment_name }} by name - no changes
|
||||||
|
openstack.cloud.network_segment:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ segment_name }}"
|
||||||
|
description: "{{ initial_description }}"
|
||||||
|
state: present
|
||||||
|
register: segment
|
||||||
|
|
||||||
|
- name: Assert not changed
|
||||||
|
assert:
|
||||||
|
that: segment is not changed
|
||||||
|
|
||||||
|
- name: Update segment {{ segment_name }} by all fields - changes
|
||||||
|
openstack.cloud.network_segment:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ segment_name }}"
|
||||||
|
description: "{{ updated_description }}"
|
||||||
|
network: "{{ network_name }}"
|
||||||
|
network_type: "{{ network_type }}"
|
||||||
|
segmentation_id: "{{ segmentation_id }}"
|
||||||
|
physical_network: "{{ physical_network }}"
|
||||||
|
state: present
|
||||||
|
register: segment
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that: segment is changed
|
||||||
|
|
||||||
|
- name: Delete segment {{ segment_name }}
|
||||||
|
openstack.cloud.network_segment:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ segment_name }}"
|
||||||
|
state: absent
|
||||||
|
register: segment
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that: segment is changed
|
||||||
|
|
||||||
|
- name: Delete network {{ network_name }}
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ network_name }}"
|
||||||
|
state: absent
|
||||||
@@ -7,3 +7,4 @@ expected_fields:
|
|||||||
- project_id
|
- project_id
|
||||||
- target_project_id
|
- target_project_id
|
||||||
- tenant_id
|
- tenant_id
|
||||||
|
all_project_symbol: '*'
|
||||||
|
|||||||
@@ -69,6 +69,29 @@
|
|||||||
id: "{{ rbac_policy.rbac_policy.id }}"
|
id: "{{ rbac_policy.rbac_policy.id }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
- name: Create a new network RBAC policy by targeting all projects
|
||||||
|
openstack.cloud.neutron_rbac_policy:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
object_id: "{{ network.network.id }}"
|
||||||
|
object_type: 'network'
|
||||||
|
action: 'access_as_shared'
|
||||||
|
target_all_project: true
|
||||||
|
project_id: "{{ source_project.project.id }}"
|
||||||
|
register: rbac_policy
|
||||||
|
|
||||||
|
- name: Assert return values of neutron_rbac_policy module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(rbac_policy.rbac_policy.keys())|length == 0
|
||||||
|
- rbac_policy.rbac_policy.target_project_id == all_project_symbol
|
||||||
|
|
||||||
|
- name: Delete RBAC policy
|
||||||
|
openstack.cloud.neutron_rbac_policy:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
id: "{{ rbac_policy.rbac_policy.id }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Get all rbac policies for {{ source_project.project.name }} - after deletion
|
- name: Get all rbac policies for {{ source_project.project.name }} - after deletion
|
||||||
openstack.cloud.neutron_rbac_policies_info:
|
openstack.cloud.neutron_rbac_policies_info:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
state: present
|
state: present
|
||||||
name: ansible_container
|
name: ansible_container
|
||||||
|
|
||||||
- name: Create object
|
- name: Create object from data
|
||||||
openstack.cloud.object:
|
openstack.cloud.object:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
@@ -28,6 +28,47 @@
|
|||||||
name: ansible_object
|
name: ansible_object
|
||||||
container: ansible_container
|
container: ansible_container
|
||||||
|
|
||||||
|
- name: Create object from file
|
||||||
|
block:
|
||||||
|
- name: Create temporary data file
|
||||||
|
ansible.builtin.tempfile:
|
||||||
|
register: tmp_file
|
||||||
|
|
||||||
|
- name: Populate data file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "this is a test"
|
||||||
|
dest: "{{ tmp_file.path }}"
|
||||||
|
|
||||||
|
- name: Create object from data file
|
||||||
|
openstack.cloud.object:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_object
|
||||||
|
filename: "{{ tmp_file.path }}"
|
||||||
|
container: ansible_container
|
||||||
|
register: object
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove temporary data file
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ tmp_file.path }}"
|
||||||
|
state: absent
|
||||||
|
when: tmp_file is defined and 'path' in tmp_file
|
||||||
|
|
||||||
|
- name: Assert return values of object module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- object.object.id == "ansible_object"
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(object.object.keys())|length == 0
|
||||||
|
|
||||||
|
- name: Delete object
|
||||||
|
openstack.cloud.object:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: ansible_object
|
||||||
|
container: ansible_container
|
||||||
|
|
||||||
- name: Delete container
|
- name: Delete container
|
||||||
openstack.cloud.object_container:
|
openstack.cloud.object_container:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
|
|||||||
@@ -31,6 +31,21 @@
|
|||||||
- ('cache-control' in container.container.metadata.keys()|map('lower'))
|
- ('cache-control' in container.container.metadata.keys()|map('lower'))
|
||||||
- container.container.metadata['foo'] == 'bar'
|
- container.container.metadata['foo'] == 'bar'
|
||||||
|
|
||||||
|
- name: Update container metadata
|
||||||
|
openstack.cloud.object_container:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_container
|
||||||
|
metadata:
|
||||||
|
'foo': 'baz'
|
||||||
|
register: container
|
||||||
|
|
||||||
|
- name: Verify container metadata was updated
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- container is changed
|
||||||
|
- ('cache-control' in container.container.metadata.keys()|map('lower'))
|
||||||
|
- container.container.metadata['foo'] == 'baz'
|
||||||
|
|
||||||
- name: Update a container
|
- name: Update a container
|
||||||
openstack.cloud.object_container:
|
openstack.cloud.object_container:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -45,7 +60,7 @@
|
|||||||
that:
|
that:
|
||||||
- container is changed
|
- container is changed
|
||||||
- ('cache-control' not in container.container.metadata.keys()|map('lower'))
|
- ('cache-control' not in container.container.metadata.keys()|map('lower'))
|
||||||
- "container.container.metadata == {'foo': 'bar'}"
|
- "container.container.metadata == {'foo': 'baz'}"
|
||||||
- container.container.read_ACL is none or container.container.read_ACL == ""
|
- container.container.read_ACL is none or container.container.read_ACL == ""
|
||||||
|
|
||||||
- name: Delete container
|
- name: Delete container
|
||||||
|
|||||||
37
ci/roles/object_containers_info/defaults/main.yml
Normal file
37
ci/roles/object_containers_info/defaults/main.yml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
test_container_unprefixed_name: ansible-test-container
|
||||||
|
test_container_prefixed_prefix: ansible-prefixed-test-container
|
||||||
|
test_container_prefixed_num: 2
|
||||||
|
|
||||||
|
test_object_data: "Hello, world!"
|
||||||
|
|
||||||
|
expected_fields_single:
|
||||||
|
- bytes
|
||||||
|
- bytes_used
|
||||||
|
- content_type
|
||||||
|
- count
|
||||||
|
- history_location
|
||||||
|
- id
|
||||||
|
- if_none_match
|
||||||
|
- is_content_type_detected
|
||||||
|
- is_newest
|
||||||
|
- meta_temp_url_key
|
||||||
|
- meta_temp_url_key_2
|
||||||
|
- name
|
||||||
|
- object_count
|
||||||
|
- read_ACL
|
||||||
|
- storage_policy
|
||||||
|
- sync_key
|
||||||
|
- sync_to
|
||||||
|
- timestamp
|
||||||
|
- versions_location
|
||||||
|
- write_ACL
|
||||||
|
|
||||||
|
expected_fields_multiple:
|
||||||
|
- bytes
|
||||||
|
- bytes_used
|
||||||
|
- count
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
- object_count
|
||||||
124
ci/roles/object_containers_info/tasks/main.yml
Normal file
124
ci/roles/object_containers_info/tasks/main.yml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Generate list of containers to create
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
all_test_containers: >-
|
||||||
|
{{
|
||||||
|
[test_container_unprefixed_name]
|
||||||
|
+ (
|
||||||
|
[test_container_prefixed_prefix + '-']
|
||||||
|
| product(range(test_container_prefixed_num) | map('string'))
|
||||||
|
| map('join', '')
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
|
||||||
|
- name: Run checks
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: Create all containers
|
||||||
|
openstack.cloud.object_container:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ item }}"
|
||||||
|
read_ACL: ".r:*,.rlistings"
|
||||||
|
loop: "{{ all_test_containers }}"
|
||||||
|
|
||||||
|
- name: Create an object in all containers
|
||||||
|
openstack.cloud.object:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
container: "{{ item }}"
|
||||||
|
name: hello.txt
|
||||||
|
data: "{{ test_object_data }}"
|
||||||
|
loop: "{{ all_test_containers }}"
|
||||||
|
|
||||||
|
- name: Fetch single containers by name
|
||||||
|
openstack.cloud.object_containers_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ item }}"
|
||||||
|
register: single_containers
|
||||||
|
loop: "{{ all_test_containers }}"
|
||||||
|
|
||||||
|
- name: Check that all fields are returned for single containers
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- (item.containers | length) == 1
|
||||||
|
- item.containers[0].name == item.item
|
||||||
|
- item.containers[0].bytes == (test_object_data | length)
|
||||||
|
- item.containers[0].read_ACL == ".r:*,.rlistings"
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- (expected_fields_single | difference(item.containers[0].keys()) | length) == 0
|
||||||
|
quiet: true
|
||||||
|
loop: "{{ single_containers.results }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.item }}"
|
||||||
|
|
||||||
|
- name: Fetch multiple containers by prefix
|
||||||
|
openstack.cloud.object_containers_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
prefix: "{{ test_container_prefixed_prefix }}"
|
||||||
|
register: multiple_containers
|
||||||
|
|
||||||
|
- name: Check that the correct number of prefixed containers were returned
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- (multiple_containers.containers | length) == test_container_prefixed_num
|
||||||
|
fail_msg: >-
|
||||||
|
Incorrect number of containers found
|
||||||
|
(found {{ multiple_containers.containers | length }},
|
||||||
|
expected {{ test_container_prefixed_num }})
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
- name: Check that all prefixed containers exist
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- >-
|
||||||
|
(test_container_prefixed_prefix + '-' + (item | string))
|
||||||
|
in (multiple_containers.containers | map(attribute='name'))
|
||||||
|
fail_msg: "Container not found: {{ test_container_prefixed_prefix + '-' + (item | string) }}"
|
||||||
|
quiet: true
|
||||||
|
loop: "{{ range(test_container_prefixed_num) | list }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ test_container_prefixed_prefix + '-' + (item | string) }}"
|
||||||
|
|
||||||
|
- name: Check that the expected fields are returned for all prefixed containers
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- item.name.startswith(test_container_prefixed_prefix)
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- (expected_fields_multiple | difference(item.keys()) | length) == 0
|
||||||
|
quiet: true
|
||||||
|
loop: "{{ multiple_containers.containers | sort(attribute='name') }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
||||||
|
|
||||||
|
- name: Fetch all containers
|
||||||
|
openstack.cloud.object_containers_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
register: all_containers
|
||||||
|
|
||||||
|
- name: Check that all expected containers were returned
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- item in (all_containers.containers | map(attribute='name'))
|
||||||
|
fail_msg: "Container not found: {{ item }}"
|
||||||
|
quiet: true
|
||||||
|
loop: "{{ all_test_containers }}"
|
||||||
|
|
||||||
|
- name: Check that the expected fields are returned for all containers
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- (expected_fields_multiple | difference(item.keys()) | length) == 0
|
||||||
|
quiet: true
|
||||||
|
loop: "{{ all_containers.containers | selectattr('name', 'in', all_test_containers) }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
||||||
|
|
||||||
|
always:
|
||||||
|
|
||||||
|
- name: Delete all containers
|
||||||
|
openstack.cloud.object_container:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
delete_with_all_objects: true
|
||||||
|
loop: "{{ all_test_containers }}"
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
binding_profile:
|
|
||||||
"pci_slot": "0000:03:11.1"
|
|
||||||
"physical_network": "provider"
|
|
||||||
expected_fields:
|
expected_fields:
|
||||||
- allowed_address_pairs
|
- allowed_address_pairs
|
||||||
- binding_host_id
|
- binding_host_id
|
||||||
|
|||||||
@@ -256,27 +256,6 @@
|
|||||||
state: absent
|
state: absent
|
||||||
name: ansible_security_group
|
name: ansible_security_group
|
||||||
|
|
||||||
- name: Create port (with binding profile)
|
|
||||||
openstack.cloud.port:
|
|
||||||
cloud: "{{ cloud }}"
|
|
||||||
state: present
|
|
||||||
name: "{{ port_name }}"
|
|
||||||
network: "{{ network_name }}"
|
|
||||||
binding_profile: "{{ binding_profile }}"
|
|
||||||
register: port
|
|
||||||
|
|
||||||
- name: Assert binding_profile exists in created port
|
|
||||||
assert:
|
|
||||||
that: "port.port['binding_profile']"
|
|
||||||
|
|
||||||
- debug: var=port
|
|
||||||
|
|
||||||
- name: Delete port (with binding profile)
|
|
||||||
openstack.cloud.port:
|
|
||||||
cloud: "{{ cloud }}"
|
|
||||||
state: absent
|
|
||||||
name: "{{ port_name }}"
|
|
||||||
|
|
||||||
- name: Delete subnet
|
- name: Delete subnet
|
||||||
openstack.cloud.subnet:
|
openstack.cloud.subnet:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
|
|||||||
10
ci/roles/port_forwarding/defaults/main.yml
Normal file
10
ci/roles/port_forwarding/defaults/main.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
expected_fields:
|
||||||
|
- description
|
||||||
|
- external_port
|
||||||
|
- floatingip_id
|
||||||
|
- id
|
||||||
|
- internal_ip_address
|
||||||
|
- internal_port
|
||||||
|
- internal_port_id
|
||||||
|
- name
|
||||||
|
- protocol
|
||||||
272
ci/roles/port_forwarding/tasks/main.yml
Normal file
272
ci/roles/port_forwarding/tasks/main.yml
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
---
|
||||||
|
- name: Create test network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: test_internal_network
|
||||||
|
|
||||||
|
- name: Create test subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: test_internal_subnet
|
||||||
|
network_name: test_internal_network
|
||||||
|
cidr: 192.168.100.0/24
|
||||||
|
gateway_ip: 192.168.100.1
|
||||||
|
|
||||||
|
- name: Create test port
|
||||||
|
openstack.cloud.port:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: test_internal_port
|
||||||
|
network: test_internal_network
|
||||||
|
fixed_ips:
|
||||||
|
- ip_address: 192.168.100.10
|
||||||
|
register: test_internal_port
|
||||||
|
|
||||||
|
- name: Create test external network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: test_external_network
|
||||||
|
external: true
|
||||||
|
|
||||||
|
- name: Create test external subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
network_name: test_external_network
|
||||||
|
name: test_external_subnet
|
||||||
|
cidr: 10.6.6.0/24
|
||||||
|
|
||||||
|
- name: Create router
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: test_router
|
||||||
|
network: test_external_network
|
||||||
|
external_fixed_ips:
|
||||||
|
- subnet: test_external_subnet
|
||||||
|
interfaces:
|
||||||
|
- test_internal_subnet
|
||||||
|
|
||||||
|
- name: Create test floating IP
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
network: test_external_network
|
||||||
|
register: test_floating_ip
|
||||||
|
|
||||||
|
- name: Test - Create port forwarding rule
|
||||||
|
openstack.cloud.port_forwarding:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
network_port: test_internal_port
|
||||||
|
internal_ip: 192.168.100.10
|
||||||
|
external_protocol_port: 8080
|
||||||
|
internal_protocol_port: 80
|
||||||
|
protocol: tcp
|
||||||
|
register: pf_create
|
||||||
|
|
||||||
|
- name: Get port forwarding info
|
||||||
|
openstack.cloud.port_forwarding_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
port_forwarding_id: "{{ pf_create.port_forwarding.id }}"
|
||||||
|
register: pf_create_info
|
||||||
|
|
||||||
|
- name: Verify - Port forwarding created successfully
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pf_create is changed
|
||||||
|
- pf_create.port_forwarding is defined
|
||||||
|
- pf_create.port_forwarding.external_port == 8080
|
||||||
|
- pf_create.port_forwarding.internal_port == 80
|
||||||
|
- pf_create.port_forwarding.protocol == "tcp"
|
||||||
|
- pf_create_info.port_forwardings | length == 1
|
||||||
|
- pf_create_info.port_forwardings.0.id == pf_create.port_forwarding.id
|
||||||
|
|
||||||
|
- name: Test - Create port forwarding rule again (idempotency)
|
||||||
|
openstack.cloud.port_forwarding:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
network_port: test_internal_port
|
||||||
|
internal_ip: 192.168.100.10
|
||||||
|
external_protocol_port: 8080
|
||||||
|
internal_protocol_port: 80
|
||||||
|
protocol: tcp
|
||||||
|
register: pf_idempotent
|
||||||
|
|
||||||
|
- name: Verify - No changes
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pf_idempotent is not changed
|
||||||
|
|
||||||
|
- name: Test - Update port forwarding internal port
|
||||||
|
openstack.cloud.port_forwarding:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
network_port: test_internal_port
|
||||||
|
internal_ip: 192.168.100.10
|
||||||
|
external_protocol_port: 8080
|
||||||
|
internal_protocol_port: 8080 # Changed from 80 to 8080
|
||||||
|
protocol: tcp
|
||||||
|
register: pf_update
|
||||||
|
|
||||||
|
- name: Get port forwarding info
|
||||||
|
openstack.cloud.port_forwarding_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
port_forwarding_id: "{{ pf_update.port_forwarding.id }}"
|
||||||
|
register: pf_update_info
|
||||||
|
|
||||||
|
- name: Verify - Port forwarding updated successfully
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pf_update is changed
|
||||||
|
- pf_update.port_forwarding.internal_port == 8080
|
||||||
|
- pf_update_info.port_forwardings | length == 1
|
||||||
|
- pf_update_info.port_forwardings.0.id == pf_update.port_forwarding.id
|
||||||
|
|
||||||
|
- name: Test - Update with same values (idempotency)
|
||||||
|
openstack.cloud.port_forwarding:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
network_port: test_internal_port
|
||||||
|
internal_ip: 192.168.100.10
|
||||||
|
external_protocol_port: 8080
|
||||||
|
internal_protocol_port: 8080
|
||||||
|
protocol: tcp
|
||||||
|
register: pf_update_idempotent
|
||||||
|
|
||||||
|
- name: Verify - No changes
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pf_update_idempotent is not changed
|
||||||
|
|
||||||
|
- name: Test - Change just one attribute
|
||||||
|
openstack.cloud.port_forwarding:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
port_forwarding_id: "{{ pf_create.port_forwarding.id }}"
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
internal_protocol_port: 9090 # Different internal port
|
||||||
|
register: pf_update_by_id
|
||||||
|
|
||||||
|
- name: Verify - Port forwarding updated by ID
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pf_update_by_id.changed == true
|
||||||
|
- pf_update_by_id.port_forwarding.id == pf_create.port_forwarding.id
|
||||||
|
- pf_update_by_id.port_forwarding.internal_port_id == test_internal_port.port.id
|
||||||
|
- pf_update_by_id.port_forwarding.internal_ip_address == "192.168.100.10"
|
||||||
|
- pf_update_by_id.port_forwarding.external_port == 8080
|
||||||
|
- pf_update_by_id.port_forwarding.internal_port == 9090
|
||||||
|
|
||||||
|
- name: Test - Create port forwarding without specifying internal IP
|
||||||
|
openstack.cloud.port_forwarding:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
network_port: test_internal_port
|
||||||
|
external_protocol_port: 2222
|
||||||
|
internal_protocol_port: 22
|
||||||
|
protocol: tcp
|
||||||
|
register: pf_auto_internal_ip
|
||||||
|
|
||||||
|
- name: Verify - Port forwarding created with auto internal IP
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pf_auto_internal_ip.changed == true
|
||||||
|
- pf_auto_internal_ip.port_forwarding.internal_ip_address == "192.168.100.10"
|
||||||
|
|
||||||
|
- name: Test - Delete port forwarding
|
||||||
|
openstack.cloud.port_forwarding:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
network_port: test_internal_port
|
||||||
|
external_protocol_port: 8080
|
||||||
|
internal_protocol_port: 9090
|
||||||
|
protocol: tcp
|
||||||
|
register: pf_delete
|
||||||
|
|
||||||
|
- name: Verify - Port forwarding deleted successfully
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pf_delete.changed == true
|
||||||
|
|
||||||
|
- name: Test - Delete port forwarding by ID
|
||||||
|
openstack.cloud.port_forwarding:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
port_forwarding_id: "{{ pf_auto_internal_ip.port_forwarding.id }}"
|
||||||
|
register: pf_delete_by_id
|
||||||
|
|
||||||
|
- name: Verify - Port forwarding deleted by ID
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pf_delete_by_id.changed == true
|
||||||
|
|
||||||
|
- name: Test - Delete already deleted port forwarding (idempotency)
|
||||||
|
openstack.cloud.port_forwarding:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
port_forwarding_id: "{{ pf_auto_internal_ip.port_forwarding.id }}"
|
||||||
|
floating_ip: "{{ test_floating_ip.floating_ip.id }}"
|
||||||
|
register: pf_delete_idempotent
|
||||||
|
|
||||||
|
- name: Verify - No errors on deleting non-existent rule (idempotency)
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- pf_delete_idempotent is not changed
|
||||||
|
- pf_delete_idempotent is not failed
|
||||||
|
|
||||||
|
- name: Clean up - Delete test floating IP
|
||||||
|
openstack.cloud.floating_ip:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
floating_ip_address: "{{ test_floating_ip.floating_ip.floating_ip_address }}"
|
||||||
|
network: test_external_network
|
||||||
|
purge: true
|
||||||
|
|
||||||
|
- name: Clean up - Delete router
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: test_router
|
||||||
|
|
||||||
|
- name: Clean up - Delete test external subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: test_external_subnet
|
||||||
|
|
||||||
|
- name: Clean up - Delete test external network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: test_external_network
|
||||||
|
|
||||||
|
- name: Clean up - Delete test port
|
||||||
|
openstack.cloud.port:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: test_internal_port
|
||||||
|
|
||||||
|
- name: Clean up - Delete test subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: test_internal_subnet
|
||||||
|
|
||||||
|
- name: Clean up - Delete test network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: test_internal_network
|
||||||
@@ -174,6 +174,38 @@
|
|||||||
that:
|
that:
|
||||||
- project.project.is_enabled == True
|
- project.project.is_enabled == True
|
||||||
|
|
||||||
|
- name: Update project to add new extra_specs
|
||||||
|
openstack.cloud.project:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_project
|
||||||
|
extra_specs:
|
||||||
|
is_enabled: True
|
||||||
|
another_tag: True
|
||||||
|
register: project
|
||||||
|
|
||||||
|
- name: Assert return values of project module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- project.project.is_enabled == True
|
||||||
|
- project.project.another_tag == True
|
||||||
|
|
||||||
|
- name: Update project to change existing extra_specs
|
||||||
|
openstack.cloud.project:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_project
|
||||||
|
extra_specs:
|
||||||
|
is_enabled: True
|
||||||
|
another_tag: False
|
||||||
|
register: project
|
||||||
|
|
||||||
|
- name: Assert return values of project module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- project.project.is_enabled == True
|
||||||
|
- project.project.another_tag == False
|
||||||
|
|
||||||
- name: Delete project
|
- name: Delete project
|
||||||
openstack.cloud.project:
|
openstack.cloud.project:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
|
|||||||
@@ -28,3 +28,9 @@ test_compute_quota:
|
|||||||
ram: 5
|
ram: 5
|
||||||
server_group_members: 5
|
server_group_members: 5
|
||||||
server_groups: 5
|
server_groups: 5
|
||||||
|
test_load_balancer_quota:
|
||||||
|
load_balancers: 5
|
||||||
|
health_monitors: 5
|
||||||
|
listeners: 5
|
||||||
|
pools: 5
|
||||||
|
members: 5
|
||||||
|
|||||||
158
ci/roles/quota/tasks/loadbalancer.yml
Normal file
158
ci/roles/quota/tasks/loadbalancer.yml
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
---
|
||||||
|
- module_defaults:
|
||||||
|
group/openstack.cloud.openstack:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ test_project }}"
|
||||||
|
# Backward compatibility with Ansible 2.9
|
||||||
|
openstack.cloud.project:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ test_project }}"
|
||||||
|
openstack.cloud.quota:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ test_project }}"
|
||||||
|
block:
|
||||||
|
- name: Create test project
|
||||||
|
openstack.cloud.project:
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Clear quotas before tests
|
||||||
|
openstack.cloud.quota:
|
||||||
|
state: absent
|
||||||
|
register: default_quotas
|
||||||
|
|
||||||
|
- name: Set network quota
|
||||||
|
openstack.cloud.quota: "{{ test_network_quota }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that: quotas is changed
|
||||||
|
|
||||||
|
- name: Assert field values
|
||||||
|
assert:
|
||||||
|
that: quotas.quotas.network[item.key] == item.value
|
||||||
|
loop: "{{ test_network_quota | dict2items }}"
|
||||||
|
|
||||||
|
- name: Set network quota again
|
||||||
|
openstack.cloud.quota: "{{ test_network_quota }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert not changed
|
||||||
|
assert:
|
||||||
|
that: quotas is not changed
|
||||||
|
|
||||||
|
- name: Set volume quotas
|
||||||
|
openstack.cloud.quota: "{{ test_volume_quota }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that: quotas is changed
|
||||||
|
|
||||||
|
- name: Assert field values
|
||||||
|
assert:
|
||||||
|
that: quotas.quotas.volume[item.key] == item.value
|
||||||
|
loop: "{{ test_volume_quota | dict2items }}"
|
||||||
|
|
||||||
|
- name: Set volume quotas again
|
||||||
|
openstack.cloud.quota: "{{ test_volume_quota }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert not changed
|
||||||
|
assert:
|
||||||
|
that: quotas is not changed
|
||||||
|
|
||||||
|
- name: Set compute quotas
|
||||||
|
openstack.cloud.quota: "{{ test_compute_quota }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that: quotas is changed
|
||||||
|
|
||||||
|
- name: Assert field values
|
||||||
|
assert:
|
||||||
|
that: quotas.quotas.compute[item.key] == item.value
|
||||||
|
loop: "{{ test_compute_quota | dict2items }}"
|
||||||
|
|
||||||
|
- name: Set compute quotas again
|
||||||
|
openstack.cloud.quota: "{{ test_compute_quota }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Set load_balancer quotas
|
||||||
|
openstack.cloud.quota: "{{ test_load_balancer_quota }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that: quotas is changed
|
||||||
|
|
||||||
|
- name: Assert field values
|
||||||
|
assert:
|
||||||
|
that: quotas.quotas.load_balancer[item.key] == item.value
|
||||||
|
loop: "{{ test_load_balancer_quota | dict2items }}"
|
||||||
|
|
||||||
|
- name: Set load_balancer quotas again
|
||||||
|
openstack.cloud.quota: "{{ test_load_balancer_quota }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert not changed
|
||||||
|
assert:
|
||||||
|
that: quotas is not changed
|
||||||
|
|
||||||
|
- name: Unset all quotas
|
||||||
|
openstack.cloud.quota:
|
||||||
|
state: absent
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert defaults restore
|
||||||
|
assert:
|
||||||
|
that: quotas.quotas == default_quotas.quotas
|
||||||
|
|
||||||
|
- name: Set all quotas at once
|
||||||
|
openstack.cloud.quota:
|
||||||
|
"{{ [test_network_quota, test_volume_quota, test_compute_quota, test_load_balancer_quota] | combine }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that: quotas is changed
|
||||||
|
|
||||||
|
- name: Assert volume values
|
||||||
|
assert:
|
||||||
|
that: quotas.quotas.volume[item.key] == item.value
|
||||||
|
loop: "{{ test_volume_quota | dict2items }}"
|
||||||
|
|
||||||
|
- name: Assert network values
|
||||||
|
assert:
|
||||||
|
that: quotas.quotas.network[item.key] == item.value
|
||||||
|
loop: "{{ test_network_quota | dict2items }}"
|
||||||
|
|
||||||
|
- name: Assert compute values
|
||||||
|
assert:
|
||||||
|
that: quotas.quotas.compute[item.key] == item.value
|
||||||
|
loop: "{{ test_compute_quota | dict2items }}"
|
||||||
|
|
||||||
|
- name: Assert load_balancer values
|
||||||
|
assert:
|
||||||
|
that: quotas.quotas.load_balancer[item.key] == item.value
|
||||||
|
loop: "{{ test_load_balancer_quota | dict2items }}"
|
||||||
|
|
||||||
|
- name: Set all quotas at once again
|
||||||
|
openstack.cloud.quota:
|
||||||
|
"{{ [test_network_quota, test_volume_quota, test_compute_quota, test_load_balancer_quota] | combine }}"
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Assert not changed
|
||||||
|
assert:
|
||||||
|
that: quotas is not changed
|
||||||
|
|
||||||
|
- name: Unset all quotas
|
||||||
|
openstack.cloud.quota:
|
||||||
|
state: absent
|
||||||
|
register: quotas
|
||||||
|
|
||||||
|
- name: Delete test project
|
||||||
|
openstack.cloud.project:
|
||||||
|
state: absent
|
||||||
|
|
||||||
@@ -129,3 +129,8 @@
|
|||||||
- name: Delete test project
|
- name: Delete test project
|
||||||
openstack.cloud.project:
|
openstack.cloud.project:
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
- import_tasks: loadbalancer.yml
|
||||||
|
tags:
|
||||||
|
- loadbalancer
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,15 @@
|
|||||||
email: test@example.net
|
email: test@example.net
|
||||||
register: dns_zone
|
register: dns_zone
|
||||||
|
|
||||||
|
- name: Ensure recordset not present
|
||||||
|
openstack.cloud.recordset:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
zone: "{{ dns_zone.zone.name }}"
|
||||||
|
name: "{{ recordset_name }}"
|
||||||
|
recordset_type: "a"
|
||||||
|
records: "{{ records }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Create a recordset
|
- name: Create a recordset
|
||||||
openstack.cloud.recordset:
|
openstack.cloud.recordset:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -22,11 +31,13 @@
|
|||||||
recordset_type: "a"
|
recordset_type: "a"
|
||||||
records: "{{ records }}"
|
records: "{{ records }}"
|
||||||
register: recordset
|
register: recordset
|
||||||
|
until: '"PENDING" not in recordset["recordset"].status'
|
||||||
|
retries: 10
|
||||||
|
delay: 5
|
||||||
|
|
||||||
- name: Verify recordset info
|
- name: Verify recordset info
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- recordset is changed
|
|
||||||
- recordset["recordset"].name == recordset_name
|
- recordset["recordset"].name == recordset_name
|
||||||
- recordset["recordset"].zone_name == dns_zone.zone.name
|
- recordset["recordset"].zone_name == dns_zone.zone.name
|
||||||
- recordset["recordset"].records | list | sort == records | list | sort
|
- recordset["recordset"].records | list | sort == records | list | sort
|
||||||
|
|||||||
@@ -45,12 +45,6 @@
|
|||||||
state: absent
|
state: absent
|
||||||
user: admin
|
user: admin
|
||||||
|
|
||||||
- name: Delete project
|
|
||||||
openstack.cloud.project:
|
|
||||||
cloud: "{{ cloud }}"
|
|
||||||
state: absent
|
|
||||||
name: ansible_project
|
|
||||||
|
|
||||||
- name: Create domain
|
- name: Create domain
|
||||||
openstack.cloud.identity_domain:
|
openstack.cloud.identity_domain:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -78,6 +72,7 @@
|
|||||||
state: present
|
state: present
|
||||||
name: ansible_user
|
name: ansible_user
|
||||||
domain: default
|
domain: default
|
||||||
|
register: specific_user
|
||||||
|
|
||||||
- name: Create user in specific domain
|
- name: Create user in specific domain
|
||||||
openstack.cloud.identity_user:
|
openstack.cloud.identity_user:
|
||||||
@@ -138,6 +133,45 @@
|
|||||||
that:
|
that:
|
||||||
- role_assignment is changed
|
- role_assignment is changed
|
||||||
|
|
||||||
|
- name: Assign role to user in specific domain on default domain project
|
||||||
|
openstack.cloud.role_assignment:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
role: anotherrole
|
||||||
|
user: "{{ specific_user.user.id }}"
|
||||||
|
domain: default
|
||||||
|
project: ansible_project
|
||||||
|
register: role_assignment
|
||||||
|
|
||||||
|
- name: Assert role assignment
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- role_assignment is changed
|
||||||
|
|
||||||
|
- name: Revoke role to user in specific domain
|
||||||
|
openstack.cloud.role_assignment:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
role: anotherrole
|
||||||
|
user: "{{ specific_user.user.id }}"
|
||||||
|
domain: default
|
||||||
|
project: ansible_project
|
||||||
|
state: absent
|
||||||
|
register: role_assignment
|
||||||
|
|
||||||
|
- name: Assert role assignment revoked
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- role_assignment is changed
|
||||||
|
|
||||||
|
- name: Assign role to user in specific domain on default domain project
|
||||||
|
openstack.cloud.role_assignment:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
role: anotherrole
|
||||||
|
user: ansible_user
|
||||||
|
user_domain: "{{ specific_user.user.domain_id }}"
|
||||||
|
project: ansible_project
|
||||||
|
project_domain: default
|
||||||
|
register: role_assignment
|
||||||
|
|
||||||
- name: Delete group in default domain
|
- name: Delete group in default domain
|
||||||
openstack.cloud.identity_group:
|
openstack.cloud.identity_group:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -171,3 +205,10 @@
|
|||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: absent
|
state: absent
|
||||||
name: ansible_domain
|
name: ansible_domain
|
||||||
|
|
||||||
|
- name: Delete project
|
||||||
|
openstack.cloud.project:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: ansible_project
|
||||||
|
|
||||||
|
|||||||
@@ -325,6 +325,43 @@
|
|||||||
- ports.ports|rejectattr('device_owner', 'equalto', 'network:router_gateway')|sum(attribute='fixed_ips', start=[])|map(attribute='ip_address')|sort|list ==
|
- ports.ports|rejectattr('device_owner', 'equalto', 'network:router_gateway')|sum(attribute='fixed_ips', start=[])|map(attribute='ip_address')|sort|list ==
|
||||||
['10.7.7.1']
|
['10.7.7.1']
|
||||||
|
|
||||||
|
- name: Update router (add tags)
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ router_name }}"
|
||||||
|
tags:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
|
|
||||||
|
- name: Gather routers info
|
||||||
|
openstack.cloud.routers_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ router_name }}"
|
||||||
|
register: info
|
||||||
|
|
||||||
|
- name: Verify tags
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- info.routers.0.name == router_name
|
||||||
|
- info.routers.0.id == router.router.id
|
||||||
|
- "'foo' in info.routers.0.tags"
|
||||||
|
- "'bar' in info.routers.0.tags"
|
||||||
|
|
||||||
|
- name: Update router (add tags) again
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ router_name }}"
|
||||||
|
tags:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
|
register: router
|
||||||
|
|
||||||
|
- name: Assert idempotent module
|
||||||
|
assert:
|
||||||
|
that: router is not changed
|
||||||
|
|
||||||
# Admin operation
|
# Admin operation
|
||||||
- name: Create external network
|
- name: Create external network
|
||||||
openstack.cloud.network:
|
openstack.cloud.network:
|
||||||
@@ -384,7 +421,7 @@
|
|||||||
- shade_subnet1
|
- shade_subnet1
|
||||||
network: "{{ external_network_name }}"
|
network: "{{ external_network_name }}"
|
||||||
external_fixed_ips:
|
external_fixed_ips:
|
||||||
- subnet: shade_subnet5
|
- subnet_id: shade_subnet5
|
||||||
ip: 10.6.6.100
|
ip: 10.6.6.100
|
||||||
|
|
||||||
- name: Gather routers info
|
- name: Gather routers info
|
||||||
@@ -412,7 +449,7 @@
|
|||||||
external_gateway_info:
|
external_gateway_info:
|
||||||
network: "{{ external_network_name }}"
|
network: "{{ external_network_name }}"
|
||||||
external_fixed_ips:
|
external_fixed_ips:
|
||||||
- subnet: shade_subnet5
|
- subnet_id: shade_subnet5
|
||||||
ip: 10.6.6.100
|
ip: 10.6.6.100
|
||||||
- subnet: shade_subnet5
|
- subnet: shade_subnet5
|
||||||
ip: 10.6.6.101
|
ip: 10.6.6.101
|
||||||
@@ -426,7 +463,7 @@
|
|||||||
- shade_subnet1
|
- shade_subnet1
|
||||||
network: "{{ external_network_name }}"
|
network: "{{ external_network_name }}"
|
||||||
external_fixed_ips:
|
external_fixed_ips:
|
||||||
- subnet: shade_subnet5
|
- subnet_id: shade_subnet5
|
||||||
ip: 10.6.6.100
|
ip: 10.6.6.100
|
||||||
- subnet: shade_subnet5
|
- subnet: shade_subnet5
|
||||||
ip: 10.6.6.101
|
ip: 10.6.6.101
|
||||||
@@ -461,7 +498,7 @@
|
|||||||
- shade_subnet1
|
- shade_subnet1
|
||||||
network: "{{ external_network_name }}"
|
network: "{{ external_network_name }}"
|
||||||
external_fixed_ips:
|
external_fixed_ips:
|
||||||
- subnet: shade_subnet5
|
- subnet_id: shade_subnet5
|
||||||
ip: 10.6.6.101
|
ip: 10.6.6.101
|
||||||
|
|
||||||
- name: Update router (remove external fixed ips) again
|
- name: Update router (remove external fixed ips) again
|
||||||
@@ -473,7 +510,7 @@
|
|||||||
- shade_subnet1
|
- shade_subnet1
|
||||||
network: "{{ external_network_name }}"
|
network: "{{ external_network_name }}"
|
||||||
external_fixed_ips:
|
external_fixed_ips:
|
||||||
- subnet: shade_subnet5
|
- subnet_id: shade_subnet5
|
||||||
ip: 10.6.6.101
|
ip: 10.6.6.101
|
||||||
register: router
|
register: router
|
||||||
|
|
||||||
@@ -506,7 +543,7 @@
|
|||||||
- shade_subnet1
|
- shade_subnet1
|
||||||
network: "{{ external_network_name }}"
|
network: "{{ external_network_name }}"
|
||||||
external_fixed_ips:
|
external_fixed_ips:
|
||||||
- subnet: shade_subnet5
|
- subnet_id: shade_subnet5
|
||||||
ip: 10.6.6.101
|
ip: 10.6.6.101
|
||||||
|
|
||||||
- name: Gather routers info
|
- name: Gather routers info
|
||||||
@@ -533,7 +570,7 @@
|
|||||||
- shade_subnet1
|
- shade_subnet1
|
||||||
network: "{{ external_network_name }}"
|
network: "{{ external_network_name }}"
|
||||||
external_fixed_ips:
|
external_fixed_ips:
|
||||||
- subnet: shade_subnet5
|
- subnet_id: shade_subnet5
|
||||||
ip: 10.6.6.101
|
ip: 10.6.6.101
|
||||||
register: router
|
register: router
|
||||||
|
|
||||||
@@ -558,6 +595,46 @@
|
|||||||
assert:
|
assert:
|
||||||
that: router is not changed
|
that: router is not changed
|
||||||
|
|
||||||
|
- name: Create router without explicit IP address
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ router_name }}"
|
||||||
|
enable_snat: false
|
||||||
|
interfaces:
|
||||||
|
- shade_subnet1
|
||||||
|
network: "{{ external_network_name }}"
|
||||||
|
external_fixed_ips:
|
||||||
|
- subnet_id: shade_subnet5
|
||||||
|
register: router
|
||||||
|
|
||||||
|
- name: Assert idempotent module
|
||||||
|
assert:
|
||||||
|
that: router is changed
|
||||||
|
|
||||||
|
- name: Update router without explicit IP address
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ router_name }}"
|
||||||
|
enable_snat: false
|
||||||
|
interfaces:
|
||||||
|
- shade_subnet1
|
||||||
|
network: "{{ external_network_name }}"
|
||||||
|
external_fixed_ips:
|
||||||
|
- subnet_id: shade_subnet5
|
||||||
|
register: router
|
||||||
|
|
||||||
|
- name: Assert idempotent module
|
||||||
|
assert:
|
||||||
|
that: router is not changed
|
||||||
|
|
||||||
|
- name: Delete router
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ router_name }}"
|
||||||
|
|
||||||
- name: Create router with simple interface
|
- name: Create router with simple interface
|
||||||
openstack.cloud.router:
|
openstack.cloud.router:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -720,3 +797,5 @@
|
|||||||
name: "{{ external_network_name }}"
|
name: "{{ external_network_name }}"
|
||||||
|
|
||||||
- include_tasks: shared_network.yml
|
- include_tasks: shared_network.yml
|
||||||
|
|
||||||
|
- include_tasks: shared_ext_network.yml
|
||||||
|
|||||||
99
ci/roles/router/tasks/shared_ext_network.yml
Normal file
99
ci/roles/router/tasks/shared_ext_network.yml
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
---
|
||||||
|
# Test the case where we have a shared external network in one project used as
|
||||||
|
# the gateway on a router in a second project.
|
||||||
|
# See https://bugs.launchpad.net/ansible-collections-openstack/+bug/2049658
|
||||||
|
|
||||||
|
- name: Create the first project
|
||||||
|
openstack.cloud.project:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "shared_ext_net_test_1"
|
||||||
|
description: "Project that contains the external network to be shared"
|
||||||
|
domain: default
|
||||||
|
is_enabled: True
|
||||||
|
register: project_1
|
||||||
|
|
||||||
|
- name: Create the external network to be shared
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ external_network_name }}"
|
||||||
|
project: "shared_ext_net_test_1"
|
||||||
|
external: true
|
||||||
|
shared: true
|
||||||
|
register: shared_ext_network
|
||||||
|
|
||||||
|
- name: Create subnet on external network
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
network_name: "{{ shared_ext_network.id }}"
|
||||||
|
name: "shared_ext_subnet"
|
||||||
|
project: "shared_ext_net_test_1"
|
||||||
|
cidr: "10.6.6.0/24"
|
||||||
|
register: shared_subnet
|
||||||
|
|
||||||
|
- name: Create the second project
|
||||||
|
openstack.cloud.project:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "shared_ext_net_test_2"
|
||||||
|
description: "Project that contains the subnet to be shared"
|
||||||
|
domain: default
|
||||||
|
is_enabled: True
|
||||||
|
register: project_2
|
||||||
|
|
||||||
|
- name: Create router with gateway on shared external network
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "shared_ext_net_test2_router"
|
||||||
|
project: "shared_ext_net_test_2"
|
||||||
|
network: "{{ external_network_name }}"
|
||||||
|
register: router
|
||||||
|
|
||||||
|
- name: Gather routers info
|
||||||
|
openstack.cloud.routers_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "shared_ext_net_test2_router"
|
||||||
|
register: routers
|
||||||
|
|
||||||
|
- name: Verify routers info
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- routers.routers.0.id == router.router.id
|
||||||
|
- routers.routers.0.external_gateway_info.external_fixed_ips|length == 1
|
||||||
|
|
||||||
|
- name: Delete router
|
||||||
|
openstack.cloud.router:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "shared_ext_net_test2_router"
|
||||||
|
project: "shared_ext_net_test_2"
|
||||||
|
|
||||||
|
- name: Delete subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
network_name: "{{ shared_ext_network.id }}"
|
||||||
|
name: "shared_ext_subnet"
|
||||||
|
project: "shared_ext_net_test_1"
|
||||||
|
|
||||||
|
- name: Delete network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ external_network_name }}"
|
||||||
|
project: "shared_ext_net_test_1"
|
||||||
|
|
||||||
|
- name: Delete project 2
|
||||||
|
openstack.cloud.project:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "shared_ext_net_test_2"
|
||||||
|
|
||||||
|
- name: Delete project 1
|
||||||
|
openstack.cloud.project:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "shared_ext_net_test_1"
|
||||||
@@ -72,4 +72,25 @@
|
|||||||
name: ansible_security_group
|
name: ansible_security_group
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
- name: Create stateless security group
|
||||||
|
openstack.cloud.security_group:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_security_group_stateless
|
||||||
|
stateful: false
|
||||||
|
state: present
|
||||||
|
description: 'Created from Ansible playbook'
|
||||||
|
register: security_group_stateless
|
||||||
|
|
||||||
|
- name: Assert return values of security_group module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- security_group_stateless.security_group.name == 'ansible_security_group_stateless'
|
||||||
|
- security_group_stateless.security_group.stateful == False
|
||||||
|
|
||||||
|
- name: Delete stateless security group
|
||||||
|
openstack.cloud.security_group:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: ansible_security_group_stateless
|
||||||
|
state: absent
|
||||||
|
|
||||||
- include_tasks: rules.yml
|
- include_tasks: rules.yml
|
||||||
|
|||||||
@@ -399,6 +399,9 @@
|
|||||||
- port-id: "{{ port.port.id }}"
|
- port-id: "{{ port.port.id }}"
|
||||||
reuse_ips: false
|
reuse_ips: false
|
||||||
state: present
|
state: present
|
||||||
|
tags:
|
||||||
|
- first
|
||||||
|
- second
|
||||||
wait: true
|
wait: true
|
||||||
register: server
|
register: server
|
||||||
|
|
||||||
@@ -413,6 +416,7 @@
|
|||||||
|selectattr('OS-EXT-IPS:type', 'equalto', 'floating')
|
|selectattr('OS-EXT-IPS:type', 'equalto', 'floating')
|
||||||
|map(attribute='addr')
|
|map(attribute='addr')
|
||||||
|list|length == 0
|
|list|length == 0
|
||||||
|
- server.server.tags == ["first", "second"]
|
||||||
|
|
||||||
- name: Find all floating ips for debugging
|
- name: Find all floating ips for debugging
|
||||||
openstack.cloud.floating_ip_info:
|
openstack.cloud.floating_ip_info:
|
||||||
@@ -454,6 +458,8 @@
|
|||||||
- '{{ server_security_group }}'
|
- '{{ server_security_group }}'
|
||||||
- '{{ server_alt_security_group }}'
|
- '{{ server_alt_security_group }}'
|
||||||
state: present
|
state: present
|
||||||
|
tags:
|
||||||
|
- yellow
|
||||||
wait: true
|
wait: true
|
||||||
register: server_updated
|
register: server_updated
|
||||||
|
|
||||||
@@ -475,6 +481,7 @@
|
|||||||
- server_updated.server.addresses[server_network]|length == 2
|
- server_updated.server.addresses[server_network]|length == 2
|
||||||
- port.port.fixed_ips[0].ip_address in
|
- port.port.fixed_ips[0].ip_address in
|
||||||
server_updated.server.addresses[server_network]|map(attribute='addr')
|
server_updated.server.addresses[server_network]|map(attribute='addr')
|
||||||
|
- server_updated.server.tags == ['yellow']
|
||||||
# TODO: Verify networks once openstacksdk's issue #2010352 has been solved
|
# TODO: Verify networks once openstacksdk's issue #2010352 has been solved
|
||||||
# Ref.: https://storyboard.openstack.org/#!/story/2010352
|
# Ref.: https://storyboard.openstack.org/#!/story/2010352
|
||||||
#- server_updated.server.addresses.public|length > 0
|
#- server_updated.server.addresses.public|length > 0
|
||||||
@@ -509,6 +516,8 @@
|
|||||||
- '{{ server_security_group }}'
|
- '{{ server_security_group }}'
|
||||||
- '{{ server_alt_security_group }}'
|
- '{{ server_alt_security_group }}'
|
||||||
state: present
|
state: present
|
||||||
|
tags:
|
||||||
|
- yellow
|
||||||
wait: true
|
wait: true
|
||||||
register: server_updated_again
|
register: server_updated_again
|
||||||
|
|
||||||
@@ -517,6 +526,7 @@
|
|||||||
that:
|
that:
|
||||||
- server.server.id == server_updated_again.server.id
|
- server.server.id == server_updated_again.server.id
|
||||||
- server_updated_again is not changed
|
- server_updated_again is not changed
|
||||||
|
- server_updated_again.server.tags == ['yellow']
|
||||||
|
|
||||||
# TODO: Drop failure test once openstacksdk's issue #2010352 has been solved
|
# TODO: Drop failure test once openstacksdk's issue #2010352 has been solved
|
||||||
# Ref.: https://storyboard.openstack.org/#!/story/2010352
|
# Ref.: https://storyboard.openstack.org/#!/story/2010352
|
||||||
|
|||||||
@@ -460,19 +460,14 @@
|
|||||||
register: server
|
register: server
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Assert shelve offload server
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ((server is success)
|
|
||||||
or (server is not success
|
|
||||||
and "Cannot 'shelveOffload' instance" in server.msg
|
|
||||||
and "while it is in vm_state shelved_offloaded" in server.msg))
|
|
||||||
|
|
||||||
- name: Get info about server
|
- name: Get info about server
|
||||||
openstack.cloud.server_info:
|
openstack.cloud.server_info:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
server: ansible_server
|
server: ansible_server
|
||||||
register: servers
|
register: servers
|
||||||
|
until: servers.servers.0.task_state == none
|
||||||
|
retries: 30
|
||||||
|
delay: 10
|
||||||
|
|
||||||
- name: Ensure status for server is SHELVED_OFFLOADED
|
- name: Ensure status for server is SHELVED_OFFLOADED
|
||||||
# no change if server has been offloaded automatically after first shelve command
|
# no change if server has been offloaded automatically after first shelve command
|
||||||
@@ -558,7 +553,7 @@
|
|||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- servers.servers.0.status == 'ACTIVE'
|
- servers.servers.0.status == 'ACTIVE'
|
||||||
- server is not changed
|
- server is changed
|
||||||
|
|
||||||
- name: Reboot server (HARD)
|
- name: Reboot server (HARD)
|
||||||
openstack.cloud.server_action:
|
openstack.cloud.server_action:
|
||||||
@@ -578,7 +573,7 @@
|
|||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- servers.servers.0.status == 'ACTIVE'
|
- servers.servers.0.status == 'ACTIVE'
|
||||||
- server is not changed
|
- server is changed
|
||||||
|
|
||||||
- name: Delete server
|
- name: Delete server
|
||||||
openstack.cloud.server:
|
openstack.cloud.server:
|
||||||
|
|||||||
5
ci/roles/share_type/defaults/main.yml
Normal file
5
ci/roles/share_type/defaults/main.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
share_backend_name: GENERIC_BACKEND
|
||||||
|
share_type_name: test_share_type
|
||||||
|
share_type_description: Test share type for CI
|
||||||
|
share_type_alt_description: Changed test share type
|
||||||
130
ci/roles/share_type/tasks/main.yml
Normal file
130
ci/roles/share_type/tasks/main.yml
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
---
|
||||||
|
- name: Create share type
|
||||||
|
openstack.cloud.share_type:
|
||||||
|
name: "{{ share_type_name }}"
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
extra_specs:
|
||||||
|
share_backend_name: "{{ share_backend_name }}"
|
||||||
|
snapshot_support: true
|
||||||
|
create_share_from_snapshot_support: true
|
||||||
|
description: "{{ share_type_description }}"
|
||||||
|
register: the_result
|
||||||
|
|
||||||
|
- name: Check created share type
|
||||||
|
vars:
|
||||||
|
the_share_type: "{{ the_result.share_type }}"
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'id' in the_result.share_type"
|
||||||
|
- the_share_type.description == share_type_description
|
||||||
|
- the_share_type.is_public == True
|
||||||
|
- the_share_type.name == share_type_name
|
||||||
|
- the_share_type.extra_specs['share_backend_name'] == share_backend_name
|
||||||
|
- the_share_type.extra_specs['snapshot_support'] == "True"
|
||||||
|
- the_share_type.extra_specs['create_share_from_snapshot_support'] == "True"
|
||||||
|
success_msg: >-
|
||||||
|
Created share type: {{ the_result.share_type.id }},
|
||||||
|
Name: {{ the_result.share_type.name }},
|
||||||
|
Description: {{ the_result.share_type.description }}
|
||||||
|
|
||||||
|
- name: Test share type info module
|
||||||
|
openstack.cloud.share_type_info:
|
||||||
|
name: "{{ share_type_name }}"
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
register: info_result
|
||||||
|
|
||||||
|
- name: Check share type info result
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- info_result.share_type.id == the_result.share_type.id
|
||||||
|
- info_result.share_type.name == share_type_name
|
||||||
|
- info_result.share_type.description == share_type_description
|
||||||
|
success_msg: "Share type info retrieved successfully"
|
||||||
|
|
||||||
|
- name: Test, check idempotency
|
||||||
|
openstack.cloud.share_type:
|
||||||
|
name: "{{ share_type_name }}"
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
extra_specs:
|
||||||
|
share_backend_name: "{{ share_backend_name }}"
|
||||||
|
snapshot_support: true
|
||||||
|
create_share_from_snapshot_support: true
|
||||||
|
description: "{{ share_type_description }}"
|
||||||
|
is_public: true
|
||||||
|
register: the_result
|
||||||
|
|
||||||
|
- name: Check result.changed is false
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- the_result.changed == false
|
||||||
|
success_msg: "Request with the same details lead to no changes"
|
||||||
|
|
||||||
|
- name: Add extra spec
|
||||||
|
openstack.cloud.share_type:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ share_type_name }}"
|
||||||
|
state: present
|
||||||
|
extra_specs:
|
||||||
|
share_backend_name: "{{ share_backend_name }}"
|
||||||
|
snapshot_support: true
|
||||||
|
create_share_from_snapshot_support: true
|
||||||
|
some_spec: fake_spec
|
||||||
|
description: "{{ share_type_alt_description }}"
|
||||||
|
is_public: true
|
||||||
|
register: the_result
|
||||||
|
|
||||||
|
- name: Check share type extra spec
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'some_spec' in the_result.share_type.extra_specs"
|
||||||
|
- the_result.share_type.extra_specs["some_spec"] == "fake_spec"
|
||||||
|
- the_result.share_type.description == share_type_alt_description
|
||||||
|
success_msg: >-
|
||||||
|
New extra specs: {{ the_result.share_type.extra_specs }}
|
||||||
|
|
||||||
|
- name: Remove extra spec by updating with reduced set
|
||||||
|
openstack.cloud.share_type:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ share_type_name }}"
|
||||||
|
state: present
|
||||||
|
extra_specs:
|
||||||
|
share_backend_name: "{{ share_backend_name }}"
|
||||||
|
snapshot_support: true
|
||||||
|
create_share_from_snapshot_support: true
|
||||||
|
description: "{{ share_type_alt_description }}"
|
||||||
|
is_public: true
|
||||||
|
register: the_result
|
||||||
|
|
||||||
|
- name: Check extra spec was removed
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'some_spec' not in the_result.share_type.extra_specs"
|
||||||
|
success_msg: "Extra spec was successfully removed"
|
||||||
|
|
||||||
|
- name: Delete share type
|
||||||
|
openstack.cloud.share_type:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ share_type_name }}"
|
||||||
|
state: absent
|
||||||
|
register: the_result
|
||||||
|
|
||||||
|
- name: Check deletion was successful
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- the_result.changed == true
|
||||||
|
success_msg: "Share type deleted successfully"
|
||||||
|
|
||||||
|
- name: Test deletion idempotency
|
||||||
|
openstack.cloud.share_type:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ share_type_name }}"
|
||||||
|
state: absent
|
||||||
|
register: the_result
|
||||||
|
|
||||||
|
- name: Check deletion idempotency
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- the_result.changed == false
|
||||||
|
success_msg: "Deletion idempotency works correctly"
|
||||||
@@ -25,3 +25,4 @@ expected_fields:
|
|||||||
- updated_at
|
- updated_at
|
||||||
- use_default_subnet_pool
|
- use_default_subnet_pool
|
||||||
subnet_name: shade_subnet
|
subnet_name: shade_subnet
|
||||||
|
segment_name: example_segment
|
||||||
|
|||||||
@@ -17,10 +17,20 @@
|
|||||||
name: "{{ network_name }}"
|
name: "{{ network_name }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
- name: Create network segment {{ segment_name }}
|
||||||
|
openstack.cloud.network_segment:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ segment_name }}"
|
||||||
|
network: "{{ network_name }}"
|
||||||
|
network_type: "vxlan"
|
||||||
|
segmentation_id: 1000
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Create subnet {{ subnet_name }} on network {{ network_name }}
|
- name: Create subnet {{ subnet_name }} on network {{ network_name }}
|
||||||
openstack.cloud.subnet:
|
openstack.cloud.subnet:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
network_name: "{{ network_name }}"
|
network_name: "{{ network_name }}"
|
||||||
|
network_segment: "{{ segment_name }}"
|
||||||
name: "{{ subnet_name }}"
|
name: "{{ subnet_name }}"
|
||||||
state: present
|
state: present
|
||||||
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
||||||
@@ -31,6 +41,9 @@
|
|||||||
gateway_ip: 192.168.0.1
|
gateway_ip: 192.168.0.1
|
||||||
allocation_pool_start: 192.168.0.2
|
allocation_pool_start: 192.168.0.2
|
||||||
allocation_pool_end: 192.168.0.254
|
allocation_pool_end: 192.168.0.254
|
||||||
|
tags:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
register: subnet
|
register: subnet
|
||||||
|
|
||||||
- name: Assert changed
|
- name: Assert changed
|
||||||
@@ -56,6 +69,9 @@
|
|||||||
gateway_ip: 192.168.0.1
|
gateway_ip: 192.168.0.1
|
||||||
allocation_pool_start: 192.168.0.2
|
allocation_pool_start: 192.168.0.2
|
||||||
allocation_pool_end: 192.168.0.254
|
allocation_pool_end: 192.168.0.254
|
||||||
|
tags:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
register: subnet
|
register: subnet
|
||||||
|
|
||||||
- name: Assert not changed
|
- name: Assert not changed
|
||||||
@@ -80,6 +96,8 @@
|
|||||||
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
||||||
gateway_ip: 192.168.0.1
|
gateway_ip: 192.168.0.1
|
||||||
cidr: 192.168.0.0/24
|
cidr: 192.168.0.0/24
|
||||||
|
tags:
|
||||||
|
- bar
|
||||||
register: subnet
|
register: subnet
|
||||||
|
|
||||||
- name: Verify Subnet info result
|
- name: Verify Subnet info result
|
||||||
@@ -114,6 +132,10 @@
|
|||||||
dns_nameservers:
|
dns_nameservers:
|
||||||
- 8.8.8.7
|
- 8.8.8.7
|
||||||
cidr: 192.168.0.0/24
|
cidr: 192.168.0.0/24
|
||||||
|
tags:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
|
- baz
|
||||||
register: subnet
|
register: subnet
|
||||||
|
|
||||||
- name: Assert changed
|
- name: Assert changed
|
||||||
@@ -142,6 +164,48 @@
|
|||||||
assert:
|
assert:
|
||||||
that: subnet is not changed
|
that: subnet is not changed
|
||||||
|
|
||||||
|
- name: Create subnet {{ subnet_name }} on network {{ network_name }} without gateway IP
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
network_name: "{{ network_name }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: present
|
||||||
|
cidr: 192.168.0.0/24
|
||||||
|
disable_gateway_ip: true
|
||||||
|
register: subnet
|
||||||
|
|
||||||
|
- name: Assert changed
|
||||||
|
assert:
|
||||||
|
that: subnet is changed
|
||||||
|
|
||||||
|
- name: Create subnet {{ subnet_name }} on network {{ network_name }} without gateway IP
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
network_name: "{{ network_name }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: present
|
||||||
|
cidr: 192.168.0.0/24
|
||||||
|
disable_gateway_ip: true
|
||||||
|
register: subnet
|
||||||
|
|
||||||
|
- name: Assert not changed
|
||||||
|
assert:
|
||||||
|
that: subnet is not changed
|
||||||
|
|
||||||
|
- name: Delete subnet {{ subnet_name }} again
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: absent
|
||||||
|
register: subnet
|
||||||
|
|
||||||
|
- name: Delete network segment {{ segment_name }}
|
||||||
|
openstack.cloud.network_segment:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ segment_name }}"
|
||||||
|
network: "{{ network_name }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Delete network {{ network_name }}
|
- name: Delete network {{ network_name }}
|
||||||
openstack.cloud.network:
|
openstack.cloud.network:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
@@ -150,3 +214,6 @@
|
|||||||
|
|
||||||
- name: Subnet Allocation
|
- name: Subnet Allocation
|
||||||
include_tasks: subnet-allocation.yml
|
include_tasks: subnet-allocation.yml
|
||||||
|
|
||||||
|
- name: Subnet Allocations from Subnet Pool
|
||||||
|
include_tasks: subnet-pool.yaml
|
||||||
|
|||||||
@@ -62,6 +62,81 @@
|
|||||||
- subnet_result.subnets[0].allocation_pools.0.start == '192.168.0.2'
|
- subnet_result.subnets[0].allocation_pools.0.start == '192.168.0.2'
|
||||||
- subnet_result.subnets[0].allocation_pools.0.end == '192.168.0.8'
|
- subnet_result.subnets[0].allocation_pools.0.end == '192.168.0.8'
|
||||||
|
|
||||||
|
- name: Delete subnet {{ subnet_name }}
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Create subnet {{ subnet_name }} with multiple allocation pools on network {{ network_name }}
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
network_name: "{{ network_name }}"
|
||||||
|
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: present
|
||||||
|
cidr: 192.168.0.0/24
|
||||||
|
gateway_ip: 192.168.0.1
|
||||||
|
allocation_pools:
|
||||||
|
- start: 192.168.0.2
|
||||||
|
end: 192.168.0.4
|
||||||
|
- start: 192.168.0.10
|
||||||
|
end: 192.168.0.12
|
||||||
|
|
||||||
|
- name: Create subnet {{ subnet_name }} on network {{ network_name }} again
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
network_name: "{{ network_name }}"
|
||||||
|
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: present
|
||||||
|
cidr: 192.168.0.0/24
|
||||||
|
gateway_ip: 192.168.0.1
|
||||||
|
allocation_pools:
|
||||||
|
- start: 192.168.0.2
|
||||||
|
end: 192.168.0.4
|
||||||
|
- start: 192.168.0.10
|
||||||
|
end: 192.168.0.12
|
||||||
|
register: idem2
|
||||||
|
|
||||||
|
- name: Update subnet {{ subnet_name }} allocation pools
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
network_name: "{{ network_name }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: present
|
||||||
|
cidr: 192.168.0.0/24
|
||||||
|
gateway_ip: 192.168.0.1
|
||||||
|
allocation_pools:
|
||||||
|
- start: 192.168.0.2
|
||||||
|
end: 192.168.0.8
|
||||||
|
- start: 192.168.0.10
|
||||||
|
end: 192.168.0.16
|
||||||
|
|
||||||
|
- name: Get Subnet Info
|
||||||
|
openstack.cloud.subnets_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
register: subnet_result
|
||||||
|
|
||||||
|
# TODO(sshnaidm): Uncomment this section when the issue with allocation_pools is fixed
|
||||||
|
# - name: Verify Subnet Allocation Pools Exist
|
||||||
|
# assert:
|
||||||
|
# that:
|
||||||
|
# - idem2 is not changed
|
||||||
|
# - subnet_result.subnets is defined
|
||||||
|
# - subnet_result.subnets | length == 1
|
||||||
|
# - subnet_result.subnets[0].allocation_pools is defined
|
||||||
|
# - subnet_result.subnets[0].allocation_pools | length == 2
|
||||||
|
|
||||||
|
# - name: Verify Subnet Allocation Pools
|
||||||
|
# assert:
|
||||||
|
# that:
|
||||||
|
# - (subnet_result.subnets[0].allocation_pools.0.start == '192.168.0.2' and subnet_result.subnets[0].allocation_pools.0.end == '192.168.0.8') or
|
||||||
|
# (subnet_result.subnets[0].allocation_pools.0.start == '192.168.0.10' and subnet_result.subnets[0].allocation_pools.0.end == '192.168.0.16')
|
||||||
|
# - (subnet_result.subnets[0].allocation_pools.1.start == '192.168.0.2' and subnet_result.subnets[0].allocation_pools.1.end == '192.168.0.8') or
|
||||||
|
# (subnet_result.subnets[0].allocation_pools.1.start == '192.168.0.10' and subnet_result.subnets[0].allocation_pools.1.end == '192.168.0.16')
|
||||||
|
|
||||||
- name: Delete subnet {{ subnet_name }}
|
- name: Delete subnet {{ subnet_name }}
|
||||||
openstack.cloud.subnet:
|
openstack.cloud.subnet:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
|
|||||||
168
ci/roles/subnet/tasks/subnet-pool.yaml
Normal file
168
ci/roles/subnet/tasks/subnet-pool.yaml
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
---
|
||||||
|
# This test cover case when subnet is constructed
|
||||||
|
# with few prefixes and neutron API is required
|
||||||
|
# CIDR parameter to be used together with subnet pool.
|
||||||
|
|
||||||
|
- name: Create network {{ network_name }}
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ network_name }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- 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 }}"
|
||||||
|
is_shared: false
|
||||||
|
address_scope: "{{ address_scope_name }}"
|
||||||
|
prefixes:
|
||||||
|
- 192.168.0.0/24
|
||||||
|
- 192.168.42.0/24
|
||||||
|
register: subnet_pool
|
||||||
|
|
||||||
|
- name: Create subnet {{ subnet_name }} on network {{ network_name }} from subnet pool {{ subnet_pool_name }}
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
network_name: "{{ network_name }}"
|
||||||
|
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: present
|
||||||
|
cidr: 192.168.42.0/24 # we want specific cidr from subnet pool
|
||||||
|
ip_version: 4
|
||||||
|
subnet_pool: "{{ subnet_pool_name }}"
|
||||||
|
gateway_ip: 192.168.42.1
|
||||||
|
allocation_pool_start: 192.168.42.2
|
||||||
|
allocation_pool_end: 192.168.42.4
|
||||||
|
|
||||||
|
- name: Create subnet {{ subnet_name }} on network {{ network_name }} from subnet pool {{ subnet_pool_name }} again
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
network_name: "{{ network_name }}"
|
||||||
|
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: present
|
||||||
|
cidr: 192.168.42.0/24
|
||||||
|
ip_version: 4
|
||||||
|
subnet_pool: "{{ subnet_pool_name }}"
|
||||||
|
gateway_ip: 192.168.42.1
|
||||||
|
allocation_pool_start: 192.168.42.2
|
||||||
|
allocation_pool_end: 192.168.42.4
|
||||||
|
register: idem1
|
||||||
|
|
||||||
|
- name: Get Subnet Info
|
||||||
|
openstack.cloud.subnets_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
register: subnet_result
|
||||||
|
|
||||||
|
- name: Verify Subnet Allocation Pools Exist
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- idem1 is not changed
|
||||||
|
- subnet_result.subnets is defined
|
||||||
|
- subnet_result.subnets | length == 1
|
||||||
|
- subnet_result.subnets[0].allocation_pools is defined
|
||||||
|
- subnet_result.subnets[0].allocation_pools | length == 1
|
||||||
|
|
||||||
|
- name: Verify Subnet Allocation Pools
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- subnet_result.subnets[0].allocation_pools.0.start == '192.168.42.2'
|
||||||
|
- subnet_result.subnets[0].allocation_pools.0.end == '192.168.42.4'
|
||||||
|
|
||||||
|
- name: Delete subnet {{ subnet_name }}
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Create subnet {{ subnet_name }} with multiple allocation pools on network {{ network_name }} from subnet pool {{ subnet_pool_name }}
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
network_name: "{{ network_name }}"
|
||||||
|
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: present
|
||||||
|
cidr: 192.168.42.0/24 # we want specific cidr from subnet pool
|
||||||
|
ip_version: 4
|
||||||
|
subnet_pool: "{{ subnet_pool_name }}"
|
||||||
|
gateway_ip: 192.168.42.1
|
||||||
|
allocation_pools:
|
||||||
|
- start: 192.168.42.2
|
||||||
|
end: 192.168.42.4
|
||||||
|
- start: 192.168.42.6
|
||||||
|
end: 192.168.42.8
|
||||||
|
|
||||||
|
- name: Create subnet {{ subnet_name }} on network {{ network_name }} from subnet pool {{ subnet_pool_name }} again
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
network_name: "{{ network_name }}"
|
||||||
|
enable_dhcp: "{{ enable_subnet_dhcp }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: present
|
||||||
|
cidr: 192.168.42.0/24
|
||||||
|
ip_version: 4
|
||||||
|
subnet_pool: "{{ subnet_pool_name }}"
|
||||||
|
gateway_ip: 192.168.42.1
|
||||||
|
allocation_pools:
|
||||||
|
- start: 192.168.42.2
|
||||||
|
end: 192.168.42.4
|
||||||
|
- start: 192.168.42.6
|
||||||
|
end: 192.168.42.8
|
||||||
|
register: idem2
|
||||||
|
|
||||||
|
- name: Get Subnet Info
|
||||||
|
openstack.cloud.subnets_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
register: subnet_result
|
||||||
|
|
||||||
|
# NOT(gtema) Temporarily disable the check to land other gate fix
|
||||||
|
#- name: Verify Subnet Allocation Pools Exist
|
||||||
|
# assert:
|
||||||
|
# that:
|
||||||
|
# - idem2 is not changed
|
||||||
|
# - subnet_result.subnets is defined
|
||||||
|
# - subnet_result.subnets | length == 1
|
||||||
|
# - subnet_result.subnets[0].allocation_pools is defined
|
||||||
|
# - subnet_result.subnets[0].allocation_pools | length == 2
|
||||||
|
#
|
||||||
|
#- name: Verify Subnet Allocation Pools
|
||||||
|
# assert:
|
||||||
|
# that:
|
||||||
|
# - (subnet_result.subnets[0].allocation_pools.0.start == '192.168.42.2' and subnet_result.subnets[0].allocation_pools.0.end == '192.168.42.4') or
|
||||||
|
# (subnet_result.subnets[0].allocation_pools.0.start == '192.168.42.6' and subnet_result.subnets[0].allocation_pools.0.end == '192.168.42.8')
|
||||||
|
# - (subnet_result.subnets[0].allocation_pools.1.start == '192.168.42.2' and subnet_result.subnets[0].allocation_pools.1.end == '192.168.42.4') or
|
||||||
|
# (subnet_result.subnets[0].allocation_pools.1.start == '192.168.42.6' and subnet_result.subnets[0].allocation_pools.1.end == '192.168.42.8')
|
||||||
|
|
||||||
|
- name: Delete subnet {{ subnet_name }}
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ subnet_name }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
- name: Delete network {{ network_name }}
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ network_name }}"
|
||||||
|
state: absent
|
||||||
1
ci/roles/trait/defaults/main.yml
Normal file
1
ci/roles/trait/defaults/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
trait_name: CUSTOM_ANSIBLE_TRAIT
|
||||||
28
ci/roles/trait/tasks/main.yml
Normal file
28
ci/roles/trait/tasks/main.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
- name: Create trait
|
||||||
|
openstack.cloud.trait:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
id: "{{ trait_name }}"
|
||||||
|
until: result is success
|
||||||
|
retries: 5
|
||||||
|
delay: 20
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert trait
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'name' in result.trait"
|
||||||
|
- "result.trait.id == trait_name"
|
||||||
|
|
||||||
|
- name: Remove trait
|
||||||
|
openstack.cloud.trait:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
id: "{{ trait_name }}"
|
||||||
|
register: result1
|
||||||
|
|
||||||
|
- name: Assert trait removed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'trait' not in result1"
|
||||||
21
ci/roles/trunk/defaults/main.yml
Normal file
21
ci/roles/trunk/defaults/main.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
expected_fields:
|
||||||
|
- created_at
|
||||||
|
- description
|
||||||
|
- id
|
||||||
|
- is_admin_state_up
|
||||||
|
- name
|
||||||
|
- port_id
|
||||||
|
- project_id
|
||||||
|
- revision_number
|
||||||
|
- status
|
||||||
|
- sub_ports
|
||||||
|
- tags
|
||||||
|
- tenant_id
|
||||||
|
- updated_at
|
||||||
|
trunk_name: ansible_trunk
|
||||||
|
parent_network_name: ansible_parent_port_network
|
||||||
|
parent_subnet_name: ansible_parent_port_subnet
|
||||||
|
parent_port_name: ansible_parent_port
|
||||||
|
subport_network_name: ansible_subport_network
|
||||||
|
subport_subnet_name: ansible_subport_subnet
|
||||||
|
subport_name: ansible_subport
|
||||||
185
ci/roles/trunk/tasks/main.yml
Normal file
185
ci/roles/trunk/tasks/main.yml
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
---
|
||||||
|
- name: Create parent network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ parent_network_name }}"
|
||||||
|
external: true
|
||||||
|
register: parent_network
|
||||||
|
|
||||||
|
- name: Create parent subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ parent_subnet_name }}"
|
||||||
|
network_name: "{{ parent_network_name }}"
|
||||||
|
cidr: 10.5.5.0/24
|
||||||
|
register: parent_subnet
|
||||||
|
|
||||||
|
- name: Create parent port
|
||||||
|
openstack.cloud.port:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ parent_port_name }}"
|
||||||
|
network: "{{ parent_network_name }}"
|
||||||
|
fixed_ips:
|
||||||
|
- ip_address: 10.5.5.69
|
||||||
|
register: parent_port
|
||||||
|
|
||||||
|
- name: Create subport network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ subport_network_name }}"
|
||||||
|
external: true
|
||||||
|
register: subport_network
|
||||||
|
|
||||||
|
- name: Create subport subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ subport_subnet_name }}"
|
||||||
|
network_name: "{{ subport_network_name }}"
|
||||||
|
cidr: 10.5.6.0/24
|
||||||
|
register: subport_subnet
|
||||||
|
|
||||||
|
- name: Create subport
|
||||||
|
openstack.cloud.port:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ subport_name }}"
|
||||||
|
network: "{{ subport_network_name }}"
|
||||||
|
fixed_ips:
|
||||||
|
- ip_address: 10.5.6.55
|
||||||
|
register: subport
|
||||||
|
|
||||||
|
- name: Create trunk without subports
|
||||||
|
openstack.cloud.trunk:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ trunk_name }}"
|
||||||
|
port: "{{ parent_port_name }}"
|
||||||
|
register: trunk
|
||||||
|
|
||||||
|
- name: Display return values of trunk module
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: trunk
|
||||||
|
|
||||||
|
- name: Assert return values of trunk module
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(trunk.trunk.keys())|length == 0
|
||||||
|
|
||||||
|
- name: Add subport to trunk by name
|
||||||
|
openstack.cloud.trunk:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ trunk_name }}"
|
||||||
|
port: "{{ parent_port_name }}"
|
||||||
|
sub_ports:
|
||||||
|
- port: "{{ subport_name }}"
|
||||||
|
segmentation_type: vlan
|
||||||
|
segmentation_id: 123
|
||||||
|
register: trunk_subport_by_name
|
||||||
|
|
||||||
|
- name: Assert the subport is part of the trunk
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- trunk_subport_by_name.trunk.sub_ports|length == 1
|
||||||
|
|
||||||
|
- name: Remove subport from trunk
|
||||||
|
openstack.cloud.trunk:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ trunk_name }}"
|
||||||
|
port: "{{ parent_port_name }}"
|
||||||
|
sub_ports: []
|
||||||
|
register: trunk_subport_removed
|
||||||
|
|
||||||
|
- name: Assert no subports are part of the trunk
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- trunk_subport_removed.trunk.sub_ports|length == 0
|
||||||
|
|
||||||
|
- name: Add subport to trunk by ID
|
||||||
|
openstack.cloud.trunk:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ trunk_name }}"
|
||||||
|
port: "{{ parent_port_name }}"
|
||||||
|
sub_ports:
|
||||||
|
- port: "{{ subport.port.id }}"
|
||||||
|
segmentation_type: vlan
|
||||||
|
segmentation_id: 123
|
||||||
|
register: trunk_subport_by_id
|
||||||
|
|
||||||
|
- name: Assert the subport is part of the trunk
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- trunk_subport_by_id.trunk.sub_ports|length == 1
|
||||||
|
|
||||||
|
- name: Delete trunk
|
||||||
|
openstack.cloud.trunk:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ trunk_name }}"
|
||||||
|
|
||||||
|
- name: Create trunk without subports
|
||||||
|
openstack.cloud.trunk:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ trunk_name }}"
|
||||||
|
port: "{{ parent_port_name }}"
|
||||||
|
sub_ports:
|
||||||
|
- port: "{{ subport.port.id }}"
|
||||||
|
segmentation_type: vlan
|
||||||
|
segmentation_id: 123
|
||||||
|
register: trunk_with_subports
|
||||||
|
|
||||||
|
- name: Assert the subport is part of the trunk
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- trunk_with_subports.trunk.sub_ports|length == 1
|
||||||
|
|
||||||
|
- name: Delete trunk
|
||||||
|
openstack.cloud.trunk:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ trunk_name }}"
|
||||||
|
|
||||||
|
- name: Delete subport
|
||||||
|
openstack.cloud.port:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ subport_name }}"
|
||||||
|
|
||||||
|
- name: Delete subport subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ subport_subnet_name }}"
|
||||||
|
|
||||||
|
- name: Delete subport network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ subport_network_name }}"
|
||||||
|
|
||||||
|
- name: Delete parent port
|
||||||
|
openstack.cloud.port:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ parent_port_name }}"
|
||||||
|
|
||||||
|
- name: Delete parent subnet
|
||||||
|
openstack.cloud.subnet:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ parent_subnet_name }}"
|
||||||
|
|
||||||
|
- name: Delete parent network
|
||||||
|
openstack.cloud.network:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ parent_network_name }}"
|
||||||
@@ -12,14 +12,35 @@
|
|||||||
that: item in vol.volume
|
that: item in vol.volume
|
||||||
loop: "{{ expected_fields }}"
|
loop: "{{ expected_fields }}"
|
||||||
|
|
||||||
- name: Create volume from existing volume
|
- assert:
|
||||||
|
that: not vol.volume.is_bootable
|
||||||
|
|
||||||
|
- name: Create bootable volume from existing volume
|
||||||
openstack.cloud.volume:
|
openstack.cloud.volume:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
size: 1
|
size: 1
|
||||||
volume: "{{ vol.volume.id }}"
|
volume: "{{ vol.volume.id }}"
|
||||||
name: ansible_volume1
|
name: ansible_volume1
|
||||||
|
is_bootable: true
|
||||||
description: Test volume
|
description: Test volume
|
||||||
|
register: vol
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: vol.volume.is_bootable
|
||||||
|
|
||||||
|
- name: Make the first volume bootable
|
||||||
|
openstack.cloud.volume:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
size: 1
|
||||||
|
name: ansible_volume
|
||||||
|
is_bootable: true
|
||||||
|
description: Test volume
|
||||||
|
register: vol
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: vol.volume.is_bootable
|
||||||
|
|
||||||
- name: Delete volume
|
- name: Delete volume
|
||||||
openstack.cloud.volume:
|
openstack.cloud.volume:
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
- name: Check info
|
- name: Check info
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- info1.volumes | selectattr("id", "equalto", "{{ info.volumes.0.id }}") | list | length == 1
|
- info1.volumes | selectattr("id", "equalto", info.volumes.0.id) | list | length == 1
|
||||||
- info1.volumes.0.name == 'ansible_test'
|
- info1.volumes.0.name == 'ansible_test'
|
||||||
- info1.volumes.0.status == None
|
- info1.volumes.0.status == None
|
||||||
|
|
||||||
|
|||||||
7
ci/roles/volume_image_metadata/defaults/main.yml
Normal file
7
ci/roles/volume_image_metadata/defaults/main.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
volume_image_metadata_cloud: "{{ cloud | default(omit) }}"
|
||||||
|
volume_image_metadata_volume_name: test-image-metadata-volume
|
||||||
|
volume_image_metadata_size: 1
|
||||||
|
volume_image_metadata:
|
||||||
|
disk_format: qcow2
|
||||||
|
container_format: bare
|
||||||
103
ci/roles/volume_image_metadata/tasks/main.yml
Normal file
103
ci/roles/volume_image_metadata/tasks/main.yml
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
---
|
||||||
|
- name: Get available images
|
||||||
|
openstack.cloud.image_info:
|
||||||
|
cloud: "{{ volume_image_metadata_cloud }}"
|
||||||
|
register: image_info
|
||||||
|
|
||||||
|
- name: Select test image
|
||||||
|
set_fact:
|
||||||
|
volume_image_metadata_image_id: >-
|
||||||
|
{{
|
||||||
|
image_info.images
|
||||||
|
| selectattr('status', 'equalto', 'active')
|
||||||
|
| list
|
||||||
|
| first
|
||||||
|
| default({})
|
||||||
|
}}
|
||||||
|
|
||||||
|
- name: Assert an image is available for testing
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- volume_image_metadata_image_id.id is defined
|
||||||
|
fail_msg: "No active images available in the cloud for volume_image_metadata CI test"
|
||||||
|
|
||||||
|
- name: Create a test volume from image
|
||||||
|
openstack.cloud.volume:
|
||||||
|
cloud: "{{ volume_image_metadata_cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ volume_image_metadata_volume_name }}"
|
||||||
|
image: "{{ volume_image_metadata_image_id.id }}"
|
||||||
|
size: "{{ volume_image_metadata_size }}"
|
||||||
|
register: created_volume
|
||||||
|
|
||||||
|
- name: Assert volume was created
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- created_volume.volume is defined
|
||||||
|
- created_volume.volume.id is defined
|
||||||
|
|
||||||
|
- name: Get volume details
|
||||||
|
openstack.cloud.volume_info:
|
||||||
|
cloud: "{{ volume_image_metadata_cloud }}"
|
||||||
|
name: "{{ volume_image_metadata_volume_name }}"
|
||||||
|
register: volume_info
|
||||||
|
|
||||||
|
- name: Assert volume has image metadata
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- volume_info.volumes[0].volume_image_metadata is defined
|
||||||
|
- volume_info.volumes[0].volume_image_metadata | length > 0
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
# Exercise new module
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
- name: Set volume image metadata
|
||||||
|
openstack.cloud.volume_image_metadata:
|
||||||
|
cloud: "{{ volume_image_metadata_cloud }}"
|
||||||
|
volume: "{{ created_volume.volume.id }}"
|
||||||
|
image_metadata: "{{ volume_image_metadata }}"
|
||||||
|
register: image_meta_result
|
||||||
|
|
||||||
|
- name: Assert image metadata changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- image_meta_result.changed | bool
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
# Idempotency check
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
- name: Set volume image metadata again (idempotent)
|
||||||
|
openstack.cloud.volume_image_metadata:
|
||||||
|
cloud: "{{ volume_image_metadata_cloud }}"
|
||||||
|
volume: "{{ created_volume.volume.id }}"
|
||||||
|
image_metadata: "{{ volume_image_metadata }}"
|
||||||
|
register: image_meta_idempotent
|
||||||
|
|
||||||
|
- name: Assert idempotent behavior
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- not image_meta_idempotent.changed | bool
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
# Verify metadata persisted
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
- name: Re-fetch volume details
|
||||||
|
openstack.cloud.volume_info:
|
||||||
|
cloud: "{{ volume_image_metadata_cloud }}"
|
||||||
|
name: "{{ volume_image_metadata_volume_name }}"
|
||||||
|
register: final_volume_info
|
||||||
|
|
||||||
|
- name: Verify image metadata values
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- final_volume_info.volumes[0].volume_image_metadata.disk_format == "qcow2"
|
||||||
|
- final_volume_info.volumes[0].volume_image_metadata.container_format == "bare"
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
# Cleanup
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
- name: Delete test volume
|
||||||
|
openstack.cloud.volume:
|
||||||
|
cloud: "{{ volume_image_metadata_cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ volume_image_metadata_volume_name }}"
|
||||||
32
ci/roles/volume_manage/defaults/main.yml
Normal file
32
ci/roles/volume_manage/defaults/main.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
test_volume: ansible_test_volume
|
||||||
|
managed_volume: managed_test_volume
|
||||||
|
expected_fields:
|
||||||
|
- attachments
|
||||||
|
- availability_zone
|
||||||
|
- consistency_group_id
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
- description
|
||||||
|
- extended_replication_status
|
||||||
|
- group_id
|
||||||
|
- host
|
||||||
|
- image_id
|
||||||
|
- is_bootable
|
||||||
|
- is_encrypted
|
||||||
|
- is_multiattach
|
||||||
|
- migration_id
|
||||||
|
- migration_status
|
||||||
|
- project_id
|
||||||
|
- replication_driver_data
|
||||||
|
- replication_status
|
||||||
|
- scheduler_hints
|
||||||
|
- size
|
||||||
|
- snapshot_id
|
||||||
|
- source_volume_id
|
||||||
|
- status
|
||||||
|
- user_id
|
||||||
|
- volume_image_metadata
|
||||||
|
- volume_type
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
- metadata
|
||||||
65
ci/roles/volume_manage/tasks/main.yml
Normal file
65
ci/roles/volume_manage/tasks/main.yml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
---
|
||||||
|
- name: Create volume
|
||||||
|
openstack.cloud.volume:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
size: 1
|
||||||
|
name: "{{ test_volume }}"
|
||||||
|
description: Test volume
|
||||||
|
register: vol
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: item in vol.volume
|
||||||
|
loop: "{{ expected_fields }}"
|
||||||
|
|
||||||
|
- name: Unmanage volume
|
||||||
|
openstack.cloud.volume_manage:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ vol.volume.id }}"
|
||||||
|
|
||||||
|
- name: Unmanage volume again
|
||||||
|
openstack.cloud.volume_manage:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ vol.volume.id }}"
|
||||||
|
register: unmanage_idempotency
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- unmanage_idempotency is not changed
|
||||||
|
|
||||||
|
- name: Manage volume
|
||||||
|
openstack.cloud.volume_manage:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
source_name: volume-{{ vol.volume.id }}
|
||||||
|
host: "{{ vol.volume.host }}"
|
||||||
|
name: "{{ managed_volume }}"
|
||||||
|
register: new_vol
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- new_vol.volume.name == managed_volume
|
||||||
|
|
||||||
|
- name: Manage volume again
|
||||||
|
openstack.cloud.volume_manage:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
source_name: volume-{{ vol.volume.id }}
|
||||||
|
host: "{{ vol.volume.host }}"
|
||||||
|
name: "{{ managed_volume }}"
|
||||||
|
register: vol_idempotency
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- vol_idempotency is not changed
|
||||||
|
|
||||||
|
- pause:
|
||||||
|
seconds: 10
|
||||||
|
|
||||||
|
- name: Delete volume
|
||||||
|
openstack.cloud.volume:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ managed_volume }}"
|
||||||
5
ci/roles/volume_retype/defaults/main.yml
Normal file
5
ci/roles/volume_retype/defaults/main.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
volume_retype_cloud: "{{ cloud | default(omit) }}"
|
||||||
|
vtype_src_name: ansible_test_vtype_src
|
||||||
|
vtype_dst_name: ansible_test_vtype_dst
|
||||||
|
volume_name: ansible_test_retype_vol
|
||||||
183
ci/roles/volume_retype/tasks/main.yml
Normal file
183
ci/roles/volume_retype/tasks/main.yml
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
---
|
||||||
|
# ci/roles/volume_retype/tasks/main.yml
|
||||||
|
# Integration tests for openstack.cloud.volume_retype
|
||||||
|
#
|
||||||
|
# Prerequisites (set up in surrounding playbook or defaults):
|
||||||
|
# - cloud: devstack-admin
|
||||||
|
# - A DevStack instance with at least two volume types
|
||||||
|
#
|
||||||
|
# The tests follow the collection's pattern:
|
||||||
|
# 1. Create prerequisites (volume types, volume)
|
||||||
|
# 2. Run module - assert changed
|
||||||
|
# 3. Re-run module - assert NOT changed (idempotency)
|
||||||
|
# 4. Validate returned data
|
||||||
|
# 5. Clean up
|
||||||
|
|
||||||
|
- name: Create source volume type
|
||||||
|
openstack.cloud.volume_type:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ vtype_src_name }}"
|
||||||
|
is_public: true
|
||||||
|
register: vtype_src
|
||||||
|
|
||||||
|
- name: Create destination volume type
|
||||||
|
openstack.cloud.volume_type:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ vtype_dst_name }}"
|
||||||
|
is_public: true
|
||||||
|
register: vtype_dst
|
||||||
|
|
||||||
|
- name: Create a test volume using the source type
|
||||||
|
openstack.cloud.volume:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ volume_name }}"
|
||||||
|
size: 1
|
||||||
|
volume_type: "{{ vtype_src_name }}"
|
||||||
|
wait: true
|
||||||
|
register: test_volume
|
||||||
|
|
||||||
|
- name: Assert volume was created with the source type
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- test_volume.volume.volume_type == vtype_src_name
|
||||||
|
- test_volume.volume.status == 'available'
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 1: Basic retype (migration_policy=never, same-backend assumed)
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
- name: Retype volume to destination type (migration_policy=never)
|
||||||
|
openstack.cloud.volume_retype:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
volume: "{{ volume_name }}"
|
||||||
|
new_type: "{{ vtype_dst_name }}"
|
||||||
|
migration_policy: never
|
||||||
|
wait: true
|
||||||
|
timeout: 120
|
||||||
|
register: retype_result
|
||||||
|
|
||||||
|
- name: Assert retype was applied
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- retype_result is changed
|
||||||
|
- retype_result.volume.volume_type == vtype_dst_name
|
||||||
|
- retype_result.volume.status == 'available'
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 2: Idempotency – re-running with same target type must be no-op
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
- name: Re-run retype with same target type (idempotency check)
|
||||||
|
openstack.cloud.volume_retype:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
volume: "{{ volume_name }}"
|
||||||
|
new_type: "{{ vtype_dst_name }}"
|
||||||
|
migration_policy: never
|
||||||
|
wait: true
|
||||||
|
register: retype_idempotent
|
||||||
|
|
||||||
|
- name: Assert no change on second run
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- retype_idempotent is not changed
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 3: Check mode – must report changed without touching the API
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
- name: Check mode – retype back to source type (should report changed, no action)
|
||||||
|
openstack.cloud.volume_retype:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
volume: "{{ volume_name }}"
|
||||||
|
new_type: "{{ vtype_src_name }}"
|
||||||
|
migration_policy: never
|
||||||
|
check_mode: true
|
||||||
|
register: retype_check_mode
|
||||||
|
|
||||||
|
- name: Assert check mode reports changed but volume type is still the destination
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- retype_check_mode is changed
|
||||||
|
|
||||||
|
- name: Confirm actual volume type did NOT change (check mode was dry-run)
|
||||||
|
openstack.cloud.volume_info:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
name: "{{ volume_name }}"
|
||||||
|
register: volume_info_after_check
|
||||||
|
|
||||||
|
- name: Assert volume type unchanged after check mode run
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- volume_info_after_check.volumes[0].volume_type == vtype_dst_name
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 4: Retype by volume ID (not name)
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
- name: Retype volume using its UUID
|
||||||
|
openstack.cloud.volume_retype:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
volume: "{{ test_volume.volume.id }}"
|
||||||
|
new_type: "{{ vtype_src_name }}"
|
||||||
|
migration_policy: never
|
||||||
|
wait: true
|
||||||
|
register: retype_by_id
|
||||||
|
|
||||||
|
- name: Assert retype by ID succeeded
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- retype_by_id is changed
|
||||||
|
- retype_by_id.volume.volume_type == vtype_src_name
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 5: Error handling – non-existent volume
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
- name: Attempt retype of non-existent volume (expect failure)
|
||||||
|
openstack.cloud.volume_retype:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
volume: this-volume-does-not-exist
|
||||||
|
new_type: "{{ vtype_dst_name }}"
|
||||||
|
register: retype_missing
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Assert that missing volume causes failure
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- retype_missing is failed
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Test 6: Error handling – non-existent volume type
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
- name: Attempt retype to a non-existent volume type (expect failure)
|
||||||
|
openstack.cloud.volume_retype:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
volume: "{{ volume_name }}"
|
||||||
|
new_type: this-type-does-not-exist
|
||||||
|
register: retype_missing_type
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Assert that missing volume type causes failure
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- retype_missing_type is failed
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Clean up
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
- name: Delete test volume
|
||||||
|
openstack.cloud.volume:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ volume_name }}"
|
||||||
|
wait: true
|
||||||
|
|
||||||
|
- name: Delete source volume type
|
||||||
|
openstack.cloud.volume_type:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ vtype_src_name }}"
|
||||||
|
|
||||||
|
- name: Delete destination volume type
|
||||||
|
openstack.cloud.volume_type:
|
||||||
|
cloud: "{{ volume_retype_cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: "{{ vtype_dst_name }}"
|
||||||
9
ci/roles/volume_service/defaults/main.yml
Normal file
9
ci/roles/volume_service/defaults/main.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
expected_fields:
|
||||||
|
- availability_zone
|
||||||
|
- binary
|
||||||
|
- disabled_reason
|
||||||
|
- host
|
||||||
|
- name
|
||||||
|
- state
|
||||||
|
- status
|
||||||
|
- updated_at
|
||||||
23
ci/roles/volume_service/tasks/main.yml
Normal file
23
ci/roles/volume_service/tasks/main.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
- name: Fetch volume services
|
||||||
|
openstack.cloud.volume_service_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
register: volume_services
|
||||||
|
|
||||||
|
- name: Assert return values of volume_service_info module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- volume_services.volume_services | length > 0
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(volume_services.volume_services[0].keys())|length == 0
|
||||||
|
|
||||||
|
- name: Fetch volume services with filters
|
||||||
|
openstack.cloud.volume_service_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
binary: "cinder-volume"
|
||||||
|
register: volume_services
|
||||||
|
|
||||||
|
- name: Assert return values of volume_service_info module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- volume_services.volume_services | length > 0
|
||||||
10
ci/roles/volume_type/defaults/main.yml
Normal file
10
ci/roles/volume_type/defaults/main.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
volume_backend_name: LVM_iSCSI
|
||||||
|
volume_type_name: test_type
|
||||||
|
volume_type_description: Test volume type
|
||||||
|
|
||||||
|
enc_provider_name: nova.volume.encryptors.luks.LuksEncryptor
|
||||||
|
enc_cipher: aes-xts-plain64
|
||||||
|
enc_control_location: front-end
|
||||||
|
enc_control_alt_location: back-end
|
||||||
|
enc_key_size: 256
|
||||||
85
ci/roles/volume_type/tasks/main.yml
Normal file
85
ci/roles/volume_type/tasks/main.yml
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
---
|
||||||
|
- name: Create volume type
|
||||||
|
openstack.cloud.volume_type:
|
||||||
|
name: "{{ volume_type_name }}"
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
extra_specs:
|
||||||
|
volume_backend_name: "{{ volume_backend_name }}"
|
||||||
|
description: "{{ volume_type_description }}"
|
||||||
|
is_public: true
|
||||||
|
register: the_result
|
||||||
|
- name: Check created volume type
|
||||||
|
vars:
|
||||||
|
the_volume: "{{ the_result.volume_type }}"
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'id' in the_result.volume_type"
|
||||||
|
- the_volume.description == volume_type_description
|
||||||
|
- the_volume.is_public == True
|
||||||
|
- the_volume.name == volume_type_name
|
||||||
|
- the_volume.extra_specs['volume_backend_name'] == volume_backend_name
|
||||||
|
success_msg: >-
|
||||||
|
Created volume: {{ the_result.volume_type.id }},
|
||||||
|
Name: {{ the_result.volume_type.name }},
|
||||||
|
Description: {{ the_result.volume_type.description }}
|
||||||
|
|
||||||
|
- name: Test, check idempotency
|
||||||
|
openstack.cloud.volume_type:
|
||||||
|
name: "{{ volume_type_name }}"
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
extra_specs:
|
||||||
|
volume_backend_name: "{{ volume_backend_name }}"
|
||||||
|
description: "{{ volume_type_description }}"
|
||||||
|
is_public: true
|
||||||
|
register: the_result
|
||||||
|
- name: Check result.changed is false
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- the_result.changed == false
|
||||||
|
success_msg: "Request with the same details lead to no changes"
|
||||||
|
|
||||||
|
- name: Add extra spec
|
||||||
|
openstack.cloud.volume_type:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ volume_type_name }}"
|
||||||
|
state: present
|
||||||
|
extra_specs:
|
||||||
|
volume_backend_name: "{{ volume_backend_name }}"
|
||||||
|
some_spec: fake_spec
|
||||||
|
description: "{{ volume_type_description }}"
|
||||||
|
is_public: true
|
||||||
|
register: the_result
|
||||||
|
- name: Check volume type extra spec
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'some_spec' in the_result.volume_type.extra_specs"
|
||||||
|
- the_result.volume_type.extra_specs["some_spec"] == "fake_spec"
|
||||||
|
success_msg: >-
|
||||||
|
New extra specs: {{ the_result.volume_type.extra_specs }}
|
||||||
|
|
||||||
|
# is_public update attempt using openstacksdk result in unexpected attribute
|
||||||
|
# error... TODO: Find solution
|
||||||
|
#
|
||||||
|
# - name: Make volume type private
|
||||||
|
# openstack.cloud.volume_type:
|
||||||
|
# cloud: "{{ cloud }}"
|
||||||
|
# name: "{{ volume_type_alt_name }}"
|
||||||
|
# state: present
|
||||||
|
# extra_specs:
|
||||||
|
# volume_backend_name: "{{ volume_backend_name }}"
|
||||||
|
# # some_other_spec: test
|
||||||
|
# description: Changed 3rd time test volume type
|
||||||
|
# is_public: true
|
||||||
|
# register: the_result
|
||||||
|
|
||||||
|
- name: Volume encryption tests
|
||||||
|
ansible.builtin.include_tasks: volume_encryption.yml
|
||||||
|
|
||||||
|
- name: Delete volume type
|
||||||
|
openstack.cloud.volume_type:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ volume_type_name }}"
|
||||||
|
state: absent
|
||||||
|
register: the_result
|
||||||
67
ci/roles/volume_type/tasks/volume_encryption.yml
Normal file
67
ci/roles/volume_type/tasks/volume_encryption.yml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
---
|
||||||
|
- name: Test, Volume type has no encryption
|
||||||
|
openstack.cloud.volume_type_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ volume_type_name }}"
|
||||||
|
register: the_result
|
||||||
|
- name: Check volume type has no encryption
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- the_result.encryption.id == None
|
||||||
|
success_msg: >-
|
||||||
|
Success: Volume type has no encryption at the moment
|
||||||
|
|
||||||
|
- name: Test, create volume type encryption
|
||||||
|
openstack.cloud.volume_type_encryption:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
volume_type: "{{ volume_type_name }}"
|
||||||
|
state: present
|
||||||
|
encryption_provider: "{{ enc_provider_name }}"
|
||||||
|
encryption_cipher: "{{ enc_cipher }}"
|
||||||
|
encryption_control_location: "{{ enc_control_location }}"
|
||||||
|
encryption_key_size: "{{ enc_key_size }}"
|
||||||
|
register: the_result
|
||||||
|
- name: Check volume type encryption
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- the_result.encryption.cipher == enc_cipher
|
||||||
|
- the_result.encryption.control_location == enc_control_location
|
||||||
|
- the_result.encryption.key_size == enc_key_size
|
||||||
|
- the_result.encryption.provider == enc_provider_name
|
||||||
|
success_msg: >-
|
||||||
|
Success: {{ the_result.encryption.encryption_id }}
|
||||||
|
|
||||||
|
- name: Test, update volume type encryption
|
||||||
|
openstack.cloud.volume_type_encryption:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
volume_type: "{{ volume_type_name }}"
|
||||||
|
state: present
|
||||||
|
encryption_provider: "{{ enc_provider_name }}"
|
||||||
|
encryption_cipher: "{{ enc_cipher }}"
|
||||||
|
encryption_control_location: "{{ enc_control_alt_location }}"
|
||||||
|
encryption_key_size: "{{ enc_key_size }}"
|
||||||
|
register: the_result
|
||||||
|
- name: Check volume type encryption change
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- the_result.encryption.control_location == enc_control_alt_location
|
||||||
|
success_msg: >-
|
||||||
|
New location: {{ the_result.encryption.control_location }}
|
||||||
|
|
||||||
|
- name: Test, delete volume type encryption
|
||||||
|
openstack.cloud.volume_type_encryption:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
volume_type: "{{ volume_type_name }}"
|
||||||
|
state: absent
|
||||||
|
register: the_result
|
||||||
|
- name: Get volume type details
|
||||||
|
openstack.cloud.volume_type_info:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
name: "{{ volume_type_name }}"
|
||||||
|
register: the_result
|
||||||
|
- name: Check volume type has no encryption
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- the_result.encryption.id == None
|
||||||
|
success_msg: >-
|
||||||
|
Success: Volume type has no encryption
|
||||||
@@ -75,10 +75,10 @@ ansible-galaxy collection install --requirements-file ci/requirements.yml
|
|||||||
if [ -z "$PIP_INSTALL" ]; then
|
if [ -z "$PIP_INSTALL" ]; then
|
||||||
tox -ebuild
|
tox -ebuild
|
||||||
ansible-galaxy collection install "$(find build_artifact/ -maxdepth 1 -name 'openstack-cloud-*')" --force
|
ansible-galaxy collection install "$(find build_artifact/ -maxdepth 1 -name 'openstack-cloud-*')" --force
|
||||||
TEST_COLLECTIONS_PATHS=${HOME}/.ansible/collections:$ANSIBLE_COLLECTIONS_PATHS
|
TEST_COLLECTIONS_PATHS=${HOME}/.ansible/collections:$ANSIBLE_COLLECTIONS_PATH
|
||||||
else
|
else
|
||||||
pip freeze | grep ansible-collections-openstack
|
pip freeze | grep ansible-collections-openstack
|
||||||
TEST_COLLECTIONS_PATHS=$VIRTUAL_ENV/share/ansible/collections:$ANSIBLE_COLLECTIONS_PATHS
|
TEST_COLLECTIONS_PATHS=$VIRTUAL_ENV/share/ansible/collections:$ANSIBLE_COLLECTIONS_PATH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We need to source the current tox environment so that Ansible will
|
# We need to source the current tox environment so that Ansible will
|
||||||
@@ -104,9 +104,6 @@ for var in $(env | grep -e '^ANSIBLE_VAR_'); do
|
|||||||
ANSIBLE_VARS+="${ANSIBLE_VAR_NAME}=${ANSIBLE_VAR_VALUE} " # concat variables
|
ANSIBLE_VARS+="${ANSIBLE_VAR_NAME}=${ANSIBLE_VAR_VALUE} " # concat variables
|
||||||
done
|
done
|
||||||
|
|
||||||
# Discover openstacksdk version
|
|
||||||
SDK_VER=$(python -c "import openstack; print(openstack.version.__version__)")
|
|
||||||
|
|
||||||
# Choose integration tests
|
# Choose integration tests
|
||||||
tag_opt=""
|
tag_opt=""
|
||||||
if [ -n "$TAGS" ]; then
|
if [ -n "$TAGS" ]; then
|
||||||
@@ -124,12 +121,17 @@ if [ ! -e /etc/magnum ]; then
|
|||||||
tag_opt+=" --skip-tags coe_cluster,coe_cluster_template"
|
tag_opt+=" --skip-tags coe_cluster,coe_cluster_template"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! systemctl is-enabled devstack@m-api.service 2>&1; then
|
||||||
|
# Skip share_type tasks if Manila is not available
|
||||||
|
tag_opt+=" --skip-tags share_type"
|
||||||
|
fi
|
||||||
|
|
||||||
cd ci/
|
cd ci/
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
ANSIBLE_COLLECTIONS_PATHS=$TEST_COLLECTIONS_PATHS ansible-playbook \
|
ANSIBLE_COLLECTIONS_PATH=$TEST_COLLECTIONS_PATHS ansible-playbook \
|
||||||
-vvv ./run-collection.yml \
|
-vvv ./run-collection.yml \
|
||||||
-e "sdk_version=${SDK_VER} cloud=${CLOUD} cloud_alt=${CLOUD_ALT} ${ANSIBLE_VARS}" \
|
-e "cloud=${CLOUD} cloud_alt=${CLOUD_ALT} ${ANSIBLE_VARS}" \
|
||||||
${tag_opt} 2>&1 | sudo tee /opt/stack/logs/test_output.log
|
${tag_opt} 2>&1 | sudo tee /opt/stack/logs/test_output.log
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
roles:
|
roles:
|
||||||
- { role: address_scope, tags: address_scope }
|
- { role: address_scope, tags: address_scope }
|
||||||
|
- { role: application_credential, tags: application_credential }
|
||||||
- { role: auth, tags: auth }
|
- { role: auth, tags: auth }
|
||||||
- { role: catalog_service, tags: catalog_service }
|
- { role: catalog_service, tags: catalog_service }
|
||||||
- { role: coe_cluster, tags: coe_cluster }
|
- { role: coe_cluster, tags: coe_cluster }
|
||||||
@@ -31,10 +32,15 @@
|
|||||||
- { role: loadbalancer, tags: loadbalancer }
|
- { role: loadbalancer, tags: loadbalancer }
|
||||||
- { role: logging, tags: logging }
|
- { role: logging, tags: logging }
|
||||||
- { role: network, tags: network }
|
- { role: network, tags: network }
|
||||||
|
- { role: network_segment, tags: network_segment }
|
||||||
- { role: neutron_rbac_policy, tags: neutron_rbac_policy }
|
- { role: neutron_rbac_policy, tags: neutron_rbac_policy }
|
||||||
- { role: object, tags: object }
|
- { role: object, tags: object }
|
||||||
- { role: object_container, tags: object_container }
|
- { role: object_container, tags: object_container }
|
||||||
|
- { role: object_containers_info, tags: object_containers_info }
|
||||||
- { role: port, tags: port }
|
- { role: port, tags: port }
|
||||||
|
- { role: port_forwarding, tags: port_forwarding }
|
||||||
|
- { role: trait, tags: trait }
|
||||||
|
- { role: trunk, tags: trunk }
|
||||||
- { role: project, tags: project }
|
- { role: project, tags: project }
|
||||||
- { role: quota, tags: quota }
|
- { role: quota, tags: quota }
|
||||||
- { role: recordset, tags: recordset }
|
- { role: recordset, tags: recordset }
|
||||||
@@ -49,10 +55,16 @@
|
|||||||
- { role: server_group, tags: server_group }
|
- { role: server_group, tags: server_group }
|
||||||
- { role: server_metadata, tags: server_metadata }
|
- { role: server_metadata, tags: server_metadata }
|
||||||
- { role: server_volume, tags: server_volume }
|
- { role: server_volume, tags: server_volume }
|
||||||
|
- { role: share_type, tags: share_type }
|
||||||
- { role: stack, tags: stack }
|
- { role: stack, tags: stack }
|
||||||
- { role: subnet, tags: subnet }
|
- { role: subnet, tags: subnet }
|
||||||
- { role: subnet_pool, tags: subnet_pool }
|
- { role: subnet_pool, tags: subnet_pool }
|
||||||
- { role: volume, tags: volume }
|
- { role: volume, tags: volume }
|
||||||
|
- { role: volume_type, tags: volume_type }
|
||||||
- { role: volume_backup, tags: volume_backup }
|
- { role: volume_backup, tags: volume_backup }
|
||||||
|
- { role: volume_manage, tags: volume_manage }
|
||||||
|
- { role: volume_service, tags: volume_service }
|
||||||
- { role: volume_snapshot, tags: volume_snapshot }
|
- { role: volume_snapshot, tags: volume_snapshot }
|
||||||
- { role: volume_type_access, tags: volume_type_access }
|
- { role: volume_type_access, tags: volume_type_access }
|
||||||
|
- { role: volume_image_metadata, tags: volume_image_metadata }
|
||||||
|
- { role: volume_retype, tags: volume_retype }
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ For hacking on the Ansible OpenStack collection it helps to [prepare a DevStack
|
|||||||
|
|
||||||
## Hosting
|
## Hosting
|
||||||
|
|
||||||
* [Bug tracker][storyboard]
|
* [Bug tracker][bugtracker]
|
||||||
* [Mailing list `openstack-discuss@lists.openstack.org`][openstack-discuss].
|
* [Mailing list `openstack-discuss@lists.openstack.org`][openstack-discuss].
|
||||||
Prefix subjects with `[aoc]` or `[aco]` for faster responses.
|
Prefix subjects with `[aoc]` or `[aco]` for faster responses.
|
||||||
* [Code Hosting][opendev-a-c-o]
|
* [Code Hosting][opendev-a-c-o]
|
||||||
@@ -80,6 +80,8 @@ openstacksdk], please read our [branching docs](branching.md).
|
|||||||
+ be based on (be subclasses of) `OpenStackModule` in
|
+ be based on (be subclasses of) `OpenStackModule` in
|
||||||
`ansible_collections.openstack.cloud.plugins.module_utils.openstack`,
|
`ansible_collections.openstack.cloud.plugins.module_utils.openstack`,
|
||||||
+ should include `extends_documentation_fragment: openstack` in their `DOCUMENTATION` docstring,
|
+ should include `extends_documentation_fragment: openstack` in their `DOCUMENTATION` docstring,
|
||||||
|
+ should contain `version_added` in their `DOCUMENTATION` docstring, where the version is
|
||||||
|
incremented minor version of the collection,
|
||||||
+ be registered in `meta/action_groups.yml` for enabling the variables to be set in
|
+ be registered in `meta/action_groups.yml` for enabling the variables to be set in
|
||||||
[group level][ansible-module-defaults].
|
[group level][ansible-module-defaults].
|
||||||
* Complex functionality, cloud interaction or interoperability code should be moved to [openstacksdk][openstacksdk].
|
* Complex functionality, cloud interaction or interoperability code should be moved to [openstacksdk][openstacksdk].
|
||||||
@@ -136,6 +138,22 @@ openstacksdk], please read our [branching docs](branching.md).
|
|||||||
results with function parameter `filters`. openstacksdk's proxy layer does not provide an equivalent and thus the
|
results with function parameter `filters`. openstacksdk's proxy layer does not provide an equivalent and thus the
|
||||||
use of `search_users()` is perfectly fine.
|
use of `search_users()` is perfectly fine.
|
||||||
|
|
||||||
|
## Changelog fragments
|
||||||
|
|
||||||
|
Every patch that introduces a new feature, a bugfix, or a breaking change must include a changelog fragment.
|
||||||
|
|
||||||
|
When you introduce a new module, the changelog fragment is not required. However, ensure that your module
|
||||||
|
`DOCUMENTATION` contains `version_added` field in it. Please, increment a minor version of the collection for
|
||||||
|
the value of `version_added`. For example, if current `openstack.cloud` collection version is `2.5.0`, you
|
||||||
|
need to use `version_added: 2.6.0`.
|
||||||
|
|
||||||
|
As this is an Ansible collection, we follow the Ansible community standard for changelogs. Please note that **the `reno`
|
||||||
|
tool should not be used** in this repository. Instead, follow the guide linked below to create fragments manually in the
|
||||||
|
`changelogs/fragments/` directory.
|
||||||
|
|
||||||
|
Please refer to the Ansible's [changelog fragments documentation](https://docs.ansible.com/projects/ansible/latest/community/development_process.html#creating-a-changelog-fragment)
|
||||||
|
for more details on the format, valid sections, and how to create a fragment.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
* Modules have to be tested with CI integration tests (if possible).
|
* Modules have to be tested with CI integration tests (if possible).
|
||||||
@@ -188,4 +206,4 @@ Read [Release Guide](releasing.md) on how to publish new releases.
|
|||||||
[openstacksdk-cloud-layer-stays]: https://meetings.opendev.org/irclogs/%23openstack-sdks/%23openstack-sdks.2022-04-27.log.html
|
[openstacksdk-cloud-layer-stays]: https://meetings.opendev.org/irclogs/%23openstack-sdks/%23openstack-sdks.2022-04-27.log.html
|
||||||
[openstacksdk-to-dict]: https://opendev.org/openstack/openstacksdk/src/branch/master/openstack/resource.py
|
[openstacksdk-to-dict]: https://opendev.org/openstack/openstacksdk/src/branch/master/openstack/resource.py
|
||||||
[openstacksdk]: https://opendev.org/openstack/openstacksdk
|
[openstacksdk]: https://opendev.org/openstack/openstacksdk
|
||||||
[storyboard]: https://storyboard.openstack.org/#!/project/openstack/ansible-collections-openstack
|
[bugtracker]: https://bugs.launchpad.net/ansible-collections-openstack
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ list(conn.network.ips())[0].to_dict(computed=False)
|
|||||||
To run the unit tests of the collection, run this in a Bash shell:
|
To run the unit tests of the collection, run this in a Bash shell:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
SDK_VER=$(python -c "import openstack; print(openstack.version.__version__)")
|
ansible-playbook -vvv ci/run-collection.yml -e "cloud=devstack-admin cloud_alt=devstack-alt"
|
||||||
ansible-playbook -vvv ci/run-collection.yml -e "sdk_version=${SDK_VER} cloud=devstack-admin cloud_alt=devstack-alt"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Use `ansible-playbook`'s `--tags` and `--skip-tags` parameters to skip CI tests. For a list of available tags, refer to
|
Use `ansible-playbook`'s `--tags` and `--skip-tags` parameters to skip CI tests. For a list of available tags, refer to
|
||||||
|
|||||||
@@ -2,16 +2,15 @@
|
|||||||
|
|
||||||
## Publishing to Ansible Galaxy
|
## Publishing to Ansible Galaxy
|
||||||
|
|
||||||
1. Create entry in [changelog.yaml](../changelogs/changelog.yaml) with commits since last release.
|
1. Change version in galaxy.yml. Apply Semantic Versioning:
|
||||||
* Modules should be in a separate section `modules`
|
|
||||||
* Bugfixes and minor changes in their sections
|
|
||||||
2. Change version in [galaxy.yml](../galaxy.yml). Apply [Semantic Versioning](https://semver.org/):
|
|
||||||
* Increase major version for breaking changes or modules were removed
|
* Increase major version for breaking changes or modules were removed
|
||||||
* Increase minor version when modules were added
|
* Increase minor version when modules were added
|
||||||
* Increase patch version for bugfixes
|
* Increase patch version for bugfixes
|
||||||
3. Run `antsibull-changelog release` command (run `pip install antsibull` before) to generate [CHANGELOG.rst](
|
2. Run `antsibull-changelog release` command ([antsibull-changelog documentation](
|
||||||
../CHANGELOG.rst) and verify correctness of generated files.
|
https://docs.ansible.com/projects/ansible/latest/dev_guide/developing_collections_changelogs.html))
|
||||||
4. Commit changes to `changelog.yaml` and `galaxy.yml`, submit patch and wait until it has been merged
|
to aggregate changelog fragments into changelog.yaml and generate CHANGELOG.rst.
|
||||||
|
3. Verify correctness of generated files.
|
||||||
|
4. Commit changes to `changelog.yaml` and `galaxy.yml`, submit patch and wait until it has been merged.
|
||||||
5. Tag the release with version as it's described in [OpenStack docs](
|
5. Tag the release with version as it's described in [OpenStack docs](
|
||||||
https://docs.opendev.org/opendev/infra-manual/latest/drivers.html#tagging-a-release):
|
https://docs.opendev.org/opendev/infra-manual/latest/drivers.html#tagging-a-release):
|
||||||
* [Make sure you have a valid GnuPG key pair](
|
* [Make sure you have a valid GnuPG key pair](
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ How to do a review? What to look for when reviewing patches?
|
|||||||
attributes to `name` to be consistent with other modules and with openstacksdk. When refactoring a module, then add
|
attributes to `name` to be consistent with other modules and with openstacksdk. When refactoring a module, then add
|
||||||
the old attribute as an alias to keep backward compatibility.
|
the old attribute as an alias to keep backward compatibility.
|
||||||
* Does the module have integration tests in `ci/roles`?
|
* Does the module have integration tests in `ci/roles`?
|
||||||
|
* Does the patch include a changelog fragment? Every new feature, or important bugfix must include one. Ensure that
|
||||||
|
the fragment follows the Ansible format and that `reno` is not used.
|
||||||
* Is documentation in `DOCUMENTATION`, `RETURN` and `EXAMPLES` up to date?
|
* Is documentation in `DOCUMENTATION`, `RETURN` and `EXAMPLES` up to date?
|
||||||
* Does `RETURN` list all values which are returned by the module?
|
* Does `RETURN` list all values which are returned by the module?
|
||||||
* Are descriptions, keys, names, types etc. in `RETURN` up to date and sorted?
|
* Are descriptions, keys, names, types etc. in `RETURN` up to date and sorted?
|
||||||
@@ -46,7 +48,7 @@ How to do a review? What to look for when reviewing patches?
|
|||||||
Example:
|
Example:
|
||||||
```sh
|
```sh
|
||||||
ansible-playbook -vvv ci/run-collection.yml \
|
ansible-playbook -vvv ci/run-collection.yml \
|
||||||
-e "sdk_version=1.0.0 cloud=devstack-admin cloud_alt=devstack-alt" \
|
-e "cloud=devstack-admin cloud_alt=devstack-alt" \
|
||||||
--tags floating_ip_info
|
--tags floating_ip_info
|
||||||
```
|
```
|
||||||
* Does a patch remove any functionality or break backwards compatibility? The author must give a good explanation for
|
* Does a patch remove any functionality or break backwards compatibility? The author must give a good explanation for
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ dependencies: {}
|
|||||||
repository: https://opendev.org/openstack/ansible-collections-openstack
|
repository: https://opendev.org/openstack/ansible-collections-openstack
|
||||||
documentation: https://docs.ansible.com/ansible/latest/collections/openstack/cloud/index.html
|
documentation: https://docs.ansible.com/ansible/latest/collections/openstack/cloud/index.html
|
||||||
homepage: https://opendev.org/openstack/ansible-collections-openstack
|
homepage: https://opendev.org/openstack/ansible-collections-openstack
|
||||||
issues: https://storyboard.openstack.org/#!/project/openstack/ansible-collections-openstack
|
issues: https://bugs.launchpad.net/ansible-collections-openstack
|
||||||
build_ignore:
|
build_ignore:
|
||||||
- "*.tar.gz"
|
- "*.tar.gz"
|
||||||
- build_artifact
|
- build_artifact
|
||||||
@@ -32,4 +32,4 @@ build_ignore:
|
|||||||
- .vscode
|
- .vscode
|
||||||
- ansible_collections_openstack.egg-info
|
- ansible_collections_openstack.egg-info
|
||||||
- changelogs
|
- changelogs
|
||||||
version: 2.1.0
|
version: 2.6.0
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ dependencies: {}
|
|||||||
repository: https://opendev.org/openstack/ansible-collections-openstack
|
repository: https://opendev.org/openstack/ansible-collections-openstack
|
||||||
documentation: https://docs.ansible.com/ansible/latest/collections/openstack/cloud/index.html
|
documentation: https://docs.ansible.com/ansible/latest/collections/openstack/cloud/index.html
|
||||||
homepage: https://opendev.org/openstack/ansible-collections-openstack
|
homepage: https://opendev.org/openstack/ansible-collections-openstack
|
||||||
issues: https://storyboard.openstack.org/#!/project/openstack/ansible-collections-openstack
|
issues: https://bugs.launchpad.net/ansible-collections-openstack
|
||||||
build_ignore:
|
build_ignore:
|
||||||
- "*.tar.gz"
|
- "*.tar.gz"
|
||||||
- build_artifact
|
- build_artifact
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
requires_ansible: ">=2.8"
|
requires_ansible: '>=2.8'
|
||||||
action_groups:
|
action_groups:
|
||||||
openstack:
|
openstack:
|
||||||
- address_scope
|
- address_scope
|
||||||
|
- application_credential
|
||||||
- auth
|
- auth
|
||||||
- baremetal_deploy_template
|
- baremetal_deploy_template
|
||||||
- baremetal_inspect
|
- baremetal_inspect
|
||||||
@@ -9,6 +10,7 @@ action_groups:
|
|||||||
- baremetal_node_action
|
- baremetal_node_action
|
||||||
- baremetal_node_info
|
- baremetal_node_info
|
||||||
- baremetal_port
|
- baremetal_port
|
||||||
|
- baremetal_port_group
|
||||||
- baremetal_port_info
|
- baremetal_port_info
|
||||||
- catalog_service
|
- catalog_service
|
||||||
- catalog_service_info
|
- catalog_service_info
|
||||||
@@ -17,6 +19,7 @@ action_groups:
|
|||||||
- compute_flavor
|
- compute_flavor
|
||||||
- compute_flavor_access
|
- compute_flavor_access
|
||||||
- compute_flavor_info
|
- compute_flavor_info
|
||||||
|
- compute_service
|
||||||
- compute_service_info
|
- compute_service_info
|
||||||
- config
|
- config
|
||||||
- dns_zone
|
- dns_zone
|
||||||
@@ -30,6 +33,7 @@ action_groups:
|
|||||||
- floating_ip_info
|
- floating_ip_info
|
||||||
- group_assignment
|
- group_assignment
|
||||||
- host_aggregate
|
- host_aggregate
|
||||||
|
- host_aggregate_info
|
||||||
- identity_domain
|
- identity_domain
|
||||||
- identity_domain_info
|
- identity_domain_info
|
||||||
- identity_group
|
- identity_group
|
||||||
@@ -50,12 +54,16 @@ action_groups:
|
|||||||
- lb_pool
|
- lb_pool
|
||||||
- loadbalancer
|
- loadbalancer
|
||||||
- network
|
- network
|
||||||
|
- network_segment
|
||||||
- networks_info
|
- networks_info
|
||||||
- neutron_rbac_policies_info
|
- neutron_rbac_policies_info
|
||||||
- neutron_rbac_policy
|
- neutron_rbac_policy
|
||||||
- object
|
- object
|
||||||
- object_container
|
- object_container
|
||||||
|
- object_containers_info
|
||||||
- port
|
- port
|
||||||
|
- port_forwarding
|
||||||
|
- port_forwarding_info
|
||||||
- port_info
|
- port_info
|
||||||
- project
|
- project
|
||||||
- project_info
|
- project_info
|
||||||
@@ -76,15 +84,22 @@ action_groups:
|
|||||||
- server_info
|
- server_info
|
||||||
- server_metadata
|
- server_metadata
|
||||||
- server_volume
|
- server_volume
|
||||||
|
- share_type
|
||||||
|
- share_type_info
|
||||||
- stack
|
- stack
|
||||||
- stack_info
|
- stack_info
|
||||||
- subnet
|
- subnet
|
||||||
- subnet_pool
|
- subnet_pool
|
||||||
- subnets_info
|
- subnets_info
|
||||||
|
- trunk
|
||||||
- volume
|
- volume
|
||||||
|
- volume_manage
|
||||||
- volume_backup
|
- volume_backup
|
||||||
- volume_backup_info
|
- volume_backup_info
|
||||||
- volume_info
|
- volume_info
|
||||||
|
- volume_service_info
|
||||||
- volume_snapshot
|
- volume_snapshot
|
||||||
- volume_snapshot_info
|
- volume_snapshot_info
|
||||||
- volume_type_access
|
- volume_type_access
|
||||||
|
- volume_image_metadata
|
||||||
|
- volume_retype
|
||||||
|
|||||||
@@ -96,6 +96,18 @@ options:
|
|||||||
only.
|
only.
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
|
only_ipv4:
|
||||||
|
description:
|
||||||
|
- Use only ipv4 addresses for ansible_host and ansible_ssh_host.
|
||||||
|
- Using I(only_ipv4) helps when running Ansible in a ipv4 only setup.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
server_filters:
|
||||||
|
description:
|
||||||
|
- A dictionary of server filter value pairs.
|
||||||
|
- Available parameters can be seen under https://docs.openstack.org/api-ref/compute/#list-servers
|
||||||
|
type: dict
|
||||||
|
default: {}
|
||||||
show_all:
|
show_all:
|
||||||
description:
|
description:
|
||||||
- Whether all servers should be listed or not.
|
- Whether all servers should be listed or not.
|
||||||
@@ -143,9 +155,6 @@ import sys
|
|||||||
|
|
||||||
from ansible.errors import AnsibleParserError
|
from ansible.errors import AnsibleParserError
|
||||||
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
|
|
||||||
ensure_compatibility
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import openstack
|
import openstack
|
||||||
@@ -167,12 +176,6 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
raise AnsibleParserError(
|
raise AnsibleParserError(
|
||||||
'Could not import Python library openstacksdk')
|
'Could not import Python library openstacksdk')
|
||||||
|
|
||||||
try:
|
|
||||||
ensure_compatibility(openstack.version.__version__)
|
|
||||||
except ImportError as e:
|
|
||||||
raise AnsibleParserError(
|
|
||||||
'Incompatible openstacksdk library found: {0}'.format(e))
|
|
||||||
|
|
||||||
# Redirect logging to stderr so it does not mix with output, in
|
# Redirect logging to stderr so it does not mix with output, in
|
||||||
# particular JSON output of ansible-inventory.
|
# particular JSON output of ansible-inventory.
|
||||||
# TODO: Integrate openstack's logging with Ansible's logging.
|
# TODO: Integrate openstack's logging with Ansible's logging.
|
||||||
@@ -271,9 +274,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
if not attempt_to_read_cache or cache_needs_update:
|
if not attempt_to_read_cache or cache_needs_update:
|
||||||
self.display.vvvv('Retrieving servers from Openstack clouds')
|
self.display.vvvv('Retrieving servers from Openstack clouds')
|
||||||
clouds_yaml_path = self.get_option('clouds_yaml_path')
|
clouds_yaml_path = self.get_option('clouds_yaml_path')
|
||||||
config_files = (
|
config_files = openstack.config.loader.CONFIG_FILES
|
||||||
openstack.config.loader.CONFIG_FILES
|
if clouds_yaml_path:
|
||||||
+ ([clouds_yaml_path] if clouds_yaml_path else []))
|
config_files = clouds_yaml_path + config_files
|
||||||
|
|
||||||
config = openstack.config.loader.OpenStackConfig(
|
config = openstack.config.loader.OpenStackConfig(
|
||||||
config_files=config_files)
|
config_files=config_files)
|
||||||
@@ -303,6 +306,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
|
|
||||||
expand_hostvars = self.get_option('expand_hostvars')
|
expand_hostvars = self.get_option('expand_hostvars')
|
||||||
all_projects = self.get_option('all_projects')
|
all_projects = self.get_option('all_projects')
|
||||||
|
server_filters = self.get_option('server_filters')
|
||||||
servers = []
|
servers = []
|
||||||
|
|
||||||
def _expand_server(server, cloud, volumes):
|
def _expand_server(server, cloud, volumes):
|
||||||
@@ -349,7 +353,8 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
all_projects=all_projects,
|
all_projects=all_projects,
|
||||||
# details are required because 'addresses'
|
# details are required because 'addresses'
|
||||||
# attribute must be populated
|
# attribute must be populated
|
||||||
details=True)
|
details=True,
|
||||||
|
**server_filters)
|
||||||
]:
|
]:
|
||||||
servers.append(server)
|
servers.append(server)
|
||||||
except openstack.exceptions.OpenStackCloudException as e:
|
except openstack.exceptions.OpenStackCloudException as e:
|
||||||
@@ -384,6 +389,13 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
if address['OS-EXT-IPS:type'] == 'floating'),
|
if address['OS-EXT-IPS:type'] == 'floating'),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
|
if self.get_option('only_ipv4'):
|
||||||
|
fixed_ip = next(
|
||||||
|
(address['addr'] for address in addresses
|
||||||
|
if (address['OS-EXT-IPS:type'] == 'fixed' and address['version'] == 4)),
|
||||||
|
None)
|
||||||
|
|
||||||
|
else:
|
||||||
fixed_ip = next(
|
fixed_ip = next(
|
||||||
(address['addr'] for address in addresses
|
(address['addr'] for address in addresses
|
||||||
if address['OS-EXT-IPS:type'] == 'fixed'),
|
if address['OS-EXT-IPS:type'] == 'fixed'),
|
||||||
|
|||||||
@@ -32,61 +32,23 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
import copy
|
import copy
|
||||||
from ansible.module_utils.six import raise_from
|
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.compat.version import StrictVersion
|
from ansible.module_utils.compat.version import StrictVersion
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
raise_from(ImportError('To use this plugin or module with ansible-core'
|
raise ImportError(f'To use this plugin or module with ansible-core'
|
||||||
' < 2.11, you need to use Python < 3.12 with '
|
f' < 2.11, you need to use Python < 3.12 with '
|
||||||
'distutils.version present'), exc)
|
f'distutils.version present. {exc}')
|
||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
OVERRIDES = {}
|
OVERRIDES = {}
|
||||||
|
|
||||||
CUSTOM_VAR_PARAMS = ['min_ver', 'max_ver']
|
CUSTOM_VAR_PARAMS = ['min_ver', 'max_ver']
|
||||||
|
|
||||||
MINIMUM_SDK_VERSION = '1.0.0'
|
|
||||||
MAXIMUM_SDK_VERSION = None
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_compatibility(version, min_version=None, max_version=None):
|
|
||||||
""" Raises ImportError if the specified version does not
|
|
||||||
meet the minimum and maximum version requirements"""
|
|
||||||
|
|
||||||
if min_version and MINIMUM_SDK_VERSION:
|
|
||||||
min_version = max(StrictVersion(MINIMUM_SDK_VERSION),
|
|
||||||
StrictVersion(min_version))
|
|
||||||
elif MINIMUM_SDK_VERSION:
|
|
||||||
min_version = StrictVersion(MINIMUM_SDK_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(version) < min_version:
|
|
||||||
raise ImportError(
|
|
||||||
"Version MUST be >={min_version} and <={max_version}, but"
|
|
||||||
" {version} is smaller than minimum version {min_version}"
|
|
||||||
.format(version=version,
|
|
||||||
min_version=min_version,
|
|
||||||
max_version=max_version))
|
|
||||||
|
|
||||||
if max_version and StrictVersion(version) > max_version:
|
|
||||||
raise ImportError(
|
|
||||||
"Version MUST be >={min_version} and <={max_version}, but"
|
|
||||||
" {version} is larger than maximum version {max_version}"
|
|
||||||
.format(version=version,
|
|
||||||
min_version=min_version,
|
|
||||||
max_version=max_version))
|
|
||||||
|
|
||||||
|
|
||||||
def openstack_argument_spec():
|
def openstack_argument_spec():
|
||||||
# DEPRECATED: This argument spec is only used for the deprecated old
|
# DEPRECATED: This argument spec is only used for the deprecated old
|
||||||
@@ -165,14 +127,6 @@ def openstack_cloud_from_module(module, min_version=None, max_version=None):
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
module.fail_json(msg='openstacksdk is required for this module')
|
module.fail_json(msg='openstacksdk is required for this module')
|
||||||
|
|
||||||
try:
|
|
||||||
ensure_compatibility(sdk.version.__version__,
|
|
||||||
min_version, max_version)
|
|
||||||
except ImportError as e:
|
|
||||||
module.fail_json(
|
|
||||||
msg="Incompatible openstacksdk library found: {error}."
|
|
||||||
.format(error=str(e)))
|
|
||||||
|
|
||||||
cloud_config = module.params.pop('cloud', None)
|
cloud_config = module.params.pop('cloud', None)
|
||||||
try:
|
try:
|
||||||
if isinstance(cloud_config, dict):
|
if isinstance(cloud_config, dict):
|
||||||
@@ -183,7 +137,7 @@ def openstack_cloud_from_module(module, min_version=None, max_version=None):
|
|||||||
" excluded.")
|
" excluded.")
|
||||||
for param in (
|
for param in (
|
||||||
'auth', 'region_name', 'validate_certs',
|
'auth', 'region_name', 'validate_certs',
|
||||||
'ca_cert', 'client_key', 'api_timeout', 'auth_type'):
|
'ca_cert', 'client_cert', 'client_key', 'api_timeout', 'auth_type'):
|
||||||
if module.params[param] is not None:
|
if module.params[param] is not None:
|
||||||
module.fail_json(msg=fail_message.format(param=param))
|
module.fail_json(msg=fail_message.format(param=param))
|
||||||
# For 'interface' parameter, fail if we receive a non-default value
|
# For 'interface' parameter, fail if we receive a non-default value
|
||||||
@@ -199,6 +153,7 @@ def openstack_cloud_from_module(module, min_version=None, max_version=None):
|
|||||||
verify=module.params['validate_certs'],
|
verify=module.params['validate_certs'],
|
||||||
cacert=module.params['ca_cert'],
|
cacert=module.params['ca_cert'],
|
||||||
key=module.params['client_key'],
|
key=module.params['client_key'],
|
||||||
|
cert=module.params['client_cert'],
|
||||||
api_timeout=module.params['api_timeout'],
|
api_timeout=module.params['api_timeout'],
|
||||||
interface=module.params['interface'],
|
interface=module.params['interface'],
|
||||||
)
|
)
|
||||||
@@ -244,8 +199,6 @@ class OpenStackModule:
|
|||||||
deprecated_names = ()
|
deprecated_names = ()
|
||||||
argument_spec = {}
|
argument_spec = {}
|
||||||
module_kwargs = {}
|
module_kwargs = {}
|
||||||
module_min_sdk_version = None
|
|
||||||
module_max_sdk_version = None
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize Openstack base class.
|
"""Initialize Openstack base class.
|
||||||
@@ -314,19 +267,9 @@ class OpenStackModule:
|
|||||||
try:
|
try:
|
||||||
# Due to the name shadowing we should import other way
|
# Due to the name shadowing we should import other way
|
||||||
sdk = importlib.import_module('openstack')
|
sdk = importlib.import_module('openstack')
|
||||||
self.sdk_version = sdk.version.__version__
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
self.fail_json(msg='openstacksdk is required for this module')
|
self.fail_json(msg='openstacksdk is required for this module')
|
||||||
|
|
||||||
try:
|
|
||||||
ensure_compatibility(self.sdk_version,
|
|
||||||
self.module_min_sdk_version,
|
|
||||||
self.module_max_sdk_version)
|
|
||||||
except ImportError as e:
|
|
||||||
self.fail_json(
|
|
||||||
msg="Incompatible openstacksdk library found: {error}."
|
|
||||||
.format(error=str(e)))
|
|
||||||
|
|
||||||
# Fail if there are set unsupported for this version parameters
|
# Fail if there are set unsupported for this version parameters
|
||||||
# New parameters should NOT use 'default' but rely on SDK defaults
|
# New parameters should NOT use 'default' but rely on SDK defaults
|
||||||
for param in self.argument_spec:
|
for param in self.argument_spec:
|
||||||
@@ -358,7 +301,7 @@ class OpenStackModule:
|
|||||||
" excluded.")
|
" excluded.")
|
||||||
for param in (
|
for param in (
|
||||||
'auth', 'region_name', 'validate_certs',
|
'auth', 'region_name', 'validate_certs',
|
||||||
'ca_cert', 'client_key', 'api_timeout', 'auth_type'):
|
'ca_cert', 'client_cert', 'client_key', 'api_timeout', 'auth_type'):
|
||||||
if self.params[param] is not None:
|
if self.params[param] is not None:
|
||||||
self.fail_json(msg=fail_message.format(param=param))
|
self.fail_json(msg=fail_message.format(param=param))
|
||||||
# For 'interface' parameter, fail if we receive a non-default value
|
# For 'interface' parameter, fail if we receive a non-default value
|
||||||
@@ -373,6 +316,7 @@ class OpenStackModule:
|
|||||||
verify=self.params['validate_certs'],
|
verify=self.params['validate_certs'],
|
||||||
cacert=self.params['ca_cert'],
|
cacert=self.params['ca_cert'],
|
||||||
key=self.params['client_key'],
|
key=self.params['client_key'],
|
||||||
|
cert=self.params['client_cert'],
|
||||||
api_timeout=self.params['api_timeout'],
|
api_timeout=self.params['api_timeout'],
|
||||||
interface=self.params['interface'],
|
interface=self.params['interface'],
|
||||||
)
|
)
|
||||||
|
|||||||
332
plugins/modules/application_credential.py
Normal file
332
plugins/modules/application_credential.py
Normal file
@@ -0,0 +1,332 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (c) 2024 Red Hat, Inc.
|
||||||
|
# GNU General Public License v3.0+
|
||||||
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
DOCUMENTATION = r"""
|
||||||
|
---
|
||||||
|
module: application_credential
|
||||||
|
short_description: Manage OpenStack Identity (Keystone) application credentials
|
||||||
|
author: OpenStack Ansible SIG
|
||||||
|
description:
|
||||||
|
- Create or delete an OpenStack Identity (Keystone) application credential.
|
||||||
|
- When the secret parameter is not set a secret will be generated and returned
|
||||||
|
- in the response. Existing credentials cannot be modified so running this module
|
||||||
|
- against an existing credential will result in it being deleted and recreated.
|
||||||
|
- This needs to be taken into account when the secret is generated, as the secret
|
||||||
|
- will change on each run of the module.
|
||||||
|
options:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Name of the application credential.
|
||||||
|
required: true
|
||||||
|
type: str
|
||||||
|
description:
|
||||||
|
description:
|
||||||
|
- Application credential description.
|
||||||
|
type: str
|
||||||
|
secret:
|
||||||
|
description:
|
||||||
|
- Secret to use for authentication
|
||||||
|
- (if not provided, one will be generated).
|
||||||
|
type: str
|
||||||
|
roles:
|
||||||
|
description:
|
||||||
|
- Roles to authorize (name or ID).
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
suboptions:
|
||||||
|
name:
|
||||||
|
description: Name of role
|
||||||
|
type: str
|
||||||
|
id:
|
||||||
|
description: ID of role
|
||||||
|
type: str
|
||||||
|
domain_id:
|
||||||
|
description: Domain ID
|
||||||
|
type: str
|
||||||
|
expires_at:
|
||||||
|
description:
|
||||||
|
- Sets an expiration date for the application credential,
|
||||||
|
- format of YYYY-mm-ddTHH:MM:SS
|
||||||
|
- (if not provided, the application credential will not expire).
|
||||||
|
type: str
|
||||||
|
unrestricted:
|
||||||
|
description:
|
||||||
|
- Enable application credential to create and delete other application
|
||||||
|
- credentials and trusts (this is potentially dangerous behavior and is
|
||||||
|
- disabled by default).
|
||||||
|
default: false
|
||||||
|
type: bool
|
||||||
|
access_rules:
|
||||||
|
description:
|
||||||
|
- List of access rules, each containing a request method, path, and service.
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
suboptions:
|
||||||
|
service:
|
||||||
|
description: Name of service endpoint
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
path:
|
||||||
|
description: Path portion of access URL
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
method:
|
||||||
|
description: HTTP method
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- Should the resource be present or absent.
|
||||||
|
- Application credentials are immutable so running with an existing present
|
||||||
|
- credential will result in the credential being deleted and recreated.
|
||||||
|
choices: [present, absent]
|
||||||
|
default: present
|
||||||
|
type: str
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- openstack.cloud.openstack
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
- name: Create application credential
|
||||||
|
openstack.cloud.application_credential:
|
||||||
|
cloud: mycloud
|
||||||
|
description: demodescription
|
||||||
|
name: democreds
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create application credential with expiration, access rules and roles
|
||||||
|
openstack.cloud.application_credential:
|
||||||
|
cloud: mycloud
|
||||||
|
description: demodescription
|
||||||
|
name: democreds
|
||||||
|
access_rules:
|
||||||
|
- service: "compute"
|
||||||
|
path: "/v2.1/servers"
|
||||||
|
method: "GET"
|
||||||
|
expires_at: "2024-02-29T09:29:59"
|
||||||
|
roles:
|
||||||
|
- name: Member
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Delete application credential
|
||||||
|
openstack.cloud.application_credential:
|
||||||
|
cloud: mycloud
|
||||||
|
name: democreds
|
||||||
|
state: absent
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = r"""
|
||||||
|
application_credential:
|
||||||
|
description: Dictionary describing the project.
|
||||||
|
returned: On success when I(state) is C(present).
|
||||||
|
type: dict
|
||||||
|
contains:
|
||||||
|
id:
|
||||||
|
description: The ID of the application credential.
|
||||||
|
type: str
|
||||||
|
sample: "2e73d1b4f0cb473f920bd54dfce3c26d"
|
||||||
|
name:
|
||||||
|
description: The name of the application credential.
|
||||||
|
type: str
|
||||||
|
sample: "appcreds"
|
||||||
|
secret:
|
||||||
|
description: Secret to use for authentication
|
||||||
|
(if not provided, returns the generated value).
|
||||||
|
type: str
|
||||||
|
sample: "JxE7LajLY75NZgDH1hfu0N_6xS9hQ-Af40W3"
|
||||||
|
description:
|
||||||
|
description: A description of the application credential's purpose.
|
||||||
|
type: str
|
||||||
|
sample: "App credential"
|
||||||
|
expires_at:
|
||||||
|
description: The expiration time of the application credential in UTC,
|
||||||
|
if one was specified.
|
||||||
|
type: str
|
||||||
|
sample: "2024-02-29T09:29:59.000000"
|
||||||
|
project_id:
|
||||||
|
description: The ID of the project the application credential was created
|
||||||
|
for and that authentication requests using this application
|
||||||
|
credential will be scoped to.
|
||||||
|
type: str
|
||||||
|
sample: "4b633c451ac74233be3721a3635275e5"
|
||||||
|
roles:
|
||||||
|
description: A list of one or more roles that this application credential
|
||||||
|
has associated with its project. A token using this application
|
||||||
|
credential will have these same roles.
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
sample: [{"name": "Member"}]
|
||||||
|
access_rules:
|
||||||
|
description: A list of access_rules objects
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
sample:
|
||||||
|
- id: "edecb6c791d541a3b458199858470d20"
|
||||||
|
service: "compute"
|
||||||
|
path: "/v2.1/servers"
|
||||||
|
method: "GET"
|
||||||
|
unrestricted:
|
||||||
|
description: A flag indicating whether the application credential may be
|
||||||
|
used for creation or destruction of other application credentials
|
||||||
|
or trusts.
|
||||||
|
type: bool
|
||||||
|
cloud:
|
||||||
|
description: The current cloud config with the username and password replaced
|
||||||
|
with the name and secret of the application credential. This
|
||||||
|
can be passed to the cloud parameter of other tasks, or written
|
||||||
|
to an openstack cloud config file.
|
||||||
|
returned: On success when I(state) is C(present).
|
||||||
|
type: dict
|
||||||
|
sample:
|
||||||
|
auth_type: "v3applicationcredential"
|
||||||
|
auth:
|
||||||
|
auth_url: "https://192.0.2.1/identity"
|
||||||
|
application_credential_secret: "JxE7LajLY75NZgDH1hfu0N_6xS9hQ-Af40W3"
|
||||||
|
application_credential_id: "3e73d1b4f0cb473f920bd54dfce3c26d"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import copy
|
||||||
|
|
||||||
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
|
||||||
|
OpenStackModule,
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import openstack.config
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IdentityApplicationCredentialModule(OpenStackModule):
|
||||||
|
argument_spec = dict(
|
||||||
|
name=dict(required=True),
|
||||||
|
description=dict(),
|
||||||
|
secret=dict(no_log=True),
|
||||||
|
roles=dict(
|
||||||
|
type="list",
|
||||||
|
elements="dict",
|
||||||
|
options=dict(name=dict(), id=dict(), domain_id=dict()),
|
||||||
|
),
|
||||||
|
expires_at=dict(),
|
||||||
|
unrestricted=dict(type="bool", default=False),
|
||||||
|
access_rules=dict(
|
||||||
|
type="list",
|
||||||
|
elements="dict",
|
||||||
|
options=dict(
|
||||||
|
service=dict(required=True),
|
||||||
|
path=dict(required=True),
|
||||||
|
method=dict(required=True),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
state=dict(default="present", choices=["absent", "present"]),
|
||||||
|
)
|
||||||
|
module_kwargs = dict()
|
||||||
|
cloud = None
|
||||||
|
|
||||||
|
def openstack_cloud_from_module(self):
|
||||||
|
# Fetch cloud param before it is popped
|
||||||
|
self.cloud = self.params["cloud"]
|
||||||
|
return OpenStackModule.openstack_cloud_from_module(self)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
state = self.params["state"]
|
||||||
|
|
||||||
|
creds = self._find()
|
||||||
|
|
||||||
|
if state == "present" and not creds:
|
||||||
|
# Create creds
|
||||||
|
creds = self._create().to_dict(computed=False)
|
||||||
|
cloud_config = self._get_cloud_config(creds)
|
||||||
|
self.exit_json(
|
||||||
|
changed=True, application_credential=creds, cloud=cloud_config
|
||||||
|
)
|
||||||
|
|
||||||
|
elif state == "present" and creds:
|
||||||
|
# Recreate immutable creds
|
||||||
|
self._delete(creds)
|
||||||
|
creds = self._create().to_dict(computed=False)
|
||||||
|
cloud_config = self._get_cloud_config(creds)
|
||||||
|
self.exit_json(
|
||||||
|
changed=True, application_credential=creds, cloud=cloud_config
|
||||||
|
)
|
||||||
|
|
||||||
|
elif state == "absent" and creds:
|
||||||
|
# Delete creds
|
||||||
|
self._delete(creds)
|
||||||
|
self.exit_json(changed=True)
|
||||||
|
|
||||||
|
elif state == "absent" and not creds:
|
||||||
|
# Do nothing
|
||||||
|
self.exit_json(changed=False)
|
||||||
|
|
||||||
|
def _get_user_id(self):
|
||||||
|
return self.conn.session.get_user_id()
|
||||||
|
|
||||||
|
def _create(self):
|
||||||
|
kwargs = dict(
|
||||||
|
(k, self.params[k])
|
||||||
|
for k in [
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"secret",
|
||||||
|
"expires_at",
|
||||||
|
"unrestricted",
|
||||||
|
"access_rules",
|
||||||
|
]
|
||||||
|
if self.params[k] is not None
|
||||||
|
)
|
||||||
|
|
||||||
|
roles = self.params["roles"]
|
||||||
|
if roles:
|
||||||
|
kwroles = []
|
||||||
|
for role in roles:
|
||||||
|
kwroles.append(
|
||||||
|
dict(
|
||||||
|
(k, role[k])
|
||||||
|
for k in ["name", "id", "domain_id"]
|
||||||
|
if role[k] is not None
|
||||||
|
)
|
||||||
|
)
|
||||||
|
kwargs["roles"] = kwroles
|
||||||
|
|
||||||
|
kwargs["user"] = self._get_user_id()
|
||||||
|
creds = self.conn.identity.create_application_credential(**kwargs)
|
||||||
|
return creds
|
||||||
|
|
||||||
|
def _get_cloud_config(self, creds):
|
||||||
|
cloud_region = openstack.config.OpenStackConfig().get_one(self.cloud)
|
||||||
|
|
||||||
|
conf = cloud_region.config
|
||||||
|
cloud_config = copy.deepcopy(conf)
|
||||||
|
cloud_config["auth_type"] = "v3applicationcredential"
|
||||||
|
cloud_config["auth"] = {
|
||||||
|
"application_credential_id": creds["id"],
|
||||||
|
"application_credential_secret": creds["secret"],
|
||||||
|
"auth_url": conf["auth"]["auth_url"],
|
||||||
|
}
|
||||||
|
|
||||||
|
return cloud_config
|
||||||
|
|
||||||
|
def _delete(self, creds):
|
||||||
|
user = self._get_user_id()
|
||||||
|
self.conn.identity.delete_application_credential(user, creds.id)
|
||||||
|
|
||||||
|
def _find(self):
|
||||||
|
name = self.params["name"]
|
||||||
|
user = self._get_user_id()
|
||||||
|
return self.conn.identity.find_application_credential(
|
||||||
|
user=user, name_or_id=name
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = IdentityApplicationCredentialModule()
|
||||||
|
module()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -243,6 +243,10 @@ node:
|
|||||||
retired_reason:
|
retired_reason:
|
||||||
description: TODO
|
description: TODO
|
||||||
type: str
|
type: str
|
||||||
|
shard:
|
||||||
|
description: The shard key for a node.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
states:
|
states:
|
||||||
description: |
|
description: |
|
||||||
Links to the collection of states. Note that this resource is also
|
Links to the collection of states. Note that this resource is also
|
||||||
|
|||||||
@@ -437,6 +437,10 @@ node:
|
|||||||
description: The reason the node is marked as retired.
|
description: The reason the node is marked as retired.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
|
shard:
|
||||||
|
description: The shard key for a node.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
states:
|
states:
|
||||||
description: Links to the collection of states.
|
description: Links to the collection of states.
|
||||||
returned: success
|
returned: success
|
||||||
|
|||||||
@@ -289,6 +289,10 @@ nodes:
|
|||||||
description: The reason the node is marked as retired.
|
description: The reason the node is marked as retired.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
|
shard:
|
||||||
|
description: The shard key for a node.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
states:
|
states:
|
||||||
description: Links to the collection of states.
|
description: Links to the collection of states.
|
||||||
returned: success
|
returned: success
|
||||||
|
|||||||
258
plugins/modules/baremetal_port_group.py
Normal file
258
plugins/modules/baremetal_port_group.py
Normal file
@@ -0,0 +1,258 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (c) 2026 OpenStack Ansible SIG
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
DOCUMENTATION = r'''
|
||||||
|
module: baremetal_port_group
|
||||||
|
short_description: Create/Delete Bare Metal port group resources from OpenStack
|
||||||
|
author: OpenStack Ansible SIG
|
||||||
|
description:
|
||||||
|
- Create, update and remove Bare Metal port groups from OpenStack.
|
||||||
|
options:
|
||||||
|
id:
|
||||||
|
description:
|
||||||
|
- ID of the port group.
|
||||||
|
- Will be auto-generated if not specified.
|
||||||
|
type: str
|
||||||
|
aliases: ['uuid']
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Name of the port group.
|
||||||
|
type: str
|
||||||
|
node:
|
||||||
|
description:
|
||||||
|
- ID or Name of the node this resource belongs to.
|
||||||
|
- Required when creating a new port group.
|
||||||
|
type: str
|
||||||
|
address:
|
||||||
|
description:
|
||||||
|
- Physical hardware address of this port group, typically the hardware
|
||||||
|
MAC address.
|
||||||
|
type: str
|
||||||
|
extra:
|
||||||
|
description:
|
||||||
|
- A set of one or more arbitrary metadata key and value pairs.
|
||||||
|
type: dict
|
||||||
|
standalone_ports_supported:
|
||||||
|
description:
|
||||||
|
- Whether the port group supports ports that are not members of this
|
||||||
|
port group.
|
||||||
|
type: bool
|
||||||
|
mode:
|
||||||
|
description:
|
||||||
|
- The port group mode.
|
||||||
|
type: str
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
- Key/value properties for the port group.
|
||||||
|
type: dict
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- Indicates desired state of the resource.
|
||||||
|
choices: ['present', 'absent']
|
||||||
|
default: present
|
||||||
|
type: str
|
||||||
|
version_added: 2.6.0
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- openstack.cloud.openstack
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = r'''
|
||||||
|
- name: Create Bare Metal port group
|
||||||
|
openstack.cloud.baremetal_port_group:
|
||||||
|
cloud: devstack
|
||||||
|
state: present
|
||||||
|
name: bond0
|
||||||
|
node: bm-0
|
||||||
|
address: fa:16:3e:aa:aa:aa
|
||||||
|
mode: '802.3ad'
|
||||||
|
standalone_ports_supported: true
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Update Bare Metal port group
|
||||||
|
openstack.cloud.baremetal_port_group:
|
||||||
|
cloud: devstack
|
||||||
|
state: present
|
||||||
|
id: 1a85ebca-22bf-42eb-ad9e-f640789b8098
|
||||||
|
mode: 'active-backup'
|
||||||
|
properties:
|
||||||
|
miimon: '100'
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Delete Bare Metal port group
|
||||||
|
openstack.cloud.baremetal_port_group:
|
||||||
|
cloud: devstack
|
||||||
|
state: absent
|
||||||
|
id: 1a85ebca-22bf-42eb-ad9e-f640789b8098
|
||||||
|
register: result
|
||||||
|
'''
|
||||||
|
|
||||||
|
RETURN = r'''
|
||||||
|
port_group:
|
||||||
|
description: A port group dictionary, subset of the dictionary keys listed
|
||||||
|
below may be returned, depending on your cloud provider.
|
||||||
|
returned: success
|
||||||
|
type: dict
|
||||||
|
contains:
|
||||||
|
address:
|
||||||
|
description: Physical hardware address of the port group.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
created_at:
|
||||||
|
description: Bare Metal port group 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 Bare Metal port group resource.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
links:
|
||||||
|
description: A list of relative links, including the self and
|
||||||
|
bookmark links.
|
||||||
|
returned: success
|
||||||
|
type: list
|
||||||
|
mode:
|
||||||
|
description: The port group mode.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
name:
|
||||||
|
description: Bare Metal port group name.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
node_id:
|
||||||
|
description: UUID of the Bare Metal node this resource belongs to.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
properties:
|
||||||
|
description: Key/value properties for this port group.
|
||||||
|
returned: success
|
||||||
|
type: dict
|
||||||
|
standalone_ports_supported:
|
||||||
|
description: Whether standalone ports are supported.
|
||||||
|
returned: success
|
||||||
|
type: bool
|
||||||
|
updated_at:
|
||||||
|
description: Bare Metal port group updated at timestamp.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
'''
|
||||||
|
|
||||||
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
|
||||||
|
OpenStackModule
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class BaremetalPortGroupModule(OpenStackModule):
|
||||||
|
argument_spec = dict(
|
||||||
|
id=dict(aliases=['uuid']),
|
||||||
|
name=dict(),
|
||||||
|
node=dict(),
|
||||||
|
address=dict(),
|
||||||
|
extra=dict(type='dict'),
|
||||||
|
standalone_ports_supported=dict(type='bool'),
|
||||||
|
mode=dict(),
|
||||||
|
properties=dict(type='dict'),
|
||||||
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
|
)
|
||||||
|
|
||||||
|
module_kwargs = dict(
|
||||||
|
required_one_of=[
|
||||||
|
('id', 'name'),
|
||||||
|
],
|
||||||
|
supports_check_mode=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _find_port_group(self):
|
||||||
|
id_or_name = self.params['id'] if self.params['id'] else self.params['name']
|
||||||
|
if not id_or_name:
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
return self.conn.baremetal.find_port_group(id_or_name)
|
||||||
|
except self.sdk.exceptions.ResourceNotFound:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _build_create_attrs(self):
|
||||||
|
attrs = {}
|
||||||
|
|
||||||
|
for key in ['id', 'name', 'address', 'extra',
|
||||||
|
'standalone_ports_supported', 'mode', 'properties']:
|
||||||
|
if self.params[key] is not None:
|
||||||
|
attrs[key] = self.params[key]
|
||||||
|
|
||||||
|
node_name_or_id = self.params['node']
|
||||||
|
if not node_name_or_id:
|
||||||
|
self.fail_json(msg="Parameter 'node' is required when creating a new port group")
|
||||||
|
|
||||||
|
node = self.conn.baremetal.find_node(node_name_or_id, ignore_missing=False)
|
||||||
|
attrs['node_id'] = node['id']
|
||||||
|
return attrs
|
||||||
|
|
||||||
|
def _build_update_attrs(self, port_group):
|
||||||
|
attrs = {}
|
||||||
|
|
||||||
|
for key in ['name', 'address', 'extra',
|
||||||
|
'standalone_ports_supported', 'mode', 'properties']:
|
||||||
|
if self.params[key] is not None and self.params[key] != port_group.get(key):
|
||||||
|
attrs[key] = self.params[key]
|
||||||
|
|
||||||
|
return attrs
|
||||||
|
|
||||||
|
def _will_change(self, port_group, state):
|
||||||
|
if state == 'absent':
|
||||||
|
return bool(port_group)
|
||||||
|
|
||||||
|
if not port_group:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return bool(self._build_update_attrs(port_group))
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
state = self.params['state']
|
||||||
|
port_group = self._find_port_group()
|
||||||
|
|
||||||
|
if self.ansible.check_mode:
|
||||||
|
if state == 'present' and not port_group:
|
||||||
|
self._build_create_attrs()
|
||||||
|
self.exit_json(changed=self._will_change(port_group, state))
|
||||||
|
|
||||||
|
if state == 'present':
|
||||||
|
if not port_group:
|
||||||
|
port_group = self.conn.baremetal.create_port_group(
|
||||||
|
**self._build_create_attrs())
|
||||||
|
self.exit_json(
|
||||||
|
changed=True,
|
||||||
|
port_group=port_group.to_dict(computed=False))
|
||||||
|
|
||||||
|
update_attrs = self._build_update_attrs(port_group)
|
||||||
|
changed = bool(update_attrs)
|
||||||
|
|
||||||
|
if changed:
|
||||||
|
port_group = self.conn.baremetal.update_port_group(
|
||||||
|
port_group['id'], **update_attrs)
|
||||||
|
|
||||||
|
self.exit_json(
|
||||||
|
changed=changed,
|
||||||
|
port_group=port_group.to_dict(computed=False))
|
||||||
|
|
||||||
|
if not port_group:
|
||||||
|
self.exit_json(changed=False)
|
||||||
|
|
||||||
|
self.conn.baremetal.delete_port_group(port_group['id'])
|
||||||
|
self.exit_json(changed=True)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = BaremetalPortGroupModule()
|
||||||
|
module()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -80,6 +80,10 @@ options:
|
|||||||
- Magnum's default value for I(is_registry_enabled) is C(false).
|
- Magnum's default value for I(is_registry_enabled) is C(false).
|
||||||
type: bool
|
type: bool
|
||||||
aliases: ['registry_enabled']
|
aliases: ['registry_enabled']
|
||||||
|
insecure_registry:
|
||||||
|
description:
|
||||||
|
- The URL pointing to users own private insecure docker registry.
|
||||||
|
type: str
|
||||||
is_tls_disabled:
|
is_tls_disabled:
|
||||||
description:
|
description:
|
||||||
- Indicates whether the TLS should be disabled.
|
- Indicates whether the TLS should be disabled.
|
||||||
@@ -342,6 +346,7 @@ class COEClusterTemplateModule(OpenStackModule):
|
|||||||
keypair_id=dict(),
|
keypair_id=dict(),
|
||||||
labels=dict(type='raw'),
|
labels=dict(type='raw'),
|
||||||
master_flavor_id=dict(),
|
master_flavor_id=dict(),
|
||||||
|
insecure_registry=dict(),
|
||||||
is_master_lb_enabled=dict(type='bool', default=False,
|
is_master_lb_enabled=dict(type='bool', default=False,
|
||||||
aliases=['master_lb_enabled']),
|
aliases=['master_lb_enabled']),
|
||||||
is_public=dict(type='bool', aliases=['public']),
|
is_public=dict(type='bool', aliases=['public']),
|
||||||
@@ -412,6 +417,7 @@ class COEClusterTemplateModule(OpenStackModule):
|
|||||||
'fixed_subnet', 'flavor_id',
|
'fixed_subnet', 'flavor_id',
|
||||||
'http_proxy', 'https_proxy',
|
'http_proxy', 'https_proxy',
|
||||||
'image_id',
|
'image_id',
|
||||||
|
'insecure_registry',
|
||||||
'is_floating_ip_enabled',
|
'is_floating_ip_enabled',
|
||||||
'is_master_lb_enabled',
|
'is_master_lb_enabled',
|
||||||
'is_public', 'is_registry_enabled',
|
'is_public', 'is_registry_enabled',
|
||||||
@@ -427,6 +433,9 @@ class COEClusterTemplateModule(OpenStackModule):
|
|||||||
if isinstance(labels, str):
|
if isinstance(labels, str):
|
||||||
labels = dict([tuple(kv.split(":"))
|
labels = dict([tuple(kv.split(":"))
|
||||||
for kv in labels.split(",")])
|
for kv in labels.split(",")])
|
||||||
|
elif isinstance(labels, dict):
|
||||||
|
labels = dict({str(k): str(v)
|
||||||
|
for k, v in labels.items()})
|
||||||
if labels != cluster_template['labels']:
|
if labels != cluster_template['labels']:
|
||||||
non_updateable_keys.append('labels')
|
non_updateable_keys.append('labels')
|
||||||
|
|
||||||
@@ -458,7 +467,7 @@ class COEClusterTemplateModule(OpenStackModule):
|
|||||||
'external_network_id', 'fixed_network',
|
'external_network_id', 'fixed_network',
|
||||||
'fixed_subnet', 'flavor_id', 'http_proxy',
|
'fixed_subnet', 'flavor_id', 'http_proxy',
|
||||||
'https_proxy', 'image_id',
|
'https_proxy', 'image_id',
|
||||||
'is_floating_ip_enabled',
|
'insecure_registry', 'is_floating_ip_enabled',
|
||||||
'is_master_lb_enabled', 'is_public',
|
'is_master_lb_enabled', 'is_public',
|
||||||
'is_registry_enabled', 'is_tls_disabled',
|
'is_registry_enabled', 'is_tls_disabled',
|
||||||
'keypair_id', 'master_flavor_id', 'name',
|
'keypair_id', 'master_flavor_id', 'name',
|
||||||
|
|||||||
152
plugins/modules/compute_service.py
Normal file
152
plugins/modules/compute_service.py
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (c) 2025 Boehringer Ingelheim
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
DOCUMENTATION = r'''
|
||||||
|
---
|
||||||
|
module: compute_service
|
||||||
|
short_description: Update OpenStack Compute (Nova) services
|
||||||
|
author: OpenStack Ansible SIG
|
||||||
|
description:
|
||||||
|
- Update OpenStack Compute (Nova) service properties.
|
||||||
|
options:
|
||||||
|
host:
|
||||||
|
description:
|
||||||
|
- Compute host name
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
binary:
|
||||||
|
description:
|
||||||
|
- Binary name of the service (e.g. C(nova-compute)).
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
status:
|
||||||
|
description:
|
||||||
|
- Desired status of the service.
|
||||||
|
type: str
|
||||||
|
choices: ['enabled', 'disabled']
|
||||||
|
default: enabled
|
||||||
|
disabled_reason:
|
||||||
|
description:
|
||||||
|
- Reason for disabling the service. Should be used with state `disabled`.
|
||||||
|
type: str
|
||||||
|
version_added: 2.6.0
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- openstack.cloud.openstack
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = r'''
|
||||||
|
- name: Disable nova-compute on node1
|
||||||
|
openstack.cloud.compute_service:
|
||||||
|
cloud: awesomecloud
|
||||||
|
host: node1
|
||||||
|
binary: nova-compute
|
||||||
|
status: disabled
|
||||||
|
|
||||||
|
- name: Enable nova-compute on node1
|
||||||
|
openstack.cloud.compute_service:
|
||||||
|
cloud: awesomecloud
|
||||||
|
host: node1
|
||||||
|
binary: nova-compute
|
||||||
|
status: enabled
|
||||||
|
'''
|
||||||
|
|
||||||
|
RETURN = r'''
|
||||||
|
compute_services:
|
||||||
|
description: List of dictionaries describing Compute (Nova) services.
|
||||||
|
returned: always
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
contains:
|
||||||
|
availability_zone:
|
||||||
|
description: The availability zone name.
|
||||||
|
type: str
|
||||||
|
binary:
|
||||||
|
description: The binary name of the service.
|
||||||
|
type: str
|
||||||
|
disabled_reason:
|
||||||
|
description: The reason why the service is disabled
|
||||||
|
type: str
|
||||||
|
id:
|
||||||
|
description: Unique UUID.
|
||||||
|
type: str
|
||||||
|
is_forced_down:
|
||||||
|
description: If the service has been forced down or nova-compute
|
||||||
|
type: bool
|
||||||
|
host:
|
||||||
|
description: The name of the host.
|
||||||
|
type: str
|
||||||
|
name:
|
||||||
|
description: Service name
|
||||||
|
type: str
|
||||||
|
state:
|
||||||
|
description: The state of the service. One of up or down.
|
||||||
|
type: str
|
||||||
|
status:
|
||||||
|
description: The status of the service. One of enabled or disabled.
|
||||||
|
type: str
|
||||||
|
update_at:
|
||||||
|
description: The date and time when the resource was updated
|
||||||
|
type: str
|
||||||
|
'''
|
||||||
|
|
||||||
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
||||||
|
|
||||||
|
|
||||||
|
class ComputeServiceModule(OpenStackModule):
|
||||||
|
argument_spec = dict(
|
||||||
|
host=dict(required=True),
|
||||||
|
binary=dict(required=True),
|
||||||
|
status=dict(default="enabled", choices=['enabled', 'disabled']),
|
||||||
|
disabled_reason=dict(default=None)
|
||||||
|
)
|
||||||
|
|
||||||
|
module_kwargs = dict(
|
||||||
|
supports_check_mode=True
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
changed = False
|
||||||
|
|
||||||
|
kwargs = {k: self.params[k]
|
||||||
|
for k in ['binary', 'host']
|
||||||
|
if self.params[k] is not None}
|
||||||
|
|
||||||
|
# retrieve current state of service(s)
|
||||||
|
compute_services = self.conn.compute.services(**kwargs)
|
||||||
|
|
||||||
|
# extract desired status
|
||||||
|
desired_status = self.params['status']
|
||||||
|
disabled_reason = self.params['disabled_reason']
|
||||||
|
|
||||||
|
# apply updates to diverging status
|
||||||
|
for service in compute_services:
|
||||||
|
|
||||||
|
current_status = service.status
|
||||||
|
|
||||||
|
if current_status != desired_status:
|
||||||
|
changed = True
|
||||||
|
if not self.check_mode:
|
||||||
|
|
||||||
|
if desired_status == 'disabled':
|
||||||
|
self.conn.compute.disable_service(service=service, host=service.host, binary=service.binary, disabled_reason=disabled_reason)
|
||||||
|
else:
|
||||||
|
self.conn.compute.enable_service(service=service, host=service.host, binary=service.binary)
|
||||||
|
|
||||||
|
# retrieve final state of the service(s)
|
||||||
|
compute_services = self.conn.compute.services(**kwargs)
|
||||||
|
|
||||||
|
self.exit_json(changed=changed,
|
||||||
|
compute_services=[s.to_dict(computed=False)
|
||||||
|
for s in compute_services],)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = ComputeServiceModule()
|
||||||
|
module()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -41,11 +41,11 @@ extends_documentation_fragment:
|
|||||||
|
|
||||||
EXAMPLES = r'''
|
EXAMPLES = r'''
|
||||||
- name: Fetch all DNS zones
|
- name: Fetch all DNS zones
|
||||||
openstack.cloud.dns_zones:
|
openstack.cloud.dns_zone_info:
|
||||||
cloud: devstack
|
cloud: devstack
|
||||||
|
|
||||||
- name: Fetch DNS zones by name
|
- name: Fetch DNS zones by name
|
||||||
openstack.cloud.dns_zones:
|
openstack.cloud.dns_zone_info:
|
||||||
cloud: devstack
|
cloud: devstack
|
||||||
name: ansible.test.zone.
|
name: ansible.test.zone.
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ description:
|
|||||||
- Create, update or delete an identity provider of the OpenStack
|
- Create, update or delete an identity provider of the OpenStack
|
||||||
identity (Keystone) service.
|
identity (Keystone) service.
|
||||||
options:
|
options:
|
||||||
|
authorization_ttl:
|
||||||
|
description:
|
||||||
|
- Time to keep the role assignments for users authenticating via this identity provider.
|
||||||
|
- When not provided, global default configured in the Identity service will be used.
|
||||||
|
type: int
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- The description of the identity provider.
|
- The description of the identity provider.
|
||||||
@@ -58,6 +63,7 @@ EXAMPLES = r'''
|
|||||||
name: example_provider
|
name: example_provider
|
||||||
domain_id: 0123456789abcdef0123456789abcdef
|
domain_id: 0123456789abcdef0123456789abcdef
|
||||||
description: 'My example IDP'
|
description: 'My example IDP'
|
||||||
|
authorization_ttl: 300
|
||||||
remote_ids:
|
remote_ids:
|
||||||
- 'https://auth.example.com/auth/realms/ExampleRealm'
|
- 'https://auth.example.com/auth/realms/ExampleRealm'
|
||||||
|
|
||||||
@@ -74,6 +80,10 @@ identity_provider:
|
|||||||
returned: On success when I(state) is C(present).
|
returned: On success when I(state) is C(present).
|
||||||
type: dict
|
type: dict
|
||||||
contains:
|
contains:
|
||||||
|
authorization_ttl:
|
||||||
|
description: Time to keep the role assignments for users authenticating via this identity provider.
|
||||||
|
type: int
|
||||||
|
sample: 300
|
||||||
description:
|
description:
|
||||||
description: Identity provider description
|
description: Identity provider description
|
||||||
type: str
|
type: str
|
||||||
@@ -104,6 +114,7 @@ from ansible_collections.openstack.cloud.plugins.module_utils.resource import St
|
|||||||
|
|
||||||
class IdentityProviderModule(OpenStackModule):
|
class IdentityProviderModule(OpenStackModule):
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
|
authorization_ttl=dict(type='int'),
|
||||||
description=dict(),
|
description=dict(),
|
||||||
domain_id=dict(),
|
domain_id=dict(),
|
||||||
id=dict(required=True, aliases=['name']),
|
id=dict(required=True, aliases=['name']),
|
||||||
@@ -127,7 +138,7 @@ class IdentityProviderModule(OpenStackModule):
|
|||||||
|
|
||||||
kwargs['attributes'] = \
|
kwargs['attributes'] = \
|
||||||
dict((k, self.params[k])
|
dict((k, self.params[k])
|
||||||
for k in ['description', 'domain_id', 'id', 'is_enabled',
|
for k in ['authorization_ttl', 'description', 'domain_id', 'id', 'is_enabled',
|
||||||
'remote_ids']
|
'remote_ids']
|
||||||
if self.params[k] is not None)
|
if self.params[k] is not None)
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,13 @@ options:
|
|||||||
required: true
|
required: true
|
||||||
type: list
|
type: list
|
||||||
elements: dict
|
elements: dict
|
||||||
|
schema_version:
|
||||||
|
description:
|
||||||
|
- The federated attribute mapping schema version.
|
||||||
|
The default value on the client side is 'None';
|
||||||
|
however, that will lead the backend to set the default according
|
||||||
|
to 'attribute_mapping_default_schema_version' option.
|
||||||
|
type: str
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Whether the mapping should be C(present) or C(absent).
|
- Whether the mapping should be C(present) or C(absent).
|
||||||
@@ -69,6 +76,7 @@ EXAMPLES = r'''
|
|||||||
any_one_of:
|
any_one_of:
|
||||||
- Contractor
|
- Contractor
|
||||||
- SubContractor
|
- SubContractor
|
||||||
|
schema_version: '1.0'
|
||||||
|
|
||||||
- name: Delete a mapping
|
- name: Delete a mapping
|
||||||
openstack.cloud.federation_mapping:
|
openstack.cloud.federation_mapping:
|
||||||
@@ -93,6 +101,9 @@ mapping:
|
|||||||
rules:
|
rules:
|
||||||
description: List of rules for the mapping
|
description: List of rules for the mapping
|
||||||
type: list
|
type: list
|
||||||
|
schema_version:
|
||||||
|
description: Schema version of the mapping
|
||||||
|
type: str
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
||||||
@@ -108,6 +119,7 @@ class IdentityFederationMappingModule(OpenStackModule):
|
|||||||
local=dict(required=True, type='list', elements='dict'),
|
local=dict(required=True, type='list', elements='dict'),
|
||||||
remote=dict(required=True, type='list', elements='dict')
|
remote=dict(required=True, type='list', elements='dict')
|
||||||
)),
|
)),
|
||||||
|
schema_version=dict(default=None),
|
||||||
state=dict(default='present', choices=['absent', 'present']),
|
state=dict(default='present', choices=['absent', 'present']),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -155,7 +167,7 @@ class IdentityFederationMappingModule(OpenStackModule):
|
|||||||
if len(self.params['rules']) < 1:
|
if len(self.params['rules']) < 1:
|
||||||
self.fail_json(msg='At least one rule must be passed')
|
self.fail_json(msg='At least one rule must be passed')
|
||||||
|
|
||||||
attributes = dict((k, self.params[k]) for k in ['rules']
|
attributes = dict((k, self.params[k]) for k in ['rules', 'schema_version']
|
||||||
if k in self.params and self.params[k] is not None
|
if k in self.params and self.params[k] is not None
|
||||||
and self.params[k] != mapping[k])
|
and self.params[k] != mapping[k])
|
||||||
|
|
||||||
@@ -166,7 +178,8 @@ class IdentityFederationMappingModule(OpenStackModule):
|
|||||||
|
|
||||||
def _create(self):
|
def _create(self):
|
||||||
return self.conn.identity.create_mapping(id=self.params['name'],
|
return self.conn.identity.create_mapping(id=self.params['name'],
|
||||||
rules=self.params['rules'])
|
rules=self.params['rules'],
|
||||||
|
schema_version=self.params['schema_version'])
|
||||||
|
|
||||||
def _delete(self, mapping):
|
def _delete(self, mapping):
|
||||||
self.conn.identity.delete_mapping(mapping.id)
|
self.conn.identity.delete_mapping(mapping.id)
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ description:
|
|||||||
options:
|
options:
|
||||||
fixed_address:
|
fixed_address:
|
||||||
description:
|
description:
|
||||||
- To which fixed IP of server the floating IP address should be
|
- To which fixed IP of attached port the floating IP address should be
|
||||||
attached to.
|
attached to.
|
||||||
|
aliases: ["fixed_ip_address"]
|
||||||
type: str
|
type: str
|
||||||
floating_ip_address:
|
floating_ip_address:
|
||||||
description:
|
description:
|
||||||
@@ -35,6 +36,7 @@ options:
|
|||||||
network:
|
network:
|
||||||
description:
|
description:
|
||||||
- The name or ID of a neutron external network or a nova pool name.
|
- The name or ID of a neutron external network or a nova pool name.
|
||||||
|
- When I(server) is not defined, I(network) is required
|
||||||
type: str
|
type: str
|
||||||
purge:
|
purge:
|
||||||
description:
|
description:
|
||||||
@@ -57,7 +59,6 @@ options:
|
|||||||
description:
|
description:
|
||||||
- The name or ID of the server to which the IP address
|
- The name or ID of the server to which the IP address
|
||||||
should be assigned.
|
should be assigned.
|
||||||
required: true
|
|
||||||
type: str
|
type: str
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
@@ -183,23 +184,24 @@ from ansible_collections.openstack.cloud.plugins.module_utils.openstack import O
|
|||||||
|
|
||||||
class NetworkingFloatingIPModule(OpenStackModule):
|
class NetworkingFloatingIPModule(OpenStackModule):
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
fixed_address=dict(),
|
fixed_address=dict(aliases=['fixed_ip_address']),
|
||||||
floating_ip_address=dict(),
|
floating_ip_address=dict(),
|
||||||
nat_destination=dict(aliases=['fixed_network', 'internal_network']),
|
nat_destination=dict(aliases=['fixed_network', 'internal_network']),
|
||||||
network=dict(),
|
network=dict(),
|
||||||
purge=dict(type='bool', default=False),
|
purge=dict(type='bool', default=False),
|
||||||
reuse=dict(type='bool', default=False),
|
reuse=dict(type='bool', default=False),
|
||||||
server=dict(required=True),
|
server=dict(),
|
||||||
state=dict(default='present', choices=['absent', 'present']),
|
state=dict(default='present', choices=['absent', 'present']),
|
||||||
)
|
)
|
||||||
|
|
||||||
module_kwargs = dict(
|
module_kwargs = dict(
|
||||||
required_if=[
|
required_if=[
|
||||||
['state', 'absent', ['floating_ip_address']]
|
['state', 'present', ['server', 'network'], True],
|
||||||
|
['state', 'absent', ['floating_ip_address'], False],
|
||||||
],
|
],
|
||||||
required_by={
|
required_by={
|
||||||
'floating_ip_address': ('network'),
|
'floating_ip_address': ('network'),
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@@ -214,64 +216,36 @@ class NetworkingFloatingIPModule(OpenStackModule):
|
|||||||
changed = False
|
changed = False
|
||||||
fixed_address = self.params['fixed_address']
|
fixed_address = self.params['fixed_address']
|
||||||
floating_ip_address = self.params['floating_ip_address']
|
floating_ip_address = self.params['floating_ip_address']
|
||||||
nat_destination_name_or_id = self.params['nat_destination']
|
nat_destination_id = (
|
||||||
|
self.nat_destination['id'] if self.nat_destination else None
|
||||||
|
)
|
||||||
network_id = self.network['id'] if self.network else None
|
network_id = self.network['id'] if self.network else None
|
||||||
|
server = self.server
|
||||||
|
|
||||||
ips = self._find_ips(
|
ips = self._find_ips(
|
||||||
server=self.server,
|
server=server,
|
||||||
floating_ip_address=floating_ip_address,
|
floating_ip_address=floating_ip_address,
|
||||||
network_id=network_id,
|
network_id=network_id,
|
||||||
fixed_address=fixed_address,
|
fixed_address=fixed_address,
|
||||||
nat_destination_name_or_id=nat_destination_name_or_id)
|
nat_destination_id=nat_destination_id
|
||||||
|
)
|
||||||
|
|
||||||
# First floating ip satisfies our requirements
|
ip = None
|
||||||
ip = ips[0] if ips else None
|
|
||||||
|
|
||||||
|
if not ips:
|
||||||
|
if server:
|
||||||
if floating_ip_address:
|
if floating_ip_address:
|
||||||
# A specific floating ip address has been requested
|
# Requested floating ip address does not exist
|
||||||
|
|
||||||
if not ip:
|
|
||||||
# If a specific floating ip address has been requested
|
|
||||||
# and it does not exist yet then create it
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
changed = True
|
|
||||||
|
|
||||||
else: # ip
|
|
||||||
# Requested floating ip address exists already
|
|
||||||
|
|
||||||
if ip.port_details and (ip.port_details['status'] == 'ACTIVE') \
|
|
||||||
and (floating_ip_address not in self._filter_ips(
|
|
||||||
self.server)):
|
|
||||||
# Floating ip address exists and has been attached
|
|
||||||
# but to a different server
|
|
||||||
|
|
||||||
# Requested ip has been attached to different server
|
|
||||||
self.fail_json(
|
|
||||||
msg="Floating ip {0} has been attached to different "
|
|
||||||
"server".format(floating_ip_address))
|
|
||||||
|
|
||||||
if not ip \
|
|
||||||
or floating_ip_address not in self._filter_ips(self.server):
|
|
||||||
# Requested floating ip address does not exist or has not been
|
|
||||||
# assigned to server
|
|
||||||
|
|
||||||
self.conn.add_ip_list(
|
self.conn.add_ip_list(
|
||||||
server=self.server,
|
server=server,
|
||||||
ips=[floating_ip_address],
|
ips=[floating_ip_address],
|
||||||
wait=self.params['wait'],
|
wait=self.params['wait'],
|
||||||
timeout=self.params['timeout'],
|
timeout=self.params['timeout'],
|
||||||
fixed_address=fixed_address)
|
fixed_address=fixed_address
|
||||||
|
)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
|
||||||
# Requested floating ip address has been assigned to server
|
|
||||||
pass
|
|
||||||
|
|
||||||
elif not ips: # and not floating_ip_address
|
else:
|
||||||
# No specific floating ip has been requested and none of the
|
# No specific floating ip has been requested and none of the
|
||||||
# floating ips which have been assigned to the server matches
|
# floating ips which have been assigned to the server matches
|
||||||
# requirements
|
# requirements
|
||||||
@@ -319,34 +293,97 @@ class NetworkingFloatingIPModule(OpenStackModule):
|
|||||||
# a6b0ece2821ea79330c4067100295f6bdcbe456e/openstack/cloud/
|
# a6b0ece2821ea79330c4067100295f6bdcbe456e/openstack/cloud/
|
||||||
# _floating_ip.py#L987
|
# _floating_ip.py#L987
|
||||||
self.conn.add_ips_to_server(
|
self.conn.add_ips_to_server(
|
||||||
server=self.server,
|
server=server,
|
||||||
ip_pool=network_id,
|
ip_pool=network_id,
|
||||||
ips=None, # No specific floating ip requested
|
ips=None, # No specific floating ip requested
|
||||||
reuse=self.params['reuse'],
|
reuse=self.params['reuse'],
|
||||||
fixed_address=fixed_address,
|
fixed_address=fixed_address,
|
||||||
wait=self.params['wait'],
|
wait=self.params['wait'],
|
||||||
timeout=self.params['timeout'],
|
timeout=self.params['timeout'],
|
||||||
nat_destination=nat_destination_name_or_id)
|
nat_destination=nat_destination_id
|
||||||
|
)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
else: # not server
|
||||||
|
kwargs = self._params_to_kwargs(
|
||||||
|
floating_ip_address,
|
||||||
|
network_id,
|
||||||
|
fixed_address,
|
||||||
|
self.nat_destination
|
||||||
|
)
|
||||||
|
|
||||||
|
# create the ip
|
||||||
|
ip = self.conn.network.create_ip(**kwargs)
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
else: # ips
|
||||||
|
ip = ips[0]
|
||||||
|
|
||||||
|
if server:
|
||||||
|
server_ips = self._filter_ips(server)
|
||||||
|
if ip.floating_ip_address not in server_ips:
|
||||||
|
port_details = ip.port_details
|
||||||
|
if (port_details
|
||||||
|
and port_details['status'] == 'ACTIVE'):
|
||||||
|
# Requested ip has been attached to different server
|
||||||
|
self.fail_json(
|
||||||
|
msg="Floating ip {0} has been attached to "
|
||||||
|
"different server".format(
|
||||||
|
floating_ip_address))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Found one or more floating ips which satisfy requirements
|
# Requested floating ip address has not been
|
||||||
|
# assigned to server
|
||||||
|
self.conn.add_ip_list(
|
||||||
|
server=server,
|
||||||
|
ips=[ip.floating_ip_address],
|
||||||
|
wait=self.params['wait'],
|
||||||
|
timeout=self.params['timeout'],
|
||||||
|
fixed_address=fixed_address
|
||||||
|
)
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
# floating ip is already assigned to the server
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if changed:
|
elif len(ips) > 1: # not server
|
||||||
|
self.fail_json(msg='Found more than one floating ip')
|
||||||
|
|
||||||
|
else:
|
||||||
|
kwargs = self._params_to_kwargs(
|
||||||
|
floating_ip_address,
|
||||||
|
network_id,
|
||||||
|
fixed_address,
|
||||||
|
self.nat_destination
|
||||||
|
)
|
||||||
|
for key, value in kwargs.items():
|
||||||
|
if ip[key] != value:
|
||||||
|
self.conn.network.update_ip(ip, **kwargs)
|
||||||
|
changed = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if changed and server:
|
||||||
# update server details such as addresses
|
# update server details such as addresses
|
||||||
self.server = self.conn.compute.get_server(self.server)
|
server = self.conn.compute.get_server(server)
|
||||||
|
|
||||||
# Update the floating ip resource
|
# Update the floating ip resource
|
||||||
ips = self._find_ips(
|
ips = self._find_ips(
|
||||||
self.server, floating_ip_address, network_id,
|
server,
|
||||||
fixed_address, nat_destination_name_or_id)
|
floating_ip_address,
|
||||||
|
network_id,
|
||||||
|
fixed_address,
|
||||||
|
nat_destination_id
|
||||||
|
)
|
||||||
|
|
||||||
# ips can be empty, e.g. when server has no private ipv4
|
# ips can be empty, e.g. when server has no private ipv4
|
||||||
# address to which a floating ip address can be attached
|
# address to which a floating ip address can be attached
|
||||||
|
ip = ips[0] if ips else None
|
||||||
|
|
||||||
self.exit_json(
|
self.exit_json(
|
||||||
changed=changed,
|
changed=changed,
|
||||||
floating_ip=ips[0].to_dict(computed=False) if ips else None)
|
floating_ip=ip.to_dict(computed=False)
|
||||||
|
)
|
||||||
|
|
||||||
def _detach_and_delete(self):
|
def _detach_and_delete(self):
|
||||||
ips = self._find_ips(
|
ips = self._find_ips(
|
||||||
@@ -354,7 +391,7 @@ class NetworkingFloatingIPModule(OpenStackModule):
|
|||||||
floating_ip_address=self.params['floating_ip_address'],
|
floating_ip_address=self.params['floating_ip_address'],
|
||||||
network_id=self.network['id'] if self.network else None,
|
network_id=self.network['id'] if self.network else None,
|
||||||
fixed_address=self.params['fixed_address'],
|
fixed_address=self.params['fixed_address'],
|
||||||
nat_destination_name_or_id=self.params['nat_destination'])
|
nat_destination_id=self.nat_destination['id'] if self.nat_destination else None)
|
||||||
|
|
||||||
if not ips:
|
if not ips:
|
||||||
# Nothing to detach
|
# Nothing to detach
|
||||||
@@ -362,19 +399,22 @@ class NetworkingFloatingIPModule(OpenStackModule):
|
|||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
for ip in ips:
|
for ip in ips:
|
||||||
|
if self.server:
|
||||||
if ip['fixed_ip_address']:
|
if ip['fixed_ip_address']:
|
||||||
# Silently ignore that ip might not be attached to server
|
# Silently ignore that ip might not be attached to server
|
||||||
#
|
#
|
||||||
# self.conn.network.update_ip(ip_id, port_id=None) does not
|
# self.conn.network.update_ip(ip_id, port_id=None) does not
|
||||||
# handle nova network but self.conn.detach_ip_from_server()
|
# handle nova network but self.conn.detach_ip_from_server()
|
||||||
# does so
|
# does so
|
||||||
self.conn.detach_ip_from_server(server_id=self.server['id'],
|
changed = self.conn.detach_ip_from_server(server_id=self.server['id'],
|
||||||
floating_ip_id=ip['id'])
|
floating_ip_id=ip['id'])
|
||||||
|
|
||||||
# OpenStackSDK sets {"port_id": None} to detach a floating
|
# OpenStackSDK sets {"port_id": None} to detach a floating
|
||||||
# ip from a device, but there might be a delay until a
|
# ip from a device, but there might be a delay until a
|
||||||
# server does not list it in addresses any more.
|
# server does not list it in addresses any more.
|
||||||
|
else: # not self.server
|
||||||
|
if ip['port_id']:
|
||||||
changed = True
|
changed = True
|
||||||
|
self.conn.network.update_ip(floating_ip=ip['id'], port_id=None)
|
||||||
|
|
||||||
if self.params['purge']:
|
if self.params['purge']:
|
||||||
self.conn.network.delete_ip(ip['id'])
|
self.conn.network.delete_ip(ip['id'])
|
||||||
@@ -397,39 +437,56 @@ class NetworkingFloatingIPModule(OpenStackModule):
|
|||||||
|
|
||||||
# Returns a list not an iterator here because
|
# Returns a list not an iterator here because
|
||||||
# it is iterated several times below
|
# it is iterated several times below
|
||||||
return [address['addr']
|
addresses = _flatten(server['addresses'].values())
|
||||||
for address in _flatten(server['addresses'].values())
|
return [
|
||||||
if address['OS-EXT-IPS:type'] == 'floating']
|
address['addr']
|
||||||
|
for address in addresses
|
||||||
|
if address['OS-EXT-IPS:type'] == 'floating'
|
||||||
|
]
|
||||||
|
|
||||||
def _find_ips(self,
|
def _find_ips(self,
|
||||||
server,
|
server,
|
||||||
floating_ip_address,
|
floating_ip_address,
|
||||||
network_id,
|
network_id,
|
||||||
fixed_address,
|
fixed_address,
|
||||||
nat_destination_name_or_id):
|
nat_destination_id):
|
||||||
# Check which floating ips matches our requirements.
|
# Check which floating ips matches our requirements.
|
||||||
# They might or might not be attached to our server.
|
# They might or might not be attached to our server.
|
||||||
if floating_ip_address:
|
if floating_ip_address:
|
||||||
# A specific floating ip address has been requested
|
# A specific floating ip address has been requested
|
||||||
ip = self.conn.network.find_ip(floating_ip_address)
|
ip = self.conn.network.find_ip(floating_ip_address)
|
||||||
return [ip] if ip else []
|
return [ip] if ip else []
|
||||||
elif (not fixed_address and nat_destination_name_or_id):
|
elif server:
|
||||||
|
if (not fixed_address and nat_destination_id):
|
||||||
# No specific floating ip and no specific fixed ip have been
|
# No specific floating ip and no specific fixed ip have been
|
||||||
# requested but a private network (nat_destination) has been
|
# requested but a private network (nat_destination) has been
|
||||||
# given where the floating ip should be attached to.
|
# given where the floating ip should be attached to.
|
||||||
return self._find_ips_by_nat_destination(
|
return self._find_ips_by_nat_destination(
|
||||||
server, nat_destination_name_or_id)
|
server, nat_destination_id)
|
||||||
else:
|
else:
|
||||||
# not floating_ip_address
|
# not floating_ip_address
|
||||||
# and (fixed_address or not nat_destination_name_or_id)
|
# and (fixed_address or not nat_destination_id)
|
||||||
|
|
||||||
# An analysis of all floating ips of server is required
|
# An analysis of all floating ips of server is required
|
||||||
return self._find_ips_by_network_id_and_fixed_address(
|
return self._find_ips_by_network_id_and_fixed_address(
|
||||||
server, fixed_address, network_id)
|
server, fixed_address, network_id)
|
||||||
|
elif fixed_address or nat_destination_id:
|
||||||
|
ports = self._find_ports_by_fixed_address_or_nat_destination(fixed_address, nat_destination_id)
|
||||||
|
|
||||||
|
floating_ips = []
|
||||||
|
for port in ports:
|
||||||
|
ips = list(self.conn.network.ips(port_id=port.id))
|
||||||
|
floating_ips.extend(ips)
|
||||||
|
|
||||||
|
return floating_ips
|
||||||
|
elif network_id:
|
||||||
|
return list(self.conn.network.ips(floating_network_id=network_id))
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
def _find_ips_by_nat_destination(self,
|
def _find_ips_by_nat_destination(self,
|
||||||
server,
|
server,
|
||||||
nat_destination_name_or_id):
|
nat_destination_id):
|
||||||
|
|
||||||
if not server['addresses']:
|
if not server['addresses']:
|
||||||
return None
|
return None
|
||||||
@@ -437,7 +494,7 @@ class NetworkingFloatingIPModule(OpenStackModule):
|
|||||||
# Check if we have any floating ip on
|
# Check if we have any floating ip on
|
||||||
# the given nat_destination network
|
# the given nat_destination network
|
||||||
nat_destination = self.conn.network.find_network(
|
nat_destination = self.conn.network.find_network(
|
||||||
nat_destination_name_or_id, ignore_missing=False)
|
nat_destination_id, ignore_missing=False)
|
||||||
|
|
||||||
fips_with_nat_destination = [
|
fips_with_nat_destination = [
|
||||||
addr for addr
|
addr for addr
|
||||||
@@ -467,7 +524,7 @@ class NetworkingFloatingIPModule(OpenStackModule):
|
|||||||
# match network of floating ip
|
# match network of floating ip
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not fixed_address: # and not nat_destination_name_or_id
|
if not fixed_address: # and not nat_destination_id
|
||||||
# Any floating ip will fullfil these requirements
|
# Any floating ip will fullfil these requirements
|
||||||
matching_ips.append(ip)
|
matching_ips.append(ip)
|
||||||
|
|
||||||
@@ -478,20 +535,84 @@ class NetworkingFloatingIPModule(OpenStackModule):
|
|||||||
|
|
||||||
return matching_ips
|
return matching_ips
|
||||||
|
|
||||||
|
def _params_to_kwargs(self,
|
||||||
|
floating_ip_address,
|
||||||
|
network_id,
|
||||||
|
fixed_address,
|
||||||
|
nat_destination):
|
||||||
|
kwargs = {}
|
||||||
|
|
||||||
|
kwargs['floating_network_id'] = network_id
|
||||||
|
|
||||||
|
if fixed_address:
|
||||||
|
# must indicate internal port identifier
|
||||||
|
ports = self._find_ports_by_fixed_address_or_nat_destination(
|
||||||
|
fixed_address, nat_destination
|
||||||
|
)
|
||||||
|
if len(ports) > 1:
|
||||||
|
self.fail_json(
|
||||||
|
msg='There are multiple subnets with the fixed ip '
|
||||||
|
'address {0}'.format(fixed_address)
|
||||||
|
)
|
||||||
|
elif len(ports) == 0:
|
||||||
|
self.fail_json(
|
||||||
|
msg='No port found with fixed ip address {0}'.format(
|
||||||
|
fixed_address)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
kwargs['fixed_ip_address'] = fixed_address
|
||||||
|
kwargs['port_id'] = ports[0].id
|
||||||
|
|
||||||
|
if floating_ip_address:
|
||||||
|
kwargs['floating_ip_address'] = floating_ip_address
|
||||||
|
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
def _find_ports_by_fixed_address_or_nat_destination(self,
|
||||||
|
fixed_address,
|
||||||
|
nat_destination):
|
||||||
|
port_kwargs = {}
|
||||||
|
|
||||||
|
if fixed_address:
|
||||||
|
port_kwargs['fixed_ips'] = f'ip_address={fixed_address}'
|
||||||
|
if nat_destination:
|
||||||
|
port_kwargs['network_id'] = nat_destination.id
|
||||||
|
|
||||||
|
ports = self.conn.network.ports(**port_kwargs)
|
||||||
|
return list(ports)
|
||||||
|
|
||||||
def _init(self):
|
def _init(self):
|
||||||
server_name_or_id = self.params['server']
|
server_name_or_id = self.params['server']
|
||||||
server = self.conn.compute.find_server(server_name_or_id,
|
if server_name_or_id:
|
||||||
ignore_missing=False)
|
self.server = self.conn.compute.find_server(
|
||||||
# fetch server details such as addresses
|
name_or_id=server_name_or_id, ignore_missing=False
|
||||||
self.server = self.conn.compute.get_server(server)
|
)
|
||||||
|
else:
|
||||||
|
self.server = None
|
||||||
|
|
||||||
|
if (self.server is None and self.params['fixed_address']
|
||||||
|
and self.params['nat_destination'] is None):
|
||||||
|
self.fail_json(
|
||||||
|
msg='fixed_address requires nat_destination to be defined '
|
||||||
|
'when server isn\'t'
|
||||||
|
)
|
||||||
|
|
||||||
network_name_or_id = self.params['network']
|
network_name_or_id = self.params['network']
|
||||||
if network_name_or_id:
|
if network_name_or_id:
|
||||||
self.network = self.conn.network.find_network(
|
self.network = self.conn.network.find_network(
|
||||||
name_or_id=network_name_or_id, ignore_missing=False)
|
name_or_id=network_name_or_id, ignore_missing=False
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.network = None
|
self.network = None
|
||||||
|
|
||||||
|
nat_destination_name_or_id = self.params['nat_destination']
|
||||||
|
if nat_destination_name_or_id:
|
||||||
|
self.nat_destination = self.conn.network.find_network(
|
||||||
|
name_or_id=nat_destination_name_or_id, ignore_missing=False
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.nat_destination = None
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = NetworkingFloatingIPModule()
|
module = NetworkingFloatingIPModule()
|
||||||
|
|||||||
107
plugins/modules/host_aggregate_info.py
Normal file
107
plugins/modules/host_aggregate_info.py
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (c) 2025 OpenStack Ansible SIG
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
DOCUMENTATION = r'''
|
||||||
|
---
|
||||||
|
module: host_aggregate_info
|
||||||
|
short_description: Fetch OpenStack host aggregates
|
||||||
|
author: OpenStack Ansible SIG
|
||||||
|
description:
|
||||||
|
- Fetch OpenStack host aggregates.
|
||||||
|
options:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Name or ID of the aggregate.
|
||||||
|
- Returns only the matching aggregate when set.
|
||||||
|
type: str
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- openstack.cloud.openstack
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = r'''
|
||||||
|
- name: Fetch all host aggregates
|
||||||
|
openstack.cloud.host_aggregate_info:
|
||||||
|
cloud: mycloud
|
||||||
|
|
||||||
|
- name: Fetch a specific host aggregate by name
|
||||||
|
openstack.cloud.host_aggregate_info:
|
||||||
|
cloud: mycloud
|
||||||
|
name: db_aggregate
|
||||||
|
'''
|
||||||
|
|
||||||
|
RETURN = r'''
|
||||||
|
aggregates:
|
||||||
|
description: List of dictionaries describing host aggregates.
|
||||||
|
returned: always
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
contains:
|
||||||
|
availability_zone:
|
||||||
|
description: Availability zone of the aggregate.
|
||||||
|
type: str
|
||||||
|
created_at:
|
||||||
|
description: The date and time when the resource was created.
|
||||||
|
type: str
|
||||||
|
deleted_at:
|
||||||
|
description: The date and time when the resource was deleted.
|
||||||
|
type: str
|
||||||
|
hosts:
|
||||||
|
description: List of hosts belonging to the aggregate.
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
id:
|
||||||
|
description: The UUID of the aggregate.
|
||||||
|
type: str
|
||||||
|
is_deleted:
|
||||||
|
description: Whether or not the resource is deleted.
|
||||||
|
type: bool
|
||||||
|
metadata:
|
||||||
|
description: Metadata attached to the aggregate.
|
||||||
|
type: dict
|
||||||
|
name:
|
||||||
|
description: Name of the aggregate.
|
||||||
|
type: str
|
||||||
|
updated_at:
|
||||||
|
description: The date and time when the resource was updated.
|
||||||
|
type: str
|
||||||
|
uuid:
|
||||||
|
description: UUID of the aggregate.
|
||||||
|
type: str
|
||||||
|
'''
|
||||||
|
|
||||||
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
||||||
|
|
||||||
|
|
||||||
|
class ComputeHostAggregateInfoModule(OpenStackModule):
|
||||||
|
argument_spec = dict(
|
||||||
|
name=dict(),
|
||||||
|
)
|
||||||
|
|
||||||
|
module_kwargs = dict(
|
||||||
|
supports_check_mode=True
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
name = self.params['name']
|
||||||
|
|
||||||
|
if name:
|
||||||
|
aggregate = self.conn.compute.find_aggregate(name)
|
||||||
|
aggregates = [aggregate] if aggregate else []
|
||||||
|
else:
|
||||||
|
aggregates = list(self.conn.compute.aggregates())
|
||||||
|
|
||||||
|
self.exit_json(changed=False,
|
||||||
|
aggregates=[a.to_dict(computed=False)
|
||||||
|
for a in aggregates])
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = ComputeHostAggregateInfoModule()
|
||||||
|
module()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -56,7 +56,7 @@ options:
|
|||||||
description:
|
description:
|
||||||
- When I(update_password) is C(always), then the password will always be
|
- When I(update_password) is C(always), then the password will always be
|
||||||
updated.
|
updated.
|
||||||
- When I(update_password) is C(on_create), the the password is only set
|
- When I(update_password) is C(on_create), then the password is only set
|
||||||
when creating a user.
|
when creating a user.
|
||||||
type: str
|
type: str
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ options:
|
|||||||
type: str
|
type: str
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Should the resource be present or absent.
|
- Should the resource be present, absent or inactive.
|
||||||
choices: [present, absent]
|
choices: [present, absent, inactive]
|
||||||
default: present
|
default: present
|
||||||
type: str
|
type: str
|
||||||
tags:
|
tags:
|
||||||
@@ -122,6 +122,26 @@ options:
|
|||||||
- I(volume) has been deprecated. Use module M(openstack.cloud.volume)
|
- I(volume) has been deprecated. Use module M(openstack.cloud.volume)
|
||||||
instead.
|
instead.
|
||||||
type: str
|
type: str
|
||||||
|
use_import:
|
||||||
|
description:
|
||||||
|
- Use the 'glance-direct' method of the interoperable image import mechanism.
|
||||||
|
- Should only be used when needed, such as when the user needs the cloud to
|
||||||
|
transform image format.
|
||||||
|
type: bool
|
||||||
|
import_method:
|
||||||
|
description:
|
||||||
|
- Method to use for importing the image. Not all deployments support all methods.
|
||||||
|
- Supports web-download or glance-download.
|
||||||
|
- copy-image is not supported with create actions.
|
||||||
|
- glance-direct is removed from the import method so use_import can be used in that case.
|
||||||
|
type: str
|
||||||
|
choices: [web-download, glance-download]
|
||||||
|
uri:
|
||||||
|
description:
|
||||||
|
- Required only if using the web-download import method.
|
||||||
|
- This url is where the data is made available to the Image service.
|
||||||
|
type: str
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- openstack.cloud.openstack
|
- openstack.cloud.openstack
|
||||||
'''
|
'''
|
||||||
@@ -147,7 +167,7 @@ EXAMPLES = r'''
|
|||||||
RETURN = r'''
|
RETURN = r'''
|
||||||
image:
|
image:
|
||||||
description: Dictionary describing the Glance image.
|
description: Dictionary describing the Glance image.
|
||||||
returned: On success when I(state) is C(present).
|
returned: On success when I(state) is C(present) or C(inactive).
|
||||||
type: dict
|
type: dict
|
||||||
contains:
|
contains:
|
||||||
id:
|
id:
|
||||||
@@ -388,15 +408,18 @@ class ImageModule(OpenStackModule):
|
|||||||
owner_domain=dict(aliases=['project_domain']),
|
owner_domain=dict(aliases=['project_domain']),
|
||||||
properties=dict(type='dict', default={}),
|
properties=dict(type='dict', default={}),
|
||||||
ramdisk=dict(),
|
ramdisk=dict(),
|
||||||
state=dict(default='present', choices=['absent', 'present']),
|
state=dict(default='present', choices=['absent', 'present', 'inactive']),
|
||||||
tags=dict(type='list', default=[], elements='str'),
|
tags=dict(type='list', default=[], elements='str'),
|
||||||
visibility=dict(choices=['public', 'private', 'shared', 'community']),
|
visibility=dict(choices=['public', 'private', 'shared', 'community']),
|
||||||
volume=dict(),
|
volume=dict(),
|
||||||
|
use_import=dict(type='bool'),
|
||||||
|
import_method=dict(choices=['web-download', 'glance-download']),
|
||||||
|
uri=dict()
|
||||||
)
|
)
|
||||||
|
|
||||||
module_kwargs = dict(
|
module_kwargs = dict(
|
||||||
mutually_exclusive=[
|
mutually_exclusive=[
|
||||||
('filename', 'volume'),
|
('filename', 'volume', 'uri'),
|
||||||
('visibility', 'is_public'),
|
('visibility', 'is_public'),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@@ -404,7 +427,8 @@ class ImageModule(OpenStackModule):
|
|||||||
# resource attributes obtainable directly from params
|
# resource attributes obtainable directly from params
|
||||||
attr_params = ('id', 'name', 'filename', 'disk_format',
|
attr_params = ('id', 'name', 'filename', 'disk_format',
|
||||||
'container_format', 'wait', 'timeout', 'is_public',
|
'container_format', 'wait', 'timeout', 'is_public',
|
||||||
'is_protected', 'min_disk', 'min_ram', 'volume', 'tags')
|
'is_protected', 'min_disk', 'min_ram', 'volume', 'tags',
|
||||||
|
'use_import', 'import_method', 'uri')
|
||||||
|
|
||||||
def _resolve_visibility(self):
|
def _resolve_visibility(self):
|
||||||
"""resolve a visibility value to be compatible with older versions"""
|
"""resolve a visibility value to be compatible with older versions"""
|
||||||
@@ -461,6 +485,28 @@ class ImageModule(OpenStackModule):
|
|||||||
|
|
||||||
return update_payload
|
return update_payload
|
||||||
|
|
||||||
|
def _wait_for_image_active(self, image):
|
||||||
|
if not self.params['wait']:
|
||||||
|
return image
|
||||||
|
|
||||||
|
return self.sdk.resource.wait_for_status(
|
||||||
|
self.conn.image,
|
||||||
|
image,
|
||||||
|
status='active',
|
||||||
|
failures=['error', 'deleted', 'killed'],
|
||||||
|
wait=self.params['timeout'],
|
||||||
|
attribute='status')
|
||||||
|
|
||||||
|
def _import_uploaded_image(self, image):
|
||||||
|
if not hasattr(self.conn.image, 'import_image'):
|
||||||
|
self.fail_json(
|
||||||
|
msg="The installed openstacksdk library does not support "
|
||||||
|
"image import operations required for images in the "
|
||||||
|
"'uploading' state.")
|
||||||
|
|
||||||
|
self.conn.image.import_image(image, method='glance-direct')
|
||||||
|
return self._wait_for_image_active(self.conn.get_image(image.id))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
changed = False
|
changed = False
|
||||||
image_name_or_id = self.params['id'] or self.params['name']
|
image_name_or_id = self.params['id'] or self.params['name']
|
||||||
@@ -485,7 +531,7 @@ class ImageModule(OpenStackModule):
|
|||||||
if image_name_or_id:
|
if image_name_or_id:
|
||||||
image = self.conn.get_image(
|
image = self.conn.get_image(
|
||||||
image_name_or_id,
|
image_name_or_id,
|
||||||
filters={(k, self.params[k])
|
filters={k: self.params[k]
|
||||||
for k in ['checksum'] if self.params[k] is not None})
|
for k in ['checksum'] if self.params[k] is not None})
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
@@ -502,6 +548,33 @@ class ImageModule(OpenStackModule):
|
|||||||
self.exit_json(changed=changed,
|
self.exit_json(changed=changed,
|
||||||
image=self._return_value(image.id))
|
image=self._return_value(image.id))
|
||||||
|
|
||||||
|
if image['status'] == 'deactivated':
|
||||||
|
self.conn.image.reactivate_image(image)
|
||||||
|
changed = True
|
||||||
|
elif image['status'] == 'queued':
|
||||||
|
if (
|
||||||
|
self.params['filename']
|
||||||
|
and hasattr(self.conn.image, 'stage_image')):
|
||||||
|
self.conn.image.stage_image(
|
||||||
|
image, filename=self.params['filename'])
|
||||||
|
changed = True
|
||||||
|
elif self.params['filename']:
|
||||||
|
with open(self.params['filename'], 'rb') as image_data:
|
||||||
|
self.conn.image.upload_image(
|
||||||
|
container_format=self.params['container_format'],
|
||||||
|
disk_format=self.params['disk_format'],
|
||||||
|
data=image_data,
|
||||||
|
id=image.id,
|
||||||
|
name=image.name)
|
||||||
|
changed = True
|
||||||
|
image = self.conn.get_image(image.id)
|
||||||
|
|
||||||
|
if image['status'] == 'uploading' and self.params['use_import']:
|
||||||
|
image = self._import_uploaded_image(image)
|
||||||
|
changed = True
|
||||||
|
elif image['status'] == 'importing':
|
||||||
|
image = self._wait_for_image_active(image)
|
||||||
|
|
||||||
update_payload = self._build_update(image)
|
update_payload = self._build_update(image)
|
||||||
|
|
||||||
if update_payload:
|
if update_payload:
|
||||||
@@ -517,6 +590,20 @@ class ImageModule(OpenStackModule):
|
|||||||
wait=self.params['wait'],
|
wait=self.params['wait'],
|
||||||
timeout=self.params['timeout'])
|
timeout=self.params['timeout'])
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
elif self.params['state'] == 'inactive' and image is not None:
|
||||||
|
if image['status'] == 'active':
|
||||||
|
self.conn.image.deactivate_image(image)
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
update_payload = self._build_update(image)
|
||||||
|
|
||||||
|
if update_payload:
|
||||||
|
self.conn.image.update_image(image.id, **update_payload)
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
self.exit_json(changed=changed, image=self._return_value(image.id))
|
||||||
|
|
||||||
self.exit_json(changed=changed)
|
self.exit_json(changed=changed)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ pool:
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = r'''
|
EXAMPLES = r'''
|
||||||
- name: Create a load-balander pool
|
- name: Create a load-balancer pool
|
||||||
openstack.cloud.lb_pool:
|
openstack.cloud.lb_pool:
|
||||||
cloud: mycloud
|
cloud: mycloud
|
||||||
lb_algorithm: ROUND_ROBIN
|
lb_algorithm: ROUND_ROBIN
|
||||||
@@ -151,7 +151,7 @@ EXAMPLES = r'''
|
|||||||
protocol: HTTP
|
protocol: HTTP
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Delete a load-balander pool
|
- name: Delete a load-balancer pool
|
||||||
openstack.cloud.lb_pool:
|
openstack.cloud.lb_pool:
|
||||||
cloud: mycloud
|
cloud: mycloud
|
||||||
name: test-pool
|
name: test-pool
|
||||||
|
|||||||
@@ -30,6 +30,15 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Whether this network is externally accessible.
|
- Whether this network is externally accessible.
|
||||||
type: bool
|
type: bool
|
||||||
|
is_default:
|
||||||
|
description:
|
||||||
|
- Whether this network is default network or not. This is only effective
|
||||||
|
with external networks.
|
||||||
|
type: bool
|
||||||
|
is_vlan_transparent:
|
||||||
|
description:
|
||||||
|
- Whether this network is vlan_transparent or not.
|
||||||
|
type: bool
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Indicate desired state of the resource.
|
- Indicate desired state of the resource.
|
||||||
@@ -74,6 +83,11 @@ options:
|
|||||||
Network will use Openstack defaults if this option is
|
Network will use Openstack defaults if this option is
|
||||||
not provided.
|
not provided.
|
||||||
type: str
|
type: str
|
||||||
|
tags:
|
||||||
|
description:
|
||||||
|
- A list of tags to set on the network
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- openstack.cloud.openstack
|
- openstack.cloud.openstack
|
||||||
'''
|
'''
|
||||||
@@ -190,6 +204,8 @@ class NetworkModule(OpenStackModule):
|
|||||||
shared=dict(type='bool'),
|
shared=dict(type='bool'),
|
||||||
admin_state_up=dict(type='bool'),
|
admin_state_up=dict(type='bool'),
|
||||||
external=dict(type='bool'),
|
external=dict(type='bool'),
|
||||||
|
is_default=dict(type='bool'),
|
||||||
|
is_vlan_transparent=dict(type='bool'),
|
||||||
provider_physical_network=dict(),
|
provider_physical_network=dict(),
|
||||||
provider_network_type=dict(),
|
provider_network_type=dict(),
|
||||||
provider_segmentation_id=dict(type='int'),
|
provider_segmentation_id=dict(type='int'),
|
||||||
@@ -197,7 +213,8 @@ class NetworkModule(OpenStackModule):
|
|||||||
project=dict(),
|
project=dict(),
|
||||||
port_security_enabled=dict(type='bool'),
|
port_security_enabled=dict(type='bool'),
|
||||||
mtu=dict(type='int', aliases=['mtu_size']),
|
mtu=dict(type='int', aliases=['mtu_size']),
|
||||||
dns_domain=dict()
|
dns_domain=dict(),
|
||||||
|
tags=dict(type='list', elements='str'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@@ -207,10 +224,13 @@ class NetworkModule(OpenStackModule):
|
|||||||
shared = self.params['shared']
|
shared = self.params['shared']
|
||||||
admin_state_up = self.params['admin_state_up']
|
admin_state_up = self.params['admin_state_up']
|
||||||
external = self.params['external']
|
external = self.params['external']
|
||||||
|
is_default = self.params['is_default']
|
||||||
|
is_vlan_transparent = self.params['is_vlan_transparent']
|
||||||
provider_physical_network = self.params['provider_physical_network']
|
provider_physical_network = self.params['provider_physical_network']
|
||||||
provider_network_type = self.params['provider_network_type']
|
provider_network_type = self.params['provider_network_type']
|
||||||
provider_segmentation_id = self.params['provider_segmentation_id']
|
provider_segmentation_id = self.params['provider_segmentation_id']
|
||||||
project = self.params['project']
|
project = self.params['project']
|
||||||
|
tags = self.params['tags']
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
for arg in ('port_security_enabled', 'mtu', 'dns_domain'):
|
for arg in ('port_security_enabled', 'mtu', 'dns_domain'):
|
||||||
@@ -244,6 +264,10 @@ class NetworkModule(OpenStackModule):
|
|||||||
kwargs["admin_state_up"] = admin_state_up
|
kwargs["admin_state_up"] = admin_state_up
|
||||||
if external is not None:
|
if external is not None:
|
||||||
kwargs["is_router_external"] = external
|
kwargs["is_router_external"] = external
|
||||||
|
if is_default is not None:
|
||||||
|
kwargs["is_default"] = is_default
|
||||||
|
if is_vlan_transparent is not None:
|
||||||
|
kwargs["is_vlan_transparent"] = is_vlan_transparent
|
||||||
|
|
||||||
if not net:
|
if not net:
|
||||||
net = self.conn.network.create_network(name=name, **kwargs)
|
net = self.conn.network.create_network(name=name, **kwargs)
|
||||||
@@ -287,6 +311,12 @@ class NetworkModule(OpenStackModule):
|
|||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
if tags is not None:
|
||||||
|
old_tags = self.conn.network.get_tags(net)
|
||||||
|
if set(old_tags) != set(tags):
|
||||||
|
self.conn.network.set_tags(net, tags)
|
||||||
|
changed = True
|
||||||
|
|
||||||
net = net.to_dict(computed=False)
|
net = net.to_dict(computed=False)
|
||||||
self.exit(changed=changed, network=net, id=net['id'])
|
self.exit(changed=changed, network=net, id=net['id'])
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
|
|||||||
184
plugins/modules/network_segment.py
Normal file
184
plugins/modules/network_segment.py
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (c) 2025 British Broadcasting Corporation
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
---
|
||||||
|
module: network_segment
|
||||||
|
short_description: Creates/removes network segments from OpenStack
|
||||||
|
author: OpenStack Ansible SIG
|
||||||
|
description:
|
||||||
|
- Add, update or remove network segments from OpenStack.
|
||||||
|
options:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Name to be assigned to the segment. Although Neutron allows for
|
||||||
|
non-unique segment names, this module enforces segment name
|
||||||
|
uniqueness.
|
||||||
|
required: true
|
||||||
|
type: str
|
||||||
|
description:
|
||||||
|
description:
|
||||||
|
- Description of the segment
|
||||||
|
type: str
|
||||||
|
network:
|
||||||
|
description:
|
||||||
|
- Name or id of the network to which the segment should be attached
|
||||||
|
type: str
|
||||||
|
network_type:
|
||||||
|
description:
|
||||||
|
- The type of physical network that maps to this segment resource.
|
||||||
|
type: str
|
||||||
|
physical_network:
|
||||||
|
description:
|
||||||
|
- The physical network where this segment object is implemented.
|
||||||
|
type: str
|
||||||
|
segmentation_id:
|
||||||
|
description:
|
||||||
|
- An isolated segment on the physical network. The I(network_type)
|
||||||
|
attribute defines the segmentation model. For example, if the
|
||||||
|
I(network_type) value is vlan, this ID is a vlan identifier. If
|
||||||
|
the I(network_type) value is gre, this ID is a gre key.
|
||||||
|
type: int
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- Indicate desired state of the resource.
|
||||||
|
choices: ['present', 'absent']
|
||||||
|
default: present
|
||||||
|
type: str
|
||||||
|
version_added: 2.6.0
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- openstack.cloud.openstack
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = '''
|
||||||
|
# Create a VLAN type network segment named 'segment1'.
|
||||||
|
- openstack.cloud.network_segment:
|
||||||
|
cloud: mycloud
|
||||||
|
name: segment1
|
||||||
|
network: my_network
|
||||||
|
network_type: vlan
|
||||||
|
segmentation_id: 2000
|
||||||
|
physical_network: my_physnet
|
||||||
|
state: present
|
||||||
|
'''
|
||||||
|
|
||||||
|
RETURN = '''
|
||||||
|
id:
|
||||||
|
description: Id of segment
|
||||||
|
returned: On success when segment exists.
|
||||||
|
type: str
|
||||||
|
network_segment:
|
||||||
|
description: Dictionary describing the network segment.
|
||||||
|
returned: On success when network segment exists.
|
||||||
|
type: dict
|
||||||
|
contains:
|
||||||
|
description:
|
||||||
|
description: Description
|
||||||
|
type: str
|
||||||
|
id:
|
||||||
|
description: Id
|
||||||
|
type: str
|
||||||
|
name:
|
||||||
|
description: Name
|
||||||
|
type: str
|
||||||
|
network_id:
|
||||||
|
description: Network Id
|
||||||
|
type: str
|
||||||
|
network_type:
|
||||||
|
description: Network type
|
||||||
|
type: str
|
||||||
|
physical_network:
|
||||||
|
description: Physical network
|
||||||
|
type: str
|
||||||
|
segmentation_id:
|
||||||
|
description: Segmentation Id
|
||||||
|
type: int
|
||||||
|
'''
|
||||||
|
|
||||||
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
||||||
|
|
||||||
|
|
||||||
|
class NetworkSegmentModule(OpenStackModule):
|
||||||
|
|
||||||
|
argument_spec = dict(
|
||||||
|
name=dict(required=True),
|
||||||
|
description=dict(),
|
||||||
|
network=dict(),
|
||||||
|
network_type=dict(),
|
||||||
|
physical_network=dict(),
|
||||||
|
segmentation_id=dict(type='int'),
|
||||||
|
state=dict(default='present', choices=['absent', 'present'])
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
|
||||||
|
state = self.params['state']
|
||||||
|
name = self.params['name']
|
||||||
|
network_name_or_id = self.params['network']
|
||||||
|
|
||||||
|
kwargs = {}
|
||||||
|
filters = {}
|
||||||
|
for arg in ('description', 'network_type', 'physical_network', 'segmentation_id'):
|
||||||
|
if self.params[arg] is not None:
|
||||||
|
kwargs[arg] = self.params[arg]
|
||||||
|
|
||||||
|
for arg in ('network_type', 'physical_network'):
|
||||||
|
if self.params[arg] is not None:
|
||||||
|
filters[arg] = self.params[arg]
|
||||||
|
|
||||||
|
if network_name_or_id:
|
||||||
|
network = self.conn.network.find_network(network_name_or_id,
|
||||||
|
ignore_missing=False,
|
||||||
|
**filters)
|
||||||
|
kwargs['network_id'] = network.id
|
||||||
|
filters['network_id'] = network.id
|
||||||
|
|
||||||
|
segment = self.conn.network.find_segment(name, **filters)
|
||||||
|
|
||||||
|
if state == 'present':
|
||||||
|
if not segment:
|
||||||
|
segment = self.conn.network.create_segment(name=name, **kwargs)
|
||||||
|
changed = True
|
||||||
|
else:
|
||||||
|
changed = False
|
||||||
|
update_kwargs = {}
|
||||||
|
|
||||||
|
# As the name is required and all other attributes cannot be
|
||||||
|
# changed (and appear in filters above), we only need to handle
|
||||||
|
# updates to the description here.
|
||||||
|
for arg in ["description"]:
|
||||||
|
if (
|
||||||
|
arg in kwargs
|
||||||
|
# ensure user wants something specific
|
||||||
|
and kwargs[arg] is not None
|
||||||
|
# and this is not what we have right now
|
||||||
|
and kwargs[arg] != segment[arg]
|
||||||
|
):
|
||||||
|
update_kwargs[arg] = kwargs[arg]
|
||||||
|
|
||||||
|
if update_kwargs:
|
||||||
|
segment = self.conn.network.update_segment(
|
||||||
|
segment.id, **update_kwargs
|
||||||
|
)
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
segment = segment.to_dict(computed=False)
|
||||||
|
self.exit(changed=changed, network_segment=segment, id=segment['id'])
|
||||||
|
elif state == 'absent':
|
||||||
|
if not segment:
|
||||||
|
self.exit(changed=False)
|
||||||
|
else:
|
||||||
|
self.conn.network.delete_segment(segment['id'])
|
||||||
|
self.exit(changed=True)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = NetworkSegmentModule()
|
||||||
|
module()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -65,6 +65,12 @@ options:
|
|||||||
- Required when creating or updating a RBAC policy rule, ignored when
|
- Required when creating or updating a RBAC policy rule, ignored when
|
||||||
deleting a policy.
|
deleting a policy.
|
||||||
type: str
|
type: str
|
||||||
|
target_all_project:
|
||||||
|
description:
|
||||||
|
- Whether all projects are targted for access.
|
||||||
|
- If this option set to true, C(target_project_id) is ignored.
|
||||||
|
type: bool
|
||||||
|
default: 'false'
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Whether the RBAC rule should be C(present) or C(absent).
|
- Whether the RBAC rule should be C(present) or C(absent).
|
||||||
@@ -145,6 +151,8 @@ from ansible_collections.openstack.cloud.plugins.module_utils.openstack import O
|
|||||||
|
|
||||||
|
|
||||||
class NeutronRBACPolicy(OpenStackModule):
|
class NeutronRBACPolicy(OpenStackModule):
|
||||||
|
all_project_symbol = '*'
|
||||||
|
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
action=dict(choices=['access_as_external', 'access_as_shared']),
|
action=dict(choices=['access_as_external', 'access_as_shared']),
|
||||||
id=dict(aliases=['policy_id']),
|
id=dict(aliases=['policy_id']),
|
||||||
@@ -153,17 +161,22 @@ class NeutronRBACPolicy(OpenStackModule):
|
|||||||
project_id=dict(),
|
project_id=dict(),
|
||||||
state=dict(default='present', choices=['absent', 'present']),
|
state=dict(default='present', choices=['absent', 'present']),
|
||||||
target_project_id=dict(),
|
target_project_id=dict(),
|
||||||
|
target_all_project=dict(type='bool', default=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
module_kwargs = dict(
|
module_kwargs = dict(
|
||||||
required_if=[
|
required_if=[
|
||||||
('state', 'present', ('target_project_id',)),
|
('state', 'present', ('target_project_id', 'target_all_project',), True),
|
||||||
('state', 'absent', ('id',)),
|
('state', 'absent', ('id',)),
|
||||||
],
|
],
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
target_all_project = self.params.get('target_all_project')
|
||||||
|
if target_all_project:
|
||||||
|
self.params['target_project_id'] = self.all_project_symbol
|
||||||
|
|
||||||
state = self.params['state']
|
state = self.params['state']
|
||||||
|
|
||||||
policy = self._find()
|
policy = self._find()
|
||||||
@@ -262,7 +275,7 @@ class NeutronRBACPolicy(OpenStackModule):
|
|||||||
|
|
||||||
return [p for p in policies
|
return [p for p in policies
|
||||||
if any(p[k] == self.params[k]
|
if any(p[k] == self.params[k]
|
||||||
for k in ['object_id', 'target_project_id'])]
|
for k in ['object_id'])]
|
||||||
|
|
||||||
def _update(self, policy, update):
|
def _update(self, policy, update):
|
||||||
attributes = update.get('attributes')
|
attributes = update.get('attributes')
|
||||||
|
|||||||
@@ -295,8 +295,11 @@ class ObjectModule(OpenStackModule):
|
|||||||
for k in ['data', 'filename']
|
for k in ['data', 'filename']
|
||||||
if self.params[k] is not None)
|
if self.params[k] is not None)
|
||||||
|
|
||||||
return self.conn.object_store.create_object(container_name, name,
|
object = self.conn.object_store.create_object(container_name, name,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
if not object:
|
||||||
|
object = self._find()
|
||||||
|
return object
|
||||||
|
|
||||||
def _delete(self, object):
|
def _delete(self, object):
|
||||||
container_name = self.params['container']
|
container_name = self.params['container']
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ class ContainerModule(OpenStackModule):
|
|||||||
if metadata is not None:
|
if metadata is not None:
|
||||||
# Swift metadata keys must be treated as case-insensitive
|
# Swift metadata keys must be treated as case-insensitive
|
||||||
old_metadata = dict((k.lower(), v)
|
old_metadata = dict((k.lower(), v)
|
||||||
for k, v in (container.metadata or {}))
|
for k, v in (container.metadata or {}).items())
|
||||||
new_metadata = dict((k, v) for k, v in metadata.items()
|
new_metadata = dict((k, v) for k, v in metadata.items()
|
||||||
if k.lower() not in old_metadata
|
if k.lower() not in old_metadata
|
||||||
or v != old_metadata[k.lower()])
|
or v != old_metadata[k.lower()])
|
||||||
|
|||||||
202
plugins/modules/object_containers_info.py
Normal file
202
plugins/modules/object_containers_info.py
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright (c) 2024 Catalyst Cloud Limited
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
DOCUMENTATION = r"""
|
||||||
|
---
|
||||||
|
module: object_containers_info
|
||||||
|
short_description: Fetch container info from the OpenStack Swift service.
|
||||||
|
author: OpenStack Ansible SIG
|
||||||
|
description:
|
||||||
|
- Fetch container info from the OpenStack Swift service.
|
||||||
|
options:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Name of the container
|
||||||
|
type: str
|
||||||
|
aliases: ["container"]
|
||||||
|
prefix:
|
||||||
|
description:
|
||||||
|
- Filter containers by prefix
|
||||||
|
type: str
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- openstack.cloud.openstack
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
- name: List all containers existing on the project
|
||||||
|
openstack.cloud.object_containers_info:
|
||||||
|
|
||||||
|
- name: Retrive a single container by name
|
||||||
|
openstack.cloud.object_containers_info:
|
||||||
|
name: test-container
|
||||||
|
|
||||||
|
- name: Retrieve and filter containers by prefix
|
||||||
|
openstack.cloud.object_containers_info:
|
||||||
|
prefix: test-
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = r"""
|
||||||
|
containers:
|
||||||
|
description: List of dictionaries describing matching containers.
|
||||||
|
returned: always
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
contains:
|
||||||
|
bytes:
|
||||||
|
description: The total number of bytes that are stored in Object Storage
|
||||||
|
for the container.
|
||||||
|
type: int
|
||||||
|
sample: 5449
|
||||||
|
bytes_used:
|
||||||
|
description: The count of bytes used in total.
|
||||||
|
type: int
|
||||||
|
sample: 5449
|
||||||
|
content_type:
|
||||||
|
description: The MIME type of the list of names.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
count:
|
||||||
|
description: The number of objects in the container.
|
||||||
|
type: int
|
||||||
|
sample: 1
|
||||||
|
history_location:
|
||||||
|
description: Enables versioning on the container.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
id:
|
||||||
|
description: The ID of the container. Equals I(name).
|
||||||
|
type: str
|
||||||
|
sample: "otc"
|
||||||
|
if_none_match:
|
||||||
|
description: "In combination with C(Expect: 100-Continue), specify an
|
||||||
|
C(If-None-Match: *) header to query whether the server
|
||||||
|
already has a copy of the object before any data is sent.
|
||||||
|
Only set when searching for a container by name."
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
is_content_type_detected:
|
||||||
|
description: If set to C(true), Object Storage guesses the content type
|
||||||
|
based on the file extension and ignores the value sent in
|
||||||
|
the Content-Type header, if present.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: bool
|
||||||
|
sample: null
|
||||||
|
is_newest:
|
||||||
|
description: If set to True, Object Storage queries all replicas to
|
||||||
|
return the most recent one. If you omit this header, Object
|
||||||
|
Storage responds faster after it finds one valid replica.
|
||||||
|
Because setting this header to True is more expensive for
|
||||||
|
the back end, use it only when it is absolutely needed.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: bool
|
||||||
|
sample: null
|
||||||
|
meta_temp_url_key:
|
||||||
|
description: The secret key value for temporary URLs. If not set,
|
||||||
|
this header is not returned by this operation.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
meta_temp_url_key_2:
|
||||||
|
description: A second secret key value for temporary URLs. If not set,
|
||||||
|
this header is not returned by this operation.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
name:
|
||||||
|
description: The name of the container.
|
||||||
|
type: str
|
||||||
|
sample: "otc"
|
||||||
|
object_count:
|
||||||
|
description: The number of objects.
|
||||||
|
type: int
|
||||||
|
sample: 1
|
||||||
|
read_ACL:
|
||||||
|
description: The ACL that grants read access. If not set, this header is
|
||||||
|
not returned by this operation.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
storage_policy:
|
||||||
|
description: Storage policy used by the container. It is not possible to
|
||||||
|
change policy of an existing container.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
sync_key:
|
||||||
|
description: The secret key for container synchronization. If not set,
|
||||||
|
this header is not returned by this operation.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
sync_to:
|
||||||
|
description: The destination for container synchronization. If not set,
|
||||||
|
this header is not returned by this operation.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
timestamp:
|
||||||
|
description: The timestamp of the transaction.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
versions_location:
|
||||||
|
description: Enables versioning on this container. The value is the name
|
||||||
|
of another container. You must UTF-8-encode and then
|
||||||
|
URL-encode the name before you include it in the header. To
|
||||||
|
disable versioning, set the header to an empty string.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
write_ACL:
|
||||||
|
description: The ACL that grants write access. If not set, this header is
|
||||||
|
not returned by this operation.
|
||||||
|
Only fetched when searching for a container by name.
|
||||||
|
type: str
|
||||||
|
sample: null
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
||||||
|
|
||||||
|
|
||||||
|
class ObjectContainersInfoModule(OpenStackModule):
|
||||||
|
argument_spec = dict(
|
||||||
|
name=dict(aliases=["container"]),
|
||||||
|
prefix=dict(),
|
||||||
|
)
|
||||||
|
|
||||||
|
module_kwargs = dict(
|
||||||
|
supports_check_mode=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
if self.params["name"]:
|
||||||
|
containers = [
|
||||||
|
(
|
||||||
|
self.conn.object_store.get_container_metadata(
|
||||||
|
self.params["name"],
|
||||||
|
).to_dict(computed=False)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
query = {}
|
||||||
|
if self.params["prefix"]:
|
||||||
|
query["prefix"] = self.params["prefix"]
|
||||||
|
containers = [
|
||||||
|
c.to_dict(computed=False)
|
||||||
|
for c in self.conn.object_store.containers(**query)
|
||||||
|
]
|
||||||
|
self.exit(changed=False, containers=containers)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = ObjectContainersInfoModule()
|
||||||
|
module()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -138,10 +138,11 @@ options:
|
|||||||
of I(no_security_groups): C(true)."
|
of I(no_security_groups): C(true)."
|
||||||
type: bool
|
type: bool
|
||||||
default: 'false'
|
default: 'false'
|
||||||
port_security_enabled:
|
is_port_security_enabled:
|
||||||
description:
|
description:
|
||||||
- Whether to enable or disable the port security on the network.
|
- Whether to enable or disable the port security on the network.
|
||||||
type: bool
|
type: bool
|
||||||
|
aliases: ['port_security_enabled']
|
||||||
security_groups:
|
security_groups:
|
||||||
description:
|
description:
|
||||||
- Security group(s) ID(s) or name(s) associated with the port.
|
- Security group(s) ID(s) or name(s) associated with the port.
|
||||||
@@ -479,7 +480,7 @@ class PortModule(OpenStackModule):
|
|||||||
name=dict(required=True),
|
name=dict(required=True),
|
||||||
network=dict(),
|
network=dict(),
|
||||||
no_security_groups=dict(default=False, type='bool'),
|
no_security_groups=dict(default=False, type='bool'),
|
||||||
port_security_enabled=dict(type='bool'),
|
is_port_security_enabled=dict(type='bool', aliases=['port_security_enabled']),
|
||||||
security_groups=dict(type='list', elements='str'),
|
security_groups=dict(type='list', elements='str'),
|
||||||
state=dict(default='present', choices=['absent', 'present']),
|
state=dict(default='present', choices=['absent', 'present']),
|
||||||
)
|
)
|
||||||
@@ -510,7 +511,7 @@ class PortModule(OpenStackModule):
|
|||||||
**(dict(network_id=network.id) if network else dict()))
|
**(dict(network_id=network.id) if network else dict()))
|
||||||
|
|
||||||
if self.ansible.check_mode:
|
if self.ansible.check_mode:
|
||||||
self.exit_json(changed=self._will_change(network, port, state))
|
self.exit_json(changed=self._will_change(port, state))
|
||||||
|
|
||||||
if state == 'present' and not port:
|
if state == 'present' and not port:
|
||||||
# create port
|
# create port
|
||||||
@@ -655,7 +656,7 @@ class PortModule(OpenStackModule):
|
|||||||
'extra_dhcp_opts',
|
'extra_dhcp_opts',
|
||||||
'is_admin_state_up',
|
'is_admin_state_up',
|
||||||
'mac_address',
|
'mac_address',
|
||||||
'port_security_enabled',
|
'is_port_security_enabled',
|
||||||
'fixed_ips',
|
'fixed_ips',
|
||||||
'name']:
|
'name']:
|
||||||
if self.params[k] is not None:
|
if self.params[k] is not None:
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user