--- - name: Generate names set_fact: project_name1: "AWX-Collection-tests-project-project1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" project_name2: "AWX-Collection-tests-project-project2-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" project_name3: "AWX-Collection-tests-project-project3-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" jt1: "AWX-Collection-tests-project-jt1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" scm_cred_name: "AWX-Collection-tests-project-scm-cred-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" org_name: "AWX-Collection-tests-project-org-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" cred_name: "AWX-Collection-tests-project-cred-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" - block: - name: Create an SCM Credential credential: name: "{{ scm_cred_name }}" organization: Default credential_type: Source Control register: result - assert: that: - result is changed - name: Create a git project without credentials and wait 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 changed - name: Recreate the project to validate not changed project: name: "{{ project_name1 }}" organization: Default scm_type: git scm_url: https://github.com/ansible/test-playbooks wait: false register: result ignore_errors: true - assert: that: - result is not changed - name: Create organizations organization: name: "{{ org_name }}" register: result - assert: that: - result is changed - name: Create credential credential: credential_type: Source Control name: "{{ cred_name }}" organization: "{{ org_name }}" register: result - assert: that: - result is changed - name: Create a new test project in check_mode 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: "Copy project from {{ project_name1 }}" project: name: "{{ project_name2 }}" copy_from: "{{ project_name1 }}" organization: "{{ org_name }}" scm_type: git scm_credential: "{{ cred_name }}" state: present 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.copied - name: Check module fails with correct msg when given non-existing org as param 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 is failed" - "result is not changed" - "'Non_Existing_Org' in result.msg" - "result.total_results == 0" - name: Check module fails with correct msg when given non-existing credential as param 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 is failed" - "result is not changed" - "'Non_Existing_Credential' in result.msg" - "result.total_results == 0" - name: Create a git project without credentials without waiting project: name: "{{ project_name3 }}" organization: Default scm_type: git scm_branch: empty_branch scm_url: https://github.com/ansible/test-playbooks allow_override: true register: result - assert: that: - result is changed - name: Update the project and wait. Verify not changed as no change made to repo and refspec not changed project: name: "{{ project_name3 }}" organization: Default scm_type: git scm_branch: empty_branch scm_url: https://github.com/ansible/test-playbooks allow_override: true wait: true update_project: true register: result - assert: that: - result is not changed - name: Create a job template that overrides the project scm_branch job_template: name: "{{ jt1 }}" project: "{{ project_name3 }}" inventory: "Demo Inventory" scm_branch: master playbook: debug.yml - name: Launch "{{ jt1 }}" job_launch: job_template: "{{ jt1 }}" register: result - assert: that: - result is changed - name: "wait for job {{ result.id }}" job_wait: job_id: "{{ result.id }}" register: job - assert: that: - job is successful always: - name: Delete the test job_template job_template: name: "{{ jt1 }}" project: "{{ project_name3 }}" inventory: "Demo Inventory" state: absent - name: Delete the test project 3 project: name: "{{ project_name3 }}" organization: Default state: absent - name: Delete the test project 2 project: name: "{{ project_name2 }}" organization: "{{ org_name }}" state: absent - name: Delete the SCM Credential credential: name: "{{ scm_cred_name }}" organization: Default credential_type: Source Control state: absent register: result - assert: that: - result is changed - name: Delete the test project 1 project: name: "{{ project_name1 }}" organization: Default state: absent register: result - assert: that: - result is changed - name: Delete credential credential: credential_type: Source Control name: "{{ cred_name }}" organization: "{{ org_name }}" state: absent register: result - assert: that: - result is changed - name: Delete the organization organization: name: "{{ org_name }}" state: absent register: result - assert: that: - result is changed