mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 13:55:04 -02:30
Merge pull request #6779 from squidboylan/fix_project_allow_override
Collection: Fix the tower_project scm_allow_override Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -83,11 +83,13 @@ options:
|
|||||||
Only valid if scm_update_on_launch is to True, otherwise ignored.
|
Only valid if scm_update_on_launch is to True, otherwise ignored.
|
||||||
type: int
|
type: int
|
||||||
default: 0
|
default: 0
|
||||||
scm_allow_override:
|
allow_override:
|
||||||
description:
|
description:
|
||||||
- Allow changing the SCM branch or revision in a job template that uses this project.
|
- Allow changing the SCM branch or revision in a job template that uses this project.
|
||||||
type: bool
|
type: bool
|
||||||
version_added: "3.7"
|
version_added: "3.7"
|
||||||
|
aliases:
|
||||||
|
- scm_allow_override
|
||||||
job_timeout:
|
job_timeout:
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
description:
|
description:
|
||||||
@@ -188,7 +190,7 @@ def main():
|
|||||||
scm_delete_on_update=dict(type='bool', default=False),
|
scm_delete_on_update=dict(type='bool', default=False),
|
||||||
scm_update_on_launch=dict(type='bool', default=False),
|
scm_update_on_launch=dict(type='bool', default=False),
|
||||||
scm_update_cache_timeout=dict(type='int', default=0),
|
scm_update_cache_timeout=dict(type='int', default=0),
|
||||||
scm_allow_override=dict(type='bool'),
|
allow_override=dict(type='bool', aliases=['scm_allow_override']),
|
||||||
job_timeout=dict(type='int', default=0),
|
job_timeout=dict(type='int', default=0),
|
||||||
custom_virtualenv=dict(),
|
custom_virtualenv=dict(),
|
||||||
organization=dict(required=True),
|
organization=dict(required=True),
|
||||||
@@ -214,7 +216,7 @@ def main():
|
|||||||
scm_delete_on_update = module.params.get('scm_delete_on_update')
|
scm_delete_on_update = module.params.get('scm_delete_on_update')
|
||||||
scm_update_on_launch = module.params.get('scm_update_on_launch')
|
scm_update_on_launch = module.params.get('scm_update_on_launch')
|
||||||
scm_update_cache_timeout = module.params.get('scm_update_cache_timeout')
|
scm_update_cache_timeout = module.params.get('scm_update_cache_timeout')
|
||||||
scm_allow_override = module.params.get('scm_allow_override')
|
allow_override = module.params.get('allow_override')
|
||||||
job_timeout = module.params.get('job_timeout')
|
job_timeout = module.params.get('job_timeout')
|
||||||
custom_virtualenv = module.params.get('custom_virtualenv')
|
custom_virtualenv = module.params.get('custom_virtualenv')
|
||||||
organization = module.params.get('organization')
|
organization = module.params.get('organization')
|
||||||
@@ -253,8 +255,8 @@ def main():
|
|||||||
project_fields['description'] = description
|
project_fields['description'] = description
|
||||||
if scm_credential is not None:
|
if scm_credential is not None:
|
||||||
project_fields['credential'] = scm_credential_id
|
project_fields['credential'] = scm_credential_id
|
||||||
if scm_allow_override is not None:
|
if allow_override is not None:
|
||||||
project_fields['scm_allow_override'] = scm_allow_override
|
project_fields['allow_override'] = allow_override
|
||||||
if scm_type == '':
|
if scm_type == '':
|
||||||
project_fields['local_path'] = local_path
|
project_fields['local_path'] = local_path
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
project_name1: "AWX-Collection-tests-tower_project-project1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
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') }}"
|
project_name2: "AWX-Collection-tests-tower_project-project2-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
|
project_name3: "AWX-Collection-tests-tower_project-project3-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
|
jt1: "AWX-Collection-tests-tower_project-jt1-{{ 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') }}"
|
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') }}"
|
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') }}"
|
cred_name: "AWX-Collection-tests-tower_project-cred-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
@@ -118,7 +120,60 @@
|
|||||||
- "result.msg =='The credentials Non Existing Credential was not found on the Tower server' or
|
- "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'"
|
result.msg =='Failed to update project, credential not found: Non Existing Credential'"
|
||||||
|
|
||||||
- name: Delete the test project
|
- 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
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result is changed
|
||||||
|
|
||||||
|
- name: "wait for job {{ result.id }}"
|
||||||
|
tower_job_wait:
|
||||||
|
job_id: "{{ result.id }}"
|
||||||
|
register: job
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- job is successful
|
||||||
|
|
||||||
|
- 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 2
|
||||||
tower_project:
|
tower_project:
|
||||||
name: "{{ project_name2 }}"
|
name: "{{ project_name2 }}"
|
||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
@@ -136,7 +191,7 @@
|
|||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Delete the other test project
|
- name: Delete the test project 1
|
||||||
tower_project:
|
tower_project:
|
||||||
name: "{{ project_name1 }}"
|
name: "{{ project_name1 }}"
|
||||||
organization: Default
|
organization: Default
|
||||||
|
|||||||
Reference in New Issue
Block a user