ansible/test/integration/targets/iam_policy/tasks/main.yml
Mark Chappell bd6d4b5b3a New module: iam_policy_info (#62955)
* iam_policy: (integration tests) migrate to module_defaults

* iam_policy: (integration tests) Rework iam_policy integration tests

* iam_policy_info: Add new module and add iam_policy_info tests to iam_policy integration tests
2019-10-23 13:04:25 -07:00

97 lines
2.5 KiB
YAML

---
- 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:
# ============================================================
- 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 }}"
- name: Copy over other policy
copy:
src: no_access_with_second_id.json
dest: "{{ tmpdir.path }}"
# ============================================================
- name: Create user for tests
iam_user:
state: present
name: "{{ iam_name }}"
register: result
- name: Ensure user was created
assert:
that:
- result is changed
- name: Create role for tests
iam_role:
state: present
name: "{{ iam_name }}"
assume_role_policy_document: "{{ lookup('file','no_trust.json') }}"
register: result
- name: Ensure role was created
assert:
that:
- result is changed
- name: Create group for tests
iam_group:
state: present
name: "{{ iam_name }}"
register: result
- name: Ensure group was created
assert:
that:
- 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
# ============================================================
always:
# ============================================================
- name: Remove user
iam_user:
state: absent
name: "{{ iam_name }}"
ignore_errors: yes
- name: Remove role
iam_role:
state: absent
name: "{{ iam_name }}"
ignore_errors: yes
- name: Remove group
iam_group:
state: absent
name: "{{ iam_name }}"
ignore_errors: yes
# ============================================================
- name: Delete temporary folder containing the policies
file:
state: absent
path: "{{ tmpdir.path }}/"