2018-11-15 02:14:19 +01:00
|
|
|
---
|
2019-10-23 22:04:25 +02:00
|
|
|
- name: 'Run integration tests for IAM (inline) Policy management'
|
|
|
|
module_defaults:
|
|
|
|
group/aws:
|
|
|
|
aws_access_key: "{{ aws_access_key }}"
|
|
|
|
aws_secret_key: "{{ aws_secret_key }}"
|
|
|
|
security_token: "{{ security_token | default(omit) }}"
|
|
|
|
region: "{{ aws_region }}"
|
|
|
|
block:
|
2018-11-15 02:14:19 +01:00
|
|
|
# ============================================================
|
|
|
|
- name: Create a temporary folder for the policies
|
|
|
|
tempfile:
|
|
|
|
state: directory
|
|
|
|
register: tmpdir
|
|
|
|
- name: Copy over policy
|
|
|
|
copy:
|
|
|
|
src: no_access.json
|
|
|
|
dest: "{{ tmpdir.path }}"
|
|
|
|
- name: Copy over other policy
|
|
|
|
copy:
|
|
|
|
src: no_access_with_id.json
|
|
|
|
dest: "{{ tmpdir.path }}"
|
2019-10-23 22:04:25 +02:00
|
|
|
- name: Copy over other policy
|
|
|
|
copy:
|
|
|
|
src: no_access_with_second_id.json
|
|
|
|
dest: "{{ tmpdir.path }}"
|
|
|
|
|
2018-11-15 02:14:19 +01:00
|
|
|
# ============================================================
|
|
|
|
- name: Create user for tests
|
|
|
|
iam_user:
|
|
|
|
state: present
|
2019-10-23 22:04:25 +02:00
|
|
|
name: "{{ iam_name }}"
|
|
|
|
register: result
|
|
|
|
- name: Ensure user was created
|
2018-11-15 02:14:19 +01:00
|
|
|
assert:
|
|
|
|
that:
|
2019-10-23 22:04:25 +02:00
|
|
|
- result is changed
|
|
|
|
|
|
|
|
- name: Create role for tests
|
|
|
|
iam_role:
|
2018-11-15 02:14:19 +01:00
|
|
|
state: present
|
2019-10-23 22:04:25 +02:00
|
|
|
name: "{{ iam_name }}"
|
|
|
|
assume_role_policy_document: "{{ lookup('file','no_trust.json') }}"
|
|
|
|
register: result
|
|
|
|
- name: Ensure role was created
|
2018-11-15 02:14:19 +01:00
|
|
|
assert:
|
|
|
|
that:
|
2019-10-23 22:04:25 +02:00
|
|
|
- result is changed
|
|
|
|
|
|
|
|
- name: Create group for tests
|
|
|
|
iam_group:
|
2018-11-15 02:14:19 +01:00
|
|
|
state: present
|
2019-10-23 22:04:25 +02:00
|
|
|
name: "{{ iam_name }}"
|
|
|
|
register: result
|
|
|
|
- name: Ensure group was created
|
2018-11-15 02:14:19 +01:00
|
|
|
assert:
|
|
|
|
that:
|
2019-10-23 22:04:25 +02:00
|
|
|
- result is changed
|
|
|
|
|
|
|
|
# ============================================================
|
|
|
|
|
|
|
|
- name: Run tests for each type of object
|
|
|
|
include_tasks: object.yml
|
|
|
|
loop_control:
|
|
|
|
loop_var: iam_type
|
|
|
|
with_items:
|
|
|
|
- user
|
|
|
|
- group
|
|
|
|
- role
|
|
|
|
|
|
|
|
# ============================================================
|
|
|
|
|
2018-11-15 02:14:19 +01:00
|
|
|
always:
|
|
|
|
# ============================================================
|
2019-10-23 22:04:25 +02:00
|
|
|
- name: Remove user
|
2018-11-15 02:14:19 +01:00
|
|
|
iam_user:
|
|
|
|
state: absent
|
2019-10-23 22:04:25 +02:00
|
|
|
name: "{{ iam_name }}"
|
2018-11-15 02:14:19 +01:00
|
|
|
ignore_errors: yes
|
2019-10-23 22:04:25 +02:00
|
|
|
|
|
|
|
- name: Remove role
|
2018-11-15 02:14:19 +01:00
|
|
|
iam_role:
|
|
|
|
state: absent
|
2019-10-23 22:04:25 +02:00
|
|
|
name: "{{ iam_name }}"
|
2018-11-15 02:14:19 +01:00
|
|
|
ignore_errors: yes
|
2019-10-23 22:04:25 +02:00
|
|
|
|
|
|
|
- name: Remove group
|
2018-11-15 02:14:19 +01:00
|
|
|
iam_group:
|
|
|
|
state: absent
|
2019-10-23 22:04:25 +02:00
|
|
|
name: "{{ iam_name }}"
|
2018-11-15 02:14:19 +01:00
|
|
|
ignore_errors: yes
|
2019-10-23 22:04:25 +02:00
|
|
|
|
2018-11-15 02:14:19 +01:00
|
|
|
# ============================================================
|
|
|
|
- name: Delete temporary folder containing the policies
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ tmpdir.path }}/"
|