mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 05:47:38 -02:30
project update fix
This commit is contained in:
@@ -9,245 +9,241 @@
|
||||
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
|
||||
- block:
|
||||
- name: Create an SCM Credential
|
||||
tower_credential:
|
||||
name: "{{ scm_cred_name }}"
|
||||
organization: Default
|
||||
kind: scm
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- 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
|
||||
- name: Create a git project without credentials and wait
|
||||
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 changed
|
||||
- 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
|
||||
- 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: false
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Create organizations
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
register: result
|
||||
- name: Create organizations
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Create credential
|
||||
tower_credential:
|
||||
kind: scm
|
||||
name: "{{ cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
register: result
|
||||
- name: Create credential
|
||||
tower_credential:
|
||||
kind: scm
|
||||
name: "{{ cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- 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 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: "Copy tower project from {{ project_name1 }}"
|
||||
tower_project:
|
||||
name: "{{ project_name2 }}"
|
||||
copy_from: "{{ project_name1 }}"
|
||||
organization: "{{ org_name }}"
|
||||
scm_type: git
|
||||
scm_credential: "{{ cred_name }}"
|
||||
state: present
|
||||
register: result
|
||||
- name: "Copy tower project from {{ project_name1 }}"
|
||||
tower_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
|
||||
# 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
|
||||
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
|
||||
- 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 is failed"
|
||||
- "result is not changed"
|
||||
- "'Non_Existing_Org' in result.msg"
|
||||
- "result.total_results == 0"
|
||||
- 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
|
||||
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
|
||||
- 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 is failed"
|
||||
- "result is not changed"
|
||||
- "'Non_Existing_Credential' in result.msg"
|
||||
- "result.total_results == 0"
|
||||
- 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
|
||||
tower_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
|
||||
- name: Create a git project without credentials without waiting
|
||||
tower_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
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Update a git project, update the project and wait.
|
||||
tower_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
|
||||
- name: Update the project and wait. Verify not changed as no change made to repo and refspec not changed
|
||||
tower_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
|
||||
|
||||
- name: Update a git project, update the project without waiting.
|
||||
tower_project:
|
||||
name: "{{ project_name3 }}"
|
||||
organization: Default
|
||||
scm_type: git
|
||||
scm_branch: empty_branch
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
wait: false
|
||||
update_project: true
|
||||
register: result
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Create a job template that overrides the project scm_branch
|
||||
tower_job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ project_name3 }}"
|
||||
inventory: "Demo Inventory"
|
||||
scm_branch: master
|
||||
playbook: debug.yml
|
||||
- name: Create a job template that overrides the project scm_branch
|
||||
tower_job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ project_name3 }}"
|
||||
inventory: "Demo Inventory"
|
||||
scm_branch: master
|
||||
playbook: debug.yml
|
||||
|
||||
- name: Launch "{{ jt1 }}"
|
||||
tower_job_launch:
|
||||
job_template: "{{ jt1 }}"
|
||||
register: result
|
||||
- name: Launch "{{ jt1 }}"
|
||||
tower_job_launch:
|
||||
job_template: "{{ jt1 }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: "wait for job {{ result.id }}"
|
||||
tower_job_wait:
|
||||
job_id: "{{ result.id }}"
|
||||
register: job
|
||||
- name: "wait for job {{ result.id }}"
|
||||
tower_job_wait:
|
||||
job_id: "{{ result.id }}"
|
||||
register: job
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- job is successful
|
||||
- assert:
|
||||
that:
|
||||
- job is successful
|
||||
|
||||
- name: Delete the test job_template
|
||||
tower_job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ project_name3 }}"
|
||||
inventory: "Demo Inventory"
|
||||
state: absent
|
||||
always:
|
||||
- name: Delete the test job_template
|
||||
tower_job_template:
|
||||
name: "{{ jt1 }}"
|
||||
project: "{{ project_name3 }}"
|
||||
inventory: "Demo Inventory"
|
||||
state: absent
|
||||
|
||||
- name: Delete the test project 3
|
||||
tower_project:
|
||||
name: "{{ project_name3 }}"
|
||||
organization: Default
|
||||
state: absent
|
||||
- name: Delete the test project 3
|
||||
tower_project:
|
||||
name: "{{ project_name3 }}"
|
||||
organization: Default
|
||||
state: absent
|
||||
|
||||
- name: Delete the test project 2
|
||||
tower_project:
|
||||
name: "{{ project_name2 }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: absent
|
||||
- name: Delete the test project 2
|
||||
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
|
||||
- name: Delete the SCM Credential
|
||||
tower_credential:
|
||||
name: "{{ scm_cred_name }}"
|
||||
organization: Default
|
||||
kind: scm
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Delete the test project 1
|
||||
tower_project:
|
||||
name: "{{ project_name1 }}"
|
||||
organization: Default
|
||||
state: absent
|
||||
register: result
|
||||
- name: Delete the test project 1
|
||||
tower_project:
|
||||
name: "{{ project_name1 }}"
|
||||
organization: Default
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Delete credential
|
||||
tower_credential:
|
||||
kind: scm
|
||||
name: "{{ cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: Delete credential
|
||||
tower_credential:
|
||||
kind: scm
|
||||
name: "{{ cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Delete the organization
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: Delete the organization
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
Reference in New Issue
Block a user