ansible/test/integration/targets/tower_workflow_template/tasks/main.yml
jainnikhil30 cd27982959 Fixing exception import for tower modules (#50447)
* fixing the exception import from tower modules

* Adding tests for checking tower modules are failing with correct msg

* fixed failing tests

* fixed failing test in tower_team
2019-01-09 15:31:21 +01:00

105 lines
No EOL
2.9 KiB
YAML

---
- name: Create an SCM Credential
tower_credential:
name: SCM Credential for JT
organization: Default
kind: scm
- name: Create a Demo Project
tower_project:
name: Job Template Test Project
organization: Default
state: present
scm_type: git
scm_url: https://github.com/ansible/ansible-tower-samples.git
scm_credential: SCM Credential for JT
register: result
- name: Update the project (to clone the git repo)
uri:
url: "https://{{ lookup('env', 'TOWER_HOST') }}/api/v2/projects/{{ result.id }}/update/"
method: POST
user: "{{ lookup('env', 'TOWER_USERNAME') }}"
password: "{{ lookup('env', 'TOWER_PASSWORD') }}"
validate_certs: false
status_code: 202
force_basic_auth: true
- name: Wait for the project to be status=successful
uri:
url: "https://{{ lookup('env', 'TOWER_HOST') }}/api/v2/projects/{{ result.id }}/"
method: GET
user: "{{ lookup('env', 'TOWER_USERNAME') }}"
password: "{{ lookup('env', 'TOWER_PASSWORD') }}"
validate_certs: false
force_basic_auth: true
return_content: true
register: result
until: result.json.status == "successful"
retries: 60
delay: 1
- name: Create a Job Template
tower_job_template:
name: my-job-1
project: Job Template Test Project
inventory: Demo Inventory
playbook: hello_world.yml
credential: Demo Credential
job_type: run
state: present
- name: Create a second Job Template
tower_job_template:
name: my-job-2
project: Job Template Test Project
inventory: Demo Inventory
playbook: hello_world.yml
credential: Demo Credential
job_type: run
state: present
- name: Add a Survey to second Job Template
tower_job_template:
name: my-job-2
project: Job Template Test Project
inventory: Demo Inventory
playbook: hello_world.yml
credential: Demo Credential
job_type: run
state: present
survey_enabled: yes
survey_spec: '{"spec": [{"index": 0, "question_name": "my question?", "default": "mydef", "variable": "myvar", "type": "text", "required": "false"}], "description": "test", "name": "test"}'
- name: Create a workflow job template
tower_workflow_template:
name: my-workflow
schema: '[{"success": [{"job_template": "my-job-1"}], "job_template": "my-job-2"}]'
register: result
- assert:
that:
- "result is changed"
- name: Delete a workflow job template
tower_workflow_template:
name: my-workflow
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Check module fails with correct msg
tower_workflow_template:
name: my-workflow
organization: Non Existing Organization
schema: '[{"success": [{"job_template": "my-job-1"}], "job_template": "my-job-2"}]'
register: result
ignore_errors: true
- assert:
that:
- "result.msg =='Failed to update organization source,organization not found: The requested object could not be found.'"