mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-05-08 14:23:03 +00:00
New Module: os_keystone_federation_protocol
Add support for Keystone federation Protocols Depends-On: https://review.opendev.org/714431 Depends-On: https://review.opendev.org/713461 Change-Id: I6dff6cebe72106e601834976e369e08583391c55
This commit is contained in:
35
ci/roles/keystone_federation_protocol/defaults/main.yml
Normal file
35
ci/roles/keystone_federation_protocol/defaults/main.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
protocol_name: 'test-protocol'
|
||||
protocol_name_2: 'test-protocol-2'
|
||||
|
||||
# Minimal IDP definition
|
||||
idp_name: 'test-idp'
|
||||
idp_remote_ids:
|
||||
- 'https://auth.example.com/auth/realms/ExampleRealm'
|
||||
|
||||
# Minimal Domain definition
|
||||
domain_name: 'test-domain'
|
||||
|
||||
# Minimal Mapping definition
|
||||
mapping_name_1: 'ansible-test-mapping-1'
|
||||
mapping_name_2: 'ansible-test-mapping-2'
|
||||
mapping_rules_1:
|
||||
- local:
|
||||
- group:
|
||||
domain:
|
||||
name: example_domain
|
||||
name: example-group
|
||||
remote:
|
||||
- type: HTTP_OIDC_GROUPS
|
||||
any_one_of:
|
||||
- group1
|
||||
- group2
|
||||
mapping_rules_2:
|
||||
- local:
|
||||
- group:
|
||||
domain:
|
||||
name: example_domain
|
||||
name: example_group
|
||||
remote:
|
||||
- type: HTTP_OIDC_GROUPS
|
||||
any_one_of:
|
||||
- group1
|
||||
393
ci/roles/keystone_federation_protocol/tasks/main.yml
Normal file
393
ci/roles/keystone_federation_protocol/tasks/main.yml
Normal file
@@ -0,0 +1,393 @@
|
||||
---
|
||||
# General run of tests
|
||||
# - Make change - Check mode
|
||||
# - Make change
|
||||
# - Retry change (noop) - Check mode
|
||||
# - Retry change (noop)
|
||||
#
|
||||
- module_defaults:
|
||||
# meta/action_groups.yml glue seems to be missing
|
||||
# group/os:
|
||||
# cloud: "{{ cloud }}"
|
||||
openstack.cloud.os_keystone_domain:
|
||||
cloud: "{{ cloud }}"
|
||||
openstack.cloud.os_keystone_identity_provider:
|
||||
cloud: "{{ cloud }}"
|
||||
openstack.cloud.os_keystone_mapping:
|
||||
cloud: "{{ cloud }}"
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
cloud: "{{ cloud }}"
|
||||
idp_id: "{{ idp_name }}"
|
||||
#openstack.cloud.os_keystone_federation_protocol_info:
|
||||
# cloud: "{{ cloud }}"
|
||||
# idp_id: "{{ idp_name }}"
|
||||
block:
|
||||
# ========================================================================
|
||||
# Initial setup
|
||||
- name: 'Create test Domain'
|
||||
openstack.cloud.os_keystone_domain:
|
||||
name: '{{ domain_name }}'
|
||||
register: create_domain
|
||||
- assert:
|
||||
that:
|
||||
- create_domain is successful
|
||||
- '"id" in create_domain'
|
||||
- name: 'Store domain ID as fact'
|
||||
set_fact:
|
||||
domain_id: '{{ create_domain.id }}'
|
||||
|
||||
- name: 'Create test Identity Provider'
|
||||
openstack.cloud.os_keystone_identity_provider:
|
||||
state: 'present'
|
||||
name: '{{ idp_name }}'
|
||||
domain_id: '{{ domain_id }}'
|
||||
register: create_idp
|
||||
- assert:
|
||||
that:
|
||||
- create_idp is successful
|
||||
|
||||
- name: 'Create test mapping (1)'
|
||||
openstack.cloud.os_keystone_mapping:
|
||||
state: 'present'
|
||||
name: '{{ mapping_name_1 }}'
|
||||
rules: '{{ mapping_rules_1 }}'
|
||||
register: create_mapping
|
||||
- assert:
|
||||
that:
|
||||
- create_mapping is successful
|
||||
- name: 'Create test mapping (2)'
|
||||
openstack.cloud.os_keystone_mapping:
|
||||
state: 'present'
|
||||
name: '{{ mapping_name_2 }}'
|
||||
rules: '{{ mapping_rules_2 }}'
|
||||
register: create_mapping
|
||||
- assert:
|
||||
that:
|
||||
- create_mapping is successful
|
||||
|
||||
# We *should* have a blank slate to start with, but we also shouldn't
|
||||
# explode if I(state=absent) and the IDP doesn't exist
|
||||
- name: "Ensure Protocol doesn't exist to start"
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'absent'
|
||||
name: '{{ protocol_name }}'
|
||||
register: delete_protocol
|
||||
- assert:
|
||||
that:
|
||||
- delete_protocol is successful
|
||||
|
||||
# ========================================================================
|
||||
# Creation
|
||||
|
||||
- name: 'Create protocol - CHECK MODE'
|
||||
check_mode: yes
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'present'
|
||||
name: '{{ protocol_name }}'
|
||||
mapping_id: '{{ mapping_name_1 }}'
|
||||
register: create_protocol
|
||||
- assert:
|
||||
that:
|
||||
- create_protocol is successful
|
||||
- create_protocol is changed
|
||||
|
||||
#- name: 'Fetch Protocol info (should be absent)'
|
||||
# openstack.cloud.os_keystone_federation_protocol_info:
|
||||
# name: '{{ protocol_name }}'
|
||||
# register: protocol_info
|
||||
# ignore_errors: yes
|
||||
#- assert:
|
||||
# that:
|
||||
# - protocol_info is failed
|
||||
|
||||
- name: 'Create protocol'
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'present'
|
||||
name: '{{ protocol_name }}'
|
||||
mapping_id: '{{ mapping_name_1 }}'
|
||||
register: create_protocol
|
||||
- assert:
|
||||
that:
|
||||
- create_protocol is successful
|
||||
- create_protocol is changed
|
||||
- '"protocol" in create_protocol'
|
||||
- '"id" in protocol'
|
||||
- '"name" in protocol'
|
||||
- '"idp_id" in protocol'
|
||||
- '"mapping_id" in protocol'
|
||||
- protocol.id == protocol_name
|
||||
- protocol.name == protocol_name
|
||||
- protocol.idp_id == idp_name
|
||||
- protocol.mapping_id == mapping_name_1
|
||||
vars:
|
||||
protocol: '{{ create_protocol.protocol }}'
|
||||
|
||||
- name: 'Create protocol (retry - no change) - CHECK MODE'
|
||||
check_mode: yes
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'present'
|
||||
name: '{{ protocol_name }}'
|
||||
mapping_id: '{{ mapping_name_1 }}'
|
||||
register: create_protocol
|
||||
- assert:
|
||||
that:
|
||||
- create_protocol is successful
|
||||
- create_protocol is not changed
|
||||
|
||||
- name: 'Create protocol (retry - no change)'
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'present'
|
||||
name: '{{ protocol_name }}'
|
||||
mapping_id: '{{ mapping_name_1 }}'
|
||||
register: create_protocol
|
||||
- assert:
|
||||
that:
|
||||
- create_protocol is successful
|
||||
- create_protocol is not changed
|
||||
- '"protocol" in create_protocol'
|
||||
- '"id" in protocol'
|
||||
- '"name" in protocol'
|
||||
- '"idp_id" in protocol'
|
||||
- '"mapping_id" in protocol'
|
||||
- protocol.id == protocol_name
|
||||
- protocol.name == protocol_name
|
||||
- protocol.idp_id == idp_name
|
||||
- protocol.mapping_id == mapping_name_1
|
||||
vars:
|
||||
protocol: '{{ create_protocol.protocol }}'
|
||||
|
||||
# ========================================================================
|
||||
# Update
|
||||
|
||||
- name: 'Update protocol - CHECK MODE'
|
||||
check_mode: yes
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'present'
|
||||
name: '{{ protocol_name }}'
|
||||
mapping_id: '{{ mapping_name_2 }}'
|
||||
register: update_protocol
|
||||
- assert:
|
||||
that:
|
||||
- update_protocol is successful
|
||||
- update_protocol is changed
|
||||
|
||||
- name: 'Update protocol'
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'present'
|
||||
name: '{{ protocol_name }}'
|
||||
mapping_id: '{{ mapping_name_2 }}'
|
||||
register: update_protocol
|
||||
- assert:
|
||||
that:
|
||||
- update_protocol is successful
|
||||
- update_protocol is changed
|
||||
- '"protocol" in update_protocol'
|
||||
- '"id" in protocol'
|
||||
- '"name" in protocol'
|
||||
- '"idp_id" in protocol'
|
||||
- '"mapping_id" in protocol'
|
||||
- protocol.id == protocol_name
|
||||
- protocol.name == protocol_name
|
||||
- protocol.idp_id == idp_name
|
||||
- protocol.mapping_id == mapping_name_2
|
||||
vars:
|
||||
protocol: '{{ update_protocol.protocol }}'
|
||||
|
||||
- name: 'Update protocol (retry - no change) - CHECK MODE'
|
||||
check_mode: yes
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'present'
|
||||
name: '{{ protocol_name }}'
|
||||
mapping_id: '{{ mapping_name_2 }}'
|
||||
register: update_protocol
|
||||
- assert:
|
||||
that:
|
||||
- update_protocol is successful
|
||||
- update_protocol is not changed
|
||||
|
||||
- name: 'Update protocol (retry - no change)'
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'present'
|
||||
name: '{{ protocol_name }}'
|
||||
mapping_id: '{{ mapping_name_2 }}'
|
||||
register: update_protocol
|
||||
- assert:
|
||||
that:
|
||||
- update_protocol is successful
|
||||
- update_protocol is not changed
|
||||
- '"protocol" in update_protocol'
|
||||
- '"id" in protocol'
|
||||
- '"name" in protocol'
|
||||
- '"idp_id" in protocol'
|
||||
- '"mapping_id" in protocol'
|
||||
- protocol.id == protocol_name
|
||||
- protocol.name == protocol_name
|
||||
- protocol.idp_id == idp_name
|
||||
- protocol.mapping_id == mapping_name_2
|
||||
vars:
|
||||
protocol: '{{ update_protocol.protocol }}'
|
||||
|
||||
# ========================================================================
|
||||
# Create second protocol to test os_keystone_federation_protocol_info
|
||||
|
||||
- name: 'Create protocol (2)'
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'present'
|
||||
name: '{{ protocol_name_2 }}'
|
||||
mapping_id: '{{ mapping_name_1 }}'
|
||||
register: create_protocol_2
|
||||
- assert:
|
||||
that:
|
||||
- create_protocol_2 is successful
|
||||
- create_protocol_2 is changed
|
||||
- '"protocol" in create_protocol_2'
|
||||
- '"id" in protocol'
|
||||
- '"name" in protocol'
|
||||
- '"idp_id" in protocol'
|
||||
- '"mapping_id" in protocol'
|
||||
- protocol.id == protocol_name_2
|
||||
- protocol.name == protocol_name_2
|
||||
- protocol.idp_id == idp_name
|
||||
- protocol.mapping_id == mapping_name_1
|
||||
vars:
|
||||
protocol: '{{ create_protocol_2.protocol }}'
|
||||
|
||||
# ========================================================================
|
||||
# Basic tests of os_keystone_federation_protocol_info
|
||||
|
||||
#- name: 'Fetch Protocol info (a specific protocol)'
|
||||
# openstack.cloud.os_keystone_federation_protocol_info:
|
||||
# name: '{{ protocol_name }}'
|
||||
# register: protocol_info
|
||||
#- assert:
|
||||
# that:
|
||||
# - protocol_info is successful
|
||||
# - '"protocols" in protocol_info'
|
||||
# - protocol_info.protocols | length == 1
|
||||
# - '"id" in protocol'
|
||||
# - '"name" in protocol'
|
||||
# - '"idp_id" in protocol'
|
||||
# - '"mapping_id" in protocol'
|
||||
# - protocol.id == protocol_name
|
||||
# - protocol.name == protocol_name
|
||||
# - protocol.idp_id == idp_name
|
||||
# - protocol.mapping_id == mapping_name_2
|
||||
# vars:
|
||||
# protocol: '{{ protocol_info.protocols[0] }}'
|
||||
|
||||
#- name: 'Fetch Protocol info (all protocols on our test IDP)'
|
||||
# openstack.cloud.os_keystone_federation_protocol_info: {}
|
||||
# # idp_id defined in defaults at the start
|
||||
# register: protocol_info
|
||||
#- assert:
|
||||
# that:
|
||||
# - protocol_info is successful
|
||||
# - '"protocols" in protocol_info'
|
||||
# # We created the IDP, and we're going to delete it:
|
||||
# # we should be able to trust what's attached to it
|
||||
# - protocol_info.protocols | length == 2
|
||||
# - '"id" in protocol_1'
|
||||
# - '"name" in protocol_1'
|
||||
# - '"idp_id" in protocol_1'
|
||||
# - '"mapping_id" in protocol_1'
|
||||
# - '"id" in protocol_2'
|
||||
# - '"name" in protocol_2'
|
||||
# - '"idp_id" in protocol_2'
|
||||
# - '"mapping_id" in protocol_2'
|
||||
# - protocol_name in (protocol_info.protocols | map(attribute='id'))
|
||||
# - protocol_name in (protocol_info.protocols | map(attribute='id'))
|
||||
# - protocol_name_2 in (protocol_info.protocols | map(attribute='name'))
|
||||
# - protocol_name_2 in (protocol_info.protocols | map(attribute='name'))
|
||||
# - mapping_name_1 in (protocol_info.protocols | map(attribute='mapping_id'))
|
||||
# - mapping_name_2 in (protocol_info.protocols | map(attribute='mapping_id'))
|
||||
# - protocol_1.idp_id == idp_name
|
||||
# - protocol_2.idp_id == idp_name
|
||||
# vars:
|
||||
# protocol_1: '{{ protocol_info.protocols[0] }}'
|
||||
# protocol_2: '{{ protocol_info.protocols[1] }}'
|
||||
|
||||
# ========================================================================
|
||||
# Deletion
|
||||
|
||||
- name: 'Delete protocol - CHECK MODE'
|
||||
check_mode: yes
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'absent'
|
||||
name: '{{ protocol_name }}'
|
||||
register: update_protocol
|
||||
- assert:
|
||||
that:
|
||||
- update_protocol is successful
|
||||
- update_protocol is changed
|
||||
|
||||
- name: 'Delete protocol'
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'absent'
|
||||
name: '{{ protocol_name }}'
|
||||
register: update_protocol
|
||||
- assert:
|
||||
that:
|
||||
- update_protocol is successful
|
||||
- update_protocol is changed
|
||||
|
||||
- name: 'Delete protocol (retry - no change) - CHECK MODE'
|
||||
check_mode: yes
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'absent'
|
||||
name: '{{ protocol_name }}'
|
||||
register: update_protocol
|
||||
- assert:
|
||||
that:
|
||||
- update_protocol is successful
|
||||
- update_protocol is not changed
|
||||
|
||||
- name: 'Delete protocol (retry - no change)'
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'absent'
|
||||
name: '{{ protocol_name }}'
|
||||
register: update_protocol
|
||||
- assert:
|
||||
that:
|
||||
- update_protocol is successful
|
||||
- update_protocol is not changed
|
||||
|
||||
# ========================================================================
|
||||
# Clean up after ourselves
|
||||
always:
|
||||
- name: 'Delete protocol'
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'absent'
|
||||
name: '{{ protocol_name }}'
|
||||
idp_id: '{{ idp_name }}'
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 'Delete protocol (2)'
|
||||
openstack.cloud.os_keystone_federation_protocol:
|
||||
state: 'absent'
|
||||
name: '{{ protocol_name_2 }}'
|
||||
idp_id: '{{ idp_name }}'
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 'Delete mapping 1'
|
||||
openstack.cloud.os_keystone_mapping:
|
||||
state: 'absent'
|
||||
name: '{{ mapping_name_1 }}'
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 'Delete mapping 2'
|
||||
openstack.cloud.os_keystone_mapping:
|
||||
state: 'absent'
|
||||
name: '{{ mapping_name_2 }}'
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 'Delete idp'
|
||||
openstack.cloud.os_keystone_identity_provider:
|
||||
state: 'absent'
|
||||
name: '{{ idp_name }}'
|
||||
ignore_errors: yes
|
||||
|
||||
- name: 'Delete domain'
|
||||
openstack.cloud.os_keystone_domain:
|
||||
state: 'absent'
|
||||
name: '{{ domain_name }}'
|
||||
ignore_errors: yes
|
||||
@@ -18,6 +18,9 @@
|
||||
- role: keystone_idp
|
||||
tags: keystone_idp
|
||||
when: sdk_version is version(0.44, '>=')
|
||||
- role: keystone_federation_protocol
|
||||
tags: keystone_federation_protocol
|
||||
when: sdk_version is version(0.44, '>=')
|
||||
- { role: keystone_role, tags: keystone_role }
|
||||
- { role: network, tags: network }
|
||||
- { role: nova_flavor, tags: nova_flavor }
|
||||
|
||||
Reference in New Issue
Block a user