1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #7897/afd19888 backport][stable-8] Consul action group (#7905)

Consul action group (#7897)

Added action group for new style consul modules.

(cherry picked from commit afd1988810)

Co-authored-by: Florian Apolloner <florian@apolloner.eu>
This commit is contained in:
patchback[bot] 2024-01-27 12:21:34 +01:00 committed by GitHub
parent 210adc196e
commit dc5f012e52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 39 additions and 47 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- consul_auth_method, consul_binding_rule, consul_policy, consul_role, consul_session, consul_token - added action group ``community.general.consul`` (https://github.com/ansible-collections/community.general/pull/7897).

View file

@ -4,6 +4,14 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
requires_ansible: '>=2.13.0' requires_ansible: '>=2.13.0'
action_groups:
consul:
- consul_auth_method
- consul_binding_rule
- consul_policy
- consul_role
- consul_session
- consul_token
plugin_routing: plugin_routing:
connection: connection:
docker: docker:

View file

@ -47,3 +47,14 @@ options:
- The token to use for authorization. - The token to use for authorization.
type: str type: str
""" """
ACTIONGROUP_CONSUL = r"""
options: {}
attributes:
action_group:
description: Use C(group/community.general.consul) in C(module_defaults) to set defaults for this module.
support: full
membership:
- community.general.consul
version_added: 8.3.0
"""

View file

@ -21,6 +21,7 @@ author:
- Florian Apolloner (@apollo13) - Florian Apolloner (@apollo13)
extends_documentation_fragment: extends_documentation_fragment:
- community.general.consul - community.general.consul
- community.general.consul.actiongroup_consul
- community.general.consul.token - community.general.consul.token
- community.general.attributes - community.general.attributes
attributes: attributes:

View file

@ -21,6 +21,7 @@ author:
- Florian Apolloner (@apollo13) - Florian Apolloner (@apollo13)
extends_documentation_fragment: extends_documentation_fragment:
- community.general.consul - community.general.consul
- community.general.consul.actiongroup_consul
- community.general.consul.token - community.general.consul.token
- community.general.attributes - community.general.attributes
attributes: attributes:

View file

@ -21,6 +21,7 @@ author:
- Håkon Lerring (@Hakon) - Håkon Lerring (@Hakon)
extends_documentation_fragment: extends_documentation_fragment:
- community.general.consul - community.general.consul
- community.general.consul.actiongroup_consul
- community.general.consul.token - community.general.consul.token
- community.general.attributes - community.general.attributes
attributes: attributes:

View file

@ -22,6 +22,7 @@ author:
extends_documentation_fragment: extends_documentation_fragment:
- community.general.consul - community.general.consul
- community.general.consul.token - community.general.consul.token
- community.general.consul.actiongroup_consul
- community.general.attributes - community.general.attributes
attributes: attributes:
check_mode: check_mode:

View file

@ -21,6 +21,7 @@ author:
- Håkon Lerring (@Hakon) - Håkon Lerring (@Hakon)
extends_documentation_fragment: extends_documentation_fragment:
- community.general.consul - community.general.consul
- community.general.consul.actiongroup_consul
- community.general.consul.token - community.general.consul.token
- community.general.attributes - community.general.attributes
attributes: attributes:

View file

@ -22,6 +22,7 @@ author:
extends_documentation_fragment: extends_documentation_fragment:
- community.general.consul - community.general.consul
- community.general.consul.token - community.general.consul.token
- community.general.consul.actiongroup_consul
- community.general.attributes - community.general.attributes
attributes: attributes:
check_mode: check_mode:

View file

@ -19,7 +19,6 @@
cKWTjpBP2dPwVZ4WWC+9aGVd+Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbc cKWTjpBP2dPwVZ4WWC+9aGVd+Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbc
mwIDAQAB mwIDAQAB
-----END PUBLIC KEY----- -----END PUBLIC KEY-----
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -32,7 +31,6 @@
community.general.consul_auth_method: community.general.consul_auth_method:
name: test name: test
max_token_ttl: 30m80s max_token_ttl: 30m80s
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -45,7 +43,6 @@
community.general.consul_auth_method: community.general.consul_auth_method:
name: test name: test
max_token_ttl: 30m80s max_token_ttl: 30m80s
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -58,7 +55,6 @@
community.general.consul_auth_method: community.general.consul_auth_method:
name: test name: test
state: absent state: absent
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -70,7 +66,6 @@
community.general.consul_auth_method: community.general.consul_auth_method:
name: test name: test
state: absent state: absent
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:

View file

@ -19,14 +19,12 @@
cKWTjpBP2dPwVZ4WWC+9aGVd+Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbc cKWTjpBP2dPwVZ4WWC+9aGVd+Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbc
mwIDAQAB mwIDAQAB
-----END PUBLIC KEY----- -----END PUBLIC KEY-----
token: "{{ consul_management_token }}"
- name: Create a binding rule - name: Create a binding rule
community.general.consul_binding_rule: community.general.consul_binding_rule:
name: test-binding name: test-binding
description: my description description: my description
auth_method: test auth_method: test
token: "{{ consul_management_token }}"
bind_type: service bind_type: service
bind_name: yolo bind_name: yolo
register: result register: result
@ -42,7 +40,6 @@
community.general.consul_binding_rule: community.general.consul_binding_rule:
name: test-binding name: test-binding
auth_method: test auth_method: test
token: "{{ consul_management_token }}"
bind_name: yolo2 bind_name: yolo2
register: result register: result
@ -56,7 +53,6 @@
community.general.consul_binding_rule: community.general.consul_binding_rule:
name: test-binding name: test-binding
auth_method: test auth_method: test
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -70,7 +66,6 @@
name: test-binding name: test-binding
auth_method: test auth_method: test
state: absent state: absent
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
that: that:

View file

@ -13,7 +13,6 @@
key "private/foo" { key "private/foo" {
policy = "deny" policy = "deny"
} }
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -35,7 +34,6 @@
event "bbq" { event "bbq" {
policy = "write" policy = "write"
} }
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -56,7 +54,6 @@
event "bbq" { event "bbq" {
policy = "write" policy = "write"
} }
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -67,7 +64,6 @@
- name: Remove a policy - name: Remove a policy
consul_policy: consul_policy:
name: foo-access name: foo-access
token: "{{ consul_management_token }}"
state: absent state: absent
register: result register: result
- assert: - assert:

View file

@ -13,7 +13,6 @@
key "private/foo" { key "private/foo" {
policy = "deny" policy = "deny"
} }
token: "{{ consul_management_token }}"
register: policy_result register: policy_result
- name: Create another policy with rules - name: Create another policy with rules
@ -26,7 +25,6 @@
key "private/bar" { key "private/bar" {
policy = "deny" policy = "deny"
} }
token: "{{ consul_management_token }}"
register: policy_result register: policy_result
- name: Create a role with policy - name: Create a role with policy
@ -34,7 +32,6 @@
name: foo-role-with-policy name: foo-role-with-policy
policies: policies:
- name: "foo-access-for-role" - name: "foo-access-for-role"
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -47,7 +44,6 @@
consul_role: consul_role:
name: foo-role-with-policy name: foo-role-with-policy
description: "Testing updating description" description: "Testing updating description"
token: "{{ consul_management_token }}"
check_mode: yes check_mode: yes
register: result register: result
@ -62,7 +58,6 @@
consul_role: consul_role:
name: foo-role-with-policy name: foo-role-with-policy
description: "Role for testing policies" description: "Role for testing policies"
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -78,7 +73,6 @@
policies: policies:
- name: "foo-access-for-role" - name: "foo-access-for-role"
- name: "bar-access-for-role" - name: "bar-access-for-role"
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -91,7 +85,6 @@
- name: Create a role with service identity - name: Create a role with service identity
consul_role: consul_role:
token: "{{ consul_management_token }}"
name: role-with-service-identity name: role-with-service-identity
service_identities: service_identities:
- name: web - name: web
@ -107,7 +100,6 @@
- name: Update the role with service identity in check mode - name: Update the role with service identity in check mode
consul_role: consul_role:
token: "{{ consul_management_token }}"
name: role-with-service-identity name: role-with-service-identity
service_identities: service_identities:
- name: web - name: web
@ -124,7 +116,6 @@
- name: Update the role with service identity to add a policy, leaving the service id unchanged - name: Update the role with service identity to add a policy, leaving the service id unchanged
consul_role: consul_role:
token: "{{ consul_management_token }}"
name: role-with-service-identity name: role-with-service-identity
policies: policies:
- name: "foo-access-for-role" - name: "foo-access-for-role"
@ -139,7 +130,6 @@
- name: Update the role with service identity to remove the policies - name: Update the role with service identity to remove the policies
consul_role: consul_role:
token: "{{ consul_management_token }}"
name: role-with-service-identity name: role-with-service-identity
policies: [] policies: []
register: result register: result
@ -153,7 +143,6 @@
- name: Update the role with service identity to remove the node identities, in check mode - name: Update the role with service identity to remove the node identities, in check mode
consul_role: consul_role:
token: "{{ consul_management_token }}"
name: role-with-service-identity name: role-with-service-identity
node_identities: [] node_identities: []
register: result register: result
@ -169,7 +158,6 @@
- name: Update the role with service identity to remove the service identities - name: Update the role with service identity to remove the service identities
consul_role: consul_role:
token: "{{ consul_management_token }}"
name: role-with-service-identity name: role-with-service-identity
service_identities: [] service_identities: []
register: result register: result
@ -182,7 +170,6 @@
- name: Create a role with node identity - name: Create a role with node identity
consul_role: consul_role:
token: "{{ consul_management_token }}"
name: role-with-node-identity name: role-with-node-identity
node_identities: node_identities:
- name: node-1 - name: node-1
@ -197,7 +184,6 @@
- name: Remove the last role - name: Remove the last role
consul_role: consul_role:
token: "{{ consul_management_token }}"
name: role-with-node-identity name: role-with-node-identity
state: absent state: absent
register: result register: result

View file

@ -6,7 +6,6 @@
- name: list sessions - name: list sessions
consul_session: consul_session:
state: list state: list
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -18,7 +17,6 @@
consul_session: consul_session:
state: present state: present
name: testsession name: testsession
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -33,7 +31,6 @@
- name: list sessions after creation - name: list sessions after creation
consul_session: consul_session:
state: list state: list
token: "{{ consul_management_token }}"
register: result register: result
- set_fact: - set_fact:
@ -61,7 +58,6 @@
consul_session: consul_session:
state: info state: info
id: '{{ session_id }}' id: '{{ session_id }}'
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -72,7 +68,6 @@
consul_session: consul_session:
state: info state: info
name: test name: test
token: "{{ consul_management_token }}"
register: result register: result
ignore_errors: true ignore_errors: true
@ -84,7 +79,6 @@
consul_session: consul_session:
state: absent state: absent
id: '{{ session_id }}' id: '{{ session_id }}'
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -94,7 +88,6 @@
- name: list sessions after deletion - name: list sessions after deletion
consul_session: consul_session:
state: list state: list
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:
@ -121,7 +114,6 @@
state: present state: present
name: session-with-ttl name: session-with-ttl
ttl: 180 # sec ttl: 180 # sec
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:

View file

@ -10,7 +10,6 @@
key "foo" { key "foo" {
policy = "read" policy = "read"
} }
token: "{{ consul_management_token }}"
loop: loop:
- foo-access - foo-access
- foo-access2 - foo-access2
@ -19,7 +18,6 @@
community.general.consul_token: community.general.consul_token:
state: present state: present
accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21 accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21
token: "{{ consul_management_token }}"
service_identities: service_identities:
- service_name: test - service_name: test
datacenters: [test1, test2] datacenters: [test1, test2]
@ -42,7 +40,6 @@
community.general.consul_token: community.general.consul_token:
state: present state: present
accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21 accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21
token: "{{ consul_management_token }}"
description: Testing description: Testing
policies: policies:
- id: "{{ create_result.token.Policies[-1].ID }}" - id: "{{ create_result.token.Policies[-1].ID }}"
@ -58,7 +55,6 @@
community.general.consul_token: community.general.consul_token:
state: present state: present
accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21 accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21
token: "{{ consul_management_token }}"
policies: policies:
- id: "{{ create_result.token.Policies[-1].ID }}" - id: "{{ create_result.token.Policies[-1].ID }}"
register: result register: result
@ -72,7 +68,6 @@
community.general.consul_token: community.general.consul_token:
state: absent state: absent
accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21 accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21
token: "{{ consul_management_token }}"
register: result register: result
- assert: - assert:

View file

@ -89,12 +89,18 @@
- 3 - 3
- import_tasks: consul_general.yml - import_tasks: consul_general.yml
- import_tasks: consul_kv.yml - import_tasks: consul_kv.yml
- block:
- import_tasks: consul_session.yml - import_tasks: consul_session.yml
- import_tasks: consul_policy.yml - import_tasks: consul_policy.yml
- import_tasks: consul_role.yml - import_tasks: consul_role.yml
- import_tasks: consul_token.yml - import_tasks: consul_token.yml
- import_tasks: consul_auth_method.yml - import_tasks: consul_auth_method.yml
- import_tasks: consul_binding_rule.yml - import_tasks: consul_binding_rule.yml
module_defaults:
group/community.general.consul:
token: "{{ consul_management_token }}"
always: always:
- name: Kill consul process - name: Kill consul process
shell: kill $(cat {{ remote_tmp_dir }}/consul.pid) shell: kill $(cat {{ remote_tmp_dir }}/consul.pid)