| 1 |
--- |
| 2 |
# Path management |
| 3 |
|
| 4 |
- name: Set path (check_mode) |
| 5 |
amazon.aws.iam_user: |
| 6 |
name: "{{ test_user }}" |
| 7 |
path: "{{ test_path2 }}" |
| 8 |
state: present |
| 9 |
register: iam_user |
| 10 |
check_mode: true |
| 11 |
|
| 12 |
- name: Assert would change |
| 13 |
ansible.builtin.assert: |
| 14 |
that: |
| 15 |
- iam_user is changed |
| 16 |
|
| 17 |
- name: Set path |
| 18 |
amazon.aws.iam_user: |
| 19 |
name: "{{ test_user }}" |
| 20 |
path: "{{ test_path2 }}" |
| 21 |
state: present |
| 22 |
register: iam_user |
| 23 |
|
| 24 |
- name: Assert path updated |
| 25 |
ansible.builtin.assert: |
| 26 |
that: |
| 27 |
- iam_user is changed |
| 28 |
- "'user' in iam_user" |
| 29 |
- iam_user.user.user_name == test_user |
| 30 |
- iam_user.user.path == test_path2 |
| 31 |
|
| 32 |
- name: Add tag to test user |
| 33 |
amazon.aws.iam_user: |
| 34 |
name: "{{ test_user }}" |
| 35 |
state: present |
| 36 |
tags: |
| 37 |
TagA: ValueA |
| 38 |
|
| 39 |
- name: List users by path |
| 40 |
amazon.aws.iam_user_info: |
| 41 |
path: "{{ test_path2 }}" |
| 42 |
register: iam_user_info |
| 43 |
- name: Assert user found by path |
| 44 |
ansible.builtin.assert: |
| 45 |
that: |
| 46 |
- iam_user_info.iam_users | length == 1 |
| 47 |
- iam_user_info.iam_users[0].user_name == test_user |
| 48 |
- iam_user_info.iam_users[0].tags | length == 1 |
| 49 |
- iam_user_info.iam_users[0].tags.TagA == "ValueA" |
| 50 |
|
| 51 |
- name: Remove tag from test user |
| 52 |
amazon.aws.iam_user: |
| 53 |
name: "{{ test_user }}" |
| 54 |
state: present |
| 55 |
tags: {} |
| 56 |
|
| 57 |
- name: Retry set path (check_mode) |
| 58 |
amazon.aws.iam_user: |
| 59 |
name: "{{ test_user }}" |
| 60 |
path: "{{ test_path2 }}" |
| 61 |
state: present |
| 62 |
register: iam_user |
| 63 |
check_mode: true |
| 64 |
|
| 65 |
- name: Assert would not change |
| 66 |
ansible.builtin.assert: |
| 67 |
that: |
| 68 |
- iam_user is not changed |
| 69 |
|
| 70 |
- name: Retry set path |
| 71 |
amazon.aws.iam_user: |
| 72 |
name: "{{ test_user }}" |
| 73 |
path: "{{ test_path2 }}" |
| 74 |
state: present |
| 75 |
register: iam_user |
| 76 |
|
| 77 |
- name: Assert no change |
| 78 |
ansible.builtin.assert: |
| 79 |
that: |
| 80 |
- iam_user is not changed |
| 81 |
- "'user' in iam_user" |
| 82 |
- iam_user.user.user_name == test_user |
| 83 |
- iam_user.user.path == test_path2 |
| 84 |
|
| 85 |
# Re-Set Path |
| 86 |
|
| 87 |
- name: Set path (check_mode) |
| 88 |
amazon.aws.iam_user: |
| 89 |
name: "{{ test_user }}" |
| 90 |
path: "{{ test_path }}" |
| 91 |
state: present |
| 92 |
register: iam_user |
| 93 |
check_mode: true |
| 94 |
|
| 95 |
- name: Assert would change |
| 96 |
ansible.builtin.assert: |
| 97 |
that: |
| 98 |
- iam_user is changed |
| 99 |
|
| 100 |
- name: Set path |
| 101 |
amazon.aws.iam_user: |
| 102 |
name: "{{ test_user }}" |
| 103 |
path: "{{ test_path }}" |
| 104 |
state: present |
| 105 |
register: iam_user |
| 106 |
|
| 107 |
- name: Assert path changed |
| 108 |
ansible.builtin.assert: |
| 109 |
that: |
| 110 |
- iam_user is changed |
| 111 |
- "'user' in iam_user" |
| 112 |
- iam_user.user.user_name == test_user |
| 113 |
- iam_user.user.path == test_path |
| 114 |
|
| 115 |
- name: Retry set path (check_mode) |
| 116 |
amazon.aws.iam_user: |
| 117 |
name: "{{ test_user }}" |
| 118 |
path: "{{ test_path }}" |
| 119 |
state: present |
| 120 |
register: iam_user |
| 121 |
check_mode: true |
| 122 |
|
| 123 |
- name: Assert no change |
| 124 |
ansible.builtin.assert: |
| 125 |
that: |
| 126 |
- iam_user is not changed |
| 127 |
|
| 128 |
- name: Retry set path |
| 129 |
amazon.aws.iam_user: |
| 130 |
name: "{{ test_user }}" |
| 131 |
path: "{{ test_path }}" |
| 132 |
state: present |
| 133 |
register: iam_user |
| 134 |
|
| 135 |
- name: Assert no change |
| 136 |
ansible.builtin.assert: |
| 137 |
that: |
| 138 |
- iam_user is not changed |
| 139 |
- "'user' in iam_user" |
| 140 |
- iam_user.user.user_name == test_user |
| 141 |
- iam_user.user.path == test_path |
| 142 |
|
| 143 |
# /end Path management |
| 144 |
|
| 145 |
# /end Path management |