diff --git a/changelogs/fragments/7897-consul-action-group.yaml b/changelogs/fragments/7897-consul-action-group.yaml new file mode 100644 index 0000000000..1764e1970d --- /dev/null +++ b/changelogs/fragments/7897-consul-action-group.yaml @@ -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). diff --git a/meta/runtime.yml b/meta/runtime.yml index 3472754bbb..c4f9589c07 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -4,6 +4,14 @@ # SPDX-License-Identifier: GPL-3.0-or-later requires_ansible: '>=2.13.0' +action_groups: + consul: + - consul_auth_method + - consul_binding_rule + - consul_policy + - consul_role + - consul_session + - consul_token plugin_routing: connection: docker: diff --git a/plugins/doc_fragments/consul.py b/plugins/doc_fragments/consul.py index 67fef5b1b3..fbe3f33d4d 100644 --- a/plugins/doc_fragments/consul.py +++ b/plugins/doc_fragments/consul.py @@ -47,3 +47,14 @@ options: - The token to use for authorization. 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 +""" diff --git a/plugins/modules/consul_auth_method.py b/plugins/modules/consul_auth_method.py index 96b2469ae5..afe549f6ef 100644 --- a/plugins/modules/consul_auth_method.py +++ b/plugins/modules/consul_auth_method.py @@ -21,6 +21,7 @@ author: - Florian Apolloner (@apollo13) extends_documentation_fragment: - community.general.consul + - community.general.consul.actiongroup_consul - community.general.consul.token - community.general.attributes attributes: diff --git a/plugins/modules/consul_binding_rule.py b/plugins/modules/consul_binding_rule.py index 065981c6a3..88496f8675 100644 --- a/plugins/modules/consul_binding_rule.py +++ b/plugins/modules/consul_binding_rule.py @@ -21,6 +21,7 @@ author: - Florian Apolloner (@apollo13) extends_documentation_fragment: - community.general.consul + - community.general.consul.actiongroup_consul - community.general.consul.token - community.general.attributes attributes: diff --git a/plugins/modules/consul_policy.py b/plugins/modules/consul_policy.py index 9f7498c005..f020622a0c 100644 --- a/plugins/modules/consul_policy.py +++ b/plugins/modules/consul_policy.py @@ -21,6 +21,7 @@ author: - Håkon Lerring (@Hakon) extends_documentation_fragment: - community.general.consul + - community.general.consul.actiongroup_consul - community.general.consul.token - community.general.attributes attributes: diff --git a/plugins/modules/consul_role.py b/plugins/modules/consul_role.py index 76f1b96580..0da71507a6 100644 --- a/plugins/modules/consul_role.py +++ b/plugins/modules/consul_role.py @@ -22,6 +22,7 @@ author: extends_documentation_fragment: - community.general.consul - community.general.consul.token + - community.general.consul.actiongroup_consul - community.general.attributes attributes: check_mode: diff --git a/plugins/modules/consul_session.py b/plugins/modules/consul_session.py index 5629454c52..bd03b561a7 100644 --- a/plugins/modules/consul_session.py +++ b/plugins/modules/consul_session.py @@ -21,6 +21,7 @@ author: - Håkon Lerring (@Hakon) extends_documentation_fragment: - community.general.consul + - community.general.consul.actiongroup_consul - community.general.consul.token - community.general.attributes attributes: diff --git a/plugins/modules/consul_token.py b/plugins/modules/consul_token.py index 97f433ae29..24b5567dca 100644 --- a/plugins/modules/consul_token.py +++ b/plugins/modules/consul_token.py @@ -22,6 +22,7 @@ author: extends_documentation_fragment: - community.general.consul - community.general.consul.token + - community.general.consul.actiongroup_consul - community.general.attributes attributes: check_mode: diff --git a/tests/integration/targets/consul/tasks/consul_auth_method.yml b/tests/integration/targets/consul/tasks/consul_auth_method.yml index 2a5c8f1b8e..611d673095 100644 --- a/tests/integration/targets/consul/tasks/consul_auth_method.yml +++ b/tests/integration/targets/consul/tasks/consul_auth_method.yml @@ -19,7 +19,6 @@ cKWTjpBP2dPwVZ4WWC+9aGVd+Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbc mwIDAQAB -----END PUBLIC KEY----- - token: "{{ consul_management_token }}" register: result - assert: @@ -32,7 +31,6 @@ community.general.consul_auth_method: name: test max_token_ttl: 30m80s - token: "{{ consul_management_token }}" register: result - assert: @@ -45,7 +43,6 @@ community.general.consul_auth_method: name: test max_token_ttl: 30m80s - token: "{{ consul_management_token }}" register: result - assert: @@ -58,7 +55,6 @@ community.general.consul_auth_method: name: test state: absent - token: "{{ consul_management_token }}" register: result - assert: @@ -70,7 +66,6 @@ community.general.consul_auth_method: name: test state: absent - token: "{{ consul_management_token }}" register: result - assert: diff --git a/tests/integration/targets/consul/tasks/consul_binding_rule.yml b/tests/integration/targets/consul/tasks/consul_binding_rule.yml index 20ff5fc696..218daf982b 100644 --- a/tests/integration/targets/consul/tasks/consul_binding_rule.yml +++ b/tests/integration/targets/consul/tasks/consul_binding_rule.yml @@ -19,14 +19,12 @@ cKWTjpBP2dPwVZ4WWC+9aGVd+Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbc mwIDAQAB -----END PUBLIC KEY----- - token: "{{ consul_management_token }}" - name: Create a binding rule community.general.consul_binding_rule: name: test-binding description: my description auth_method: test - token: "{{ consul_management_token }}" bind_type: service bind_name: yolo register: result @@ -42,7 +40,6 @@ community.general.consul_binding_rule: name: test-binding auth_method: test - token: "{{ consul_management_token }}" bind_name: yolo2 register: result @@ -56,7 +53,6 @@ community.general.consul_binding_rule: name: test-binding auth_method: test - token: "{{ consul_management_token }}" register: result - assert: @@ -70,7 +66,6 @@ name: test-binding auth_method: test state: absent - token: "{{ consul_management_token }}" register: result - assert: that: diff --git a/tests/integration/targets/consul/tasks/consul_policy.yml b/tests/integration/targets/consul/tasks/consul_policy.yml index bfcd67368f..336324f03b 100644 --- a/tests/integration/targets/consul/tasks/consul_policy.yml +++ b/tests/integration/targets/consul/tasks/consul_policy.yml @@ -13,7 +13,6 @@ key "private/foo" { policy = "deny" } - token: "{{ consul_management_token }}" register: result - assert: @@ -35,7 +34,6 @@ event "bbq" { policy = "write" } - token: "{{ consul_management_token }}" register: result - assert: @@ -56,7 +54,6 @@ event "bbq" { policy = "write" } - token: "{{ consul_management_token }}" register: result - assert: @@ -67,7 +64,6 @@ - name: Remove a policy consul_policy: name: foo-access - token: "{{ consul_management_token }}" state: absent register: result - assert: diff --git a/tests/integration/targets/consul/tasks/consul_role.yml b/tests/integration/targets/consul/tasks/consul_role.yml index e761b3679f..9b0504e0b6 100644 --- a/tests/integration/targets/consul/tasks/consul_role.yml +++ b/tests/integration/targets/consul/tasks/consul_role.yml @@ -13,7 +13,6 @@ key "private/foo" { policy = "deny" } - token: "{{ consul_management_token }}" register: policy_result - name: Create another policy with rules @@ -26,7 +25,6 @@ key "private/bar" { policy = "deny" } - token: "{{ consul_management_token }}" register: policy_result - name: Create a role with policy @@ -34,7 +32,6 @@ name: foo-role-with-policy policies: - name: "foo-access-for-role" - token: "{{ consul_management_token }}" register: result - assert: @@ -47,7 +44,6 @@ consul_role: name: foo-role-with-policy description: "Testing updating description" - token: "{{ consul_management_token }}" check_mode: yes register: result @@ -62,7 +58,6 @@ consul_role: name: foo-role-with-policy description: "Role for testing policies" - token: "{{ consul_management_token }}" register: result - assert: @@ -78,7 +73,6 @@ policies: - name: "foo-access-for-role" - name: "bar-access-for-role" - token: "{{ consul_management_token }}" register: result - assert: @@ -91,7 +85,6 @@ - name: Create a role with service identity consul_role: - token: "{{ consul_management_token }}" name: role-with-service-identity service_identities: - name: web @@ -107,7 +100,6 @@ - name: Update the role with service identity in check mode consul_role: - token: "{{ consul_management_token }}" name: role-with-service-identity service_identities: - name: web @@ -124,7 +116,6 @@ - name: Update the role with service identity to add a policy, leaving the service id unchanged consul_role: - token: "{{ consul_management_token }}" name: role-with-service-identity policies: - name: "foo-access-for-role" @@ -139,7 +130,6 @@ - name: Update the role with service identity to remove the policies consul_role: - token: "{{ consul_management_token }}" name: role-with-service-identity policies: [] register: result @@ -153,7 +143,6 @@ - name: Update the role with service identity to remove the node identities, in check mode consul_role: - token: "{{ consul_management_token }}" name: role-with-service-identity node_identities: [] register: result @@ -169,7 +158,6 @@ - name: Update the role with service identity to remove the service identities consul_role: - token: "{{ consul_management_token }}" name: role-with-service-identity service_identities: [] register: result @@ -182,7 +170,6 @@ - name: Create a role with node identity consul_role: - token: "{{ consul_management_token }}" name: role-with-node-identity node_identities: - name: node-1 @@ -197,7 +184,6 @@ - name: Remove the last role consul_role: - token: "{{ consul_management_token }}" name: role-with-node-identity state: absent register: result diff --git a/tests/integration/targets/consul/tasks/consul_session.yml b/tests/integration/targets/consul/tasks/consul_session.yml index 7d6d084021..7f852a36d1 100644 --- a/tests/integration/targets/consul/tasks/consul_session.yml +++ b/tests/integration/targets/consul/tasks/consul_session.yml @@ -6,7 +6,6 @@ - name: list sessions consul_session: state: list - token: "{{ consul_management_token }}" register: result - assert: @@ -18,7 +17,6 @@ consul_session: state: present name: testsession - token: "{{ consul_management_token }}" register: result - assert: @@ -33,7 +31,6 @@ - name: list sessions after creation consul_session: state: list - token: "{{ consul_management_token }}" register: result - set_fact: @@ -61,7 +58,6 @@ consul_session: state: info id: '{{ session_id }}' - token: "{{ consul_management_token }}" register: result - assert: @@ -72,7 +68,6 @@ consul_session: state: info name: test - token: "{{ consul_management_token }}" register: result ignore_errors: true @@ -84,7 +79,6 @@ consul_session: state: absent id: '{{ session_id }}' - token: "{{ consul_management_token }}" register: result - assert: @@ -94,7 +88,6 @@ - name: list sessions after deletion consul_session: state: list - token: "{{ consul_management_token }}" register: result - assert: @@ -121,7 +114,6 @@ state: present name: session-with-ttl ttl: 180 # sec - token: "{{ consul_management_token }}" register: result - assert: diff --git a/tests/integration/targets/consul/tasks/consul_token.yml b/tests/integration/targets/consul/tasks/consul_token.yml index 88e5011eab..4e4c90af9b 100644 --- a/tests/integration/targets/consul/tasks/consul_token.yml +++ b/tests/integration/targets/consul/tasks/consul_token.yml @@ -10,7 +10,6 @@ key "foo" { policy = "read" } - token: "{{ consul_management_token }}" loop: - foo-access - foo-access2 @@ -19,7 +18,6 @@ community.general.consul_token: state: present accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21 - token: "{{ consul_management_token }}" service_identities: - service_name: test datacenters: [test1, test2] @@ -42,7 +40,6 @@ community.general.consul_token: state: present accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21 - token: "{{ consul_management_token }}" description: Testing policies: - id: "{{ create_result.token.Policies[-1].ID }}" @@ -58,7 +55,6 @@ community.general.consul_token: state: present accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21 - token: "{{ consul_management_token }}" policies: - id: "{{ create_result.token.Policies[-1].ID }}" register: result @@ -72,7 +68,6 @@ community.general.consul_token: state: absent accessor_id: 07a7de84-c9c7-448a-99cc-beaf682efd21 - token: "{{ consul_management_token }}" register: result - assert: diff --git a/tests/integration/targets/consul/tasks/main.yml b/tests/integration/targets/consul/tasks/main.yml index d172a7eaa3..6fef2b9980 100644 --- a/tests/integration/targets/consul/tasks/main.yml +++ b/tests/integration/targets/consul/tasks/main.yml @@ -89,12 +89,18 @@ - 3 - import_tasks: consul_general.yml - import_tasks: consul_kv.yml - - import_tasks: consul_session.yml - - import_tasks: consul_policy.yml - - import_tasks: consul_role.yml - - import_tasks: consul_token.yml - - import_tasks: consul_auth_method.yml - - import_tasks: consul_binding_rule.yml + + - block: + - import_tasks: consul_session.yml + - import_tasks: consul_policy.yml + - import_tasks: consul_role.yml + - import_tasks: consul_token.yml + - import_tasks: consul_auth_method.yml + - import_tasks: consul_binding_rule.yml + module_defaults: + group/community.general.consul: + token: "{{ consul_management_token }}" + always: - name: Kill consul process shell: kill $(cat {{ remote_tmp_dir }}/consul.pid)