Debian Codegraph @

ansible_collections/amazon/aws/tests/integration/targets/iam_role/tasks/main.yml

raw
1 ---
2 # Tests for iam_role and iam_role_info
3 #
4 # Tests:
5 # - Minimal Role creation
6 # - Role deletion
7 # - Fetching a specific role
8 # - Creating roles w/ and w/o instance profiles
9 # - Creating roles w/ a path
10 # - Updating Max Session Duration
11 # - Updating Description
12 # - Managing list of managed policies
13 # - Managing list of inline policies (for testing _info)
14 # - Managing boundary policy
15 #
16 # Notes:
17 # - Only tests *documented* return values ( RESULT.iam_role )
18 # - There are some known timing issues with boto3 returning before actions
19 # complete in the case of problems with "changed" status it's worth enabling
20 # the standard_pauses and paranoid_pauses options as a first step in debugging
21 - name: Setup AWS connection info
22 module_defaults:
23 group/aws:
24 access_key: "{{ aws_access_key }}"
25 secret_key: "{{ aws_secret_key }}"
26 session_token: "{{ security_token | default(omit) }}"
27 region: "{{ aws_region }}"
28 amazon.aws.iam_role:
29 assume_role_policy_document: '{{ lookup("file", "deny-assume.json") }}'
30 block:
31 - ansible.builtin.set_fact:
32 assume_deny_policy: '{{ lookup("file", "deny-assume.json") | from_json }}'
33 - ansible.builtin.include_tasks: parameter_checks.yml
34 - name: Create Safe IAM Managed Policy
35 amazon.aws.iam_managed_policy:
36 state: present
37 policy_name: "{{ custom_policy_name }}"
38 policy_description: A safe (deny-all) managed policy
39 policy: "{{ lookup('file', 'deny-all.json') }}"
40 register: create_managed_policy
41 - ansible.builtin.assert:
42 that:
43 - create_managed_policy is succeeded
44
45 # ===================================================================
46 - ansible.builtin.include_tasks: instance_profile.yml
47 - ansible.builtin.include_tasks: creation_deletion.yml
48 - ansible.builtin.include_tasks: max_session_update.yml
49 - ansible.builtin.include_tasks: description_update.yml
50 - ansible.builtin.include_tasks: tags_update.yml
51 - ansible.builtin.include_tasks: policy_update.yml
52 - ansible.builtin.include_tasks: inline_policy_update.yml
53 - ansible.builtin.include_tasks: role_removal.yml
54 - ansible.builtin.include_tasks: boundary_policy.yml
55 - ansible.builtin.include_tasks: complex_role_creation.yml
56 always:
57 # ===================================================================
58 # Cleanup
59
60 - name: Remove IAM Role
61 amazon.aws.iam_role:
62 state: absent
63 name: "{{ test_role }}"
64 delete_instance_profile: true
65 ignore_errors: true
66 - name: Remove IAM Role (with path)
67 amazon.aws.iam_role:
68 state: absent
69 name: "{{ test_role }}"
70 path: "{{ test_path }}"
71 delete_instance_profile: true
72 ignore_errors: true
73 - name: Iam_role_info after Role deletion
74 amazon.aws.iam_role_info:
75 name: "{{ test_role }}"
76 ignore_errors: true
77 - name: Remove test managed policy
78 amazon.aws.iam_managed_policy:
79 state: absent
80 policy_name: "{{ custom_policy_name }}"