Files
awx/awx_collection/tests/integration/targets/tower_project/tasks/main.yml
2020-03-03 10:44:48 -08:00

116 lines
3.1 KiB
YAML

---
- name: Delete old git project from any previous test runs
tower_project:
name: "git project"
organization: Default
state: absent
ignore_errors: true
- name: Create an SCM Credential
tower_credential:
name: SCM Credential for Project
organization: Default
kind: scm
- name: Create a git project without credentials without waiting
tower_project:
name: "git project"
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: "git project"
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: TestOrg
- name: Create credential
tower_credential:
kind: scm
name: TestCred
organization: TestOrg
register: new_credentials
- name: Generate random project name appender
set_fact:
project_name_rand: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Create a new test project in check_mode
tower_project:
name: "TestProject {{ project_name_rand }}"
organization: TestOrg
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
scm_credential: TestCred
check_mode: true
- name: Create a new test project
tower_project:
name: "TestProject {{ project_name_rand }}"
organization: TestOrg
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
scm_credential: TestCred
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: "TestProject {{ project_name_rand }}"
organization: Non Existing Org
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
scm_credential: TestCred
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: "TestProject {{ project_name_rand }}"
organization: TestOrg
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: "TestProject {{ project_name_rand }}"
organization: TestOrg
state: absent