mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-05 23:51:48 -05:00
113 lines
2.6 KiB
YAML
113 lines
2.6 KiB
YAML
---
|
|
- name: Generate a test id
|
|
set_fact:
|
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
|
|
|
- name: Generate names
|
|
set_fact:
|
|
username: "AWX-Collection-tests-tower_role-user-{{ test_id }}"
|
|
project_name: "AWX-Collection-tests-tower_role-project-{{ test_id }}"
|
|
|
|
- block:
|
|
- name: Create a User
|
|
tower_user:
|
|
first_name: Joe
|
|
last_name: User
|
|
username: "{{ username }}"
|
|
password: "{{ 65535 | random | to_uuid }}"
|
|
email: joe@example.org
|
|
state: present
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- "result is changed"
|
|
|
|
- name: Create a project
|
|
tower_project:
|
|
name: "{{ project_name }}"
|
|
organization: Default
|
|
scm_type: git
|
|
scm_url: https://github.com/ansible/test-playbooks
|
|
wait: false
|
|
register: project_info
|
|
|
|
- assert:
|
|
that:
|
|
- project_info is changed
|
|
|
|
- name: Add Joe to the update role of the default Project
|
|
tower_role:
|
|
user: "{{ username }}"
|
|
role: update
|
|
project: "Demo Project"
|
|
state: "{{ item }}"
|
|
register: result
|
|
with_items:
|
|
- "present"
|
|
- "absent"
|
|
|
|
- assert:
|
|
that:
|
|
- "result is changed"
|
|
|
|
- name: Add Joe to the new project by ID
|
|
tower_role:
|
|
user: "{{ username }}"
|
|
role: update
|
|
project: "{{ project_info['id'] }}"
|
|
state: "{{ item }}"
|
|
register: result
|
|
with_items:
|
|
- "present"
|
|
- "absent"
|
|
|
|
- assert:
|
|
that:
|
|
- "result is changed"
|
|
|
|
- name: Create a workflow
|
|
tower_workflow_job_template:
|
|
name: test-role-workflow
|
|
organization: Default
|
|
state: present
|
|
|
|
- name: Add Joe to workflow execute role
|
|
tower_role:
|
|
user: "{{ username }}"
|
|
role: execute
|
|
workflow: test-role-workflow
|
|
state: present
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- "result is changed"
|
|
|
|
- name: Add Joe to workflow execute role, no-op
|
|
tower_role:
|
|
user: "{{ username }}"
|
|
role: execute
|
|
workflow: test-role-workflow
|
|
state: present
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- "result is not changed"
|
|
|
|
always:
|
|
- name: Delete a User
|
|
tower_user:
|
|
username: "{{ username }}"
|
|
email: joe@example.org
|
|
state: absent
|
|
register: result
|
|
|
|
- name: Delete the project
|
|
tower_project:
|
|
name: "{{ project_name }}"
|
|
organization: Default
|
|
state: absent
|
|
register: result
|