Files
awx/awx_collection/tests/integration/targets/tower_project/tasks/main.yml

171 lines
4.4 KiB
YAML

---
- name: Generate names
set_fact:
project_name1: "AWX-Collection-tests-tower_project-project1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
project_name2: "AWX-Collection-tests-tower_project-project2-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
scm_cred_name: "AWX-Collection-tests-tower_project-scm-cred-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
org_name: "AWX-Collection-tests-tower_project-org-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
cred_name: "AWX-Collection-tests-tower_project-cred-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Create an SCM Credential
tower_credential:
name: "{{ scm_cred_name }}"
organization: Default
kind: scm
register: result
- assert:
that:
- result is changed
- name: Create a git project without credentials without waiting
tower_project:
name: "{{ project_name1 }}"
organization: Default
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
wait: false
register: result
- assert:
that:
- result is changed
- name: Recreate the project to validate not changed
tower_project:
name: "{{ project_name1 }}"
organization: Default
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
wait: true
register: result
- assert:
that:
- result is not changed
- name: Create organizations
tower_organization:
name: "{{ org_name }}"
register: result
- assert:
that:
- result is changed
- name: Create credential
tower_credential:
kind: scm
name: "{{ cred_name }}"
organization: "{{ org_name }}"
register: result
- assert:
that:
- result is changed
- name: Create a new test project in check_mode
tower_project:
name: "{{ project_name2 }}"
organization: "{{ org_name }}"
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
scm_credential: "{{ cred_name }}"
check_mode: true
- name: Create a new test project
tower_project:
name: "{{ project_name2 }}"
organization: "{{ org_name }}"
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
scm_credential: "{{ cred_name }}"
register: result
# If this fails it may be because the check_mode task actually already created
# the project, or it could be because the module actually failed somehow
- assert:
that:
- "result is changed"
- name: Check module fails with correct msg when given non-existing org as param
tower_project:
name: "{{ project_name2 }}"
organization: Non Existing Org
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
scm_credential: "{{ cred_name }}"
register: result
ignore_errors: true
- assert:
that:
- "result.msg == 'The organizations Non Existing Org was not found on the Tower server' or
result.msg == 'Failed to update project, organization not found: Non Existing Org'"
- name: Check module fails with correct msg when given non-existing credential as param
tower_project:
name: "{{ project_name2 }}"
organization: "{{ org_name }}"
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
scm_credential: Non Existing Credential
register: result
ignore_errors: true
- assert:
that:
- "result.msg =='The credentials Non Existing Credential was not found on the Tower server' or
result.msg =='Failed to update project, credential not found: Non Existing Credential'"
- name: Delete the test project
tower_project:
name: "{{ project_name2 }}"
organization: "{{ org_name }}"
state: absent
- name: Delete the SCM Credential
tower_credential:
name: "{{ scm_cred_name }}"
organization: Default
kind: scm
state: absent
register: result
- assert:
that:
- result is changed
- name: Delete the other test project
tower_project:
name: "{{ project_name1 }}"
organization: Default
state: absent
register: result
- assert:
that:
- result is changed
- name: Delete credential
tower_credential:
kind: scm
name: "{{ cred_name }}"
organization: "{{ org_name }}"
state: absent
register: result
- assert:
that:
- result is changed
- name: Delete the organization
tower_organization:
name: "{{ org_name }}"
state: absent
register: result
- assert:
that:
- result is changed