add logic for survey

This commit is contained in:
sean-m-sullivan
2021-01-17 10:32:07 -06:00
parent 1ce9c00d77
commit 1042c1cc28
6 changed files with 170 additions and 3 deletions

View File

@@ -70,12 +70,84 @@
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
- name: Create the job template with survey
tower_job_template:
name: "{{ jt_name2 }}"
project: "{{ proj_name }}"
playbook: debug.yml
job_type: run
state: present
inventory: "Demo Inventory"
survey_enabled: true
ask_variables_on_launch: false
survey_spec:
name: ''
description: ''
spec:
- question_name: Basic Name
question_description: Name
required: true
type: text
variable: basic_name
min: 0
max: 1024
default: ''
choices: ''
new_question: true
- question_name: Choose yes or no?
question_description: Choosing yes or no.
required: false
type: multiplechoice
variable: option_true_false
min:
max:
default: 'yes'
choices: |-
yes
no
new_question: true
- name: Kick off a job template with survey
tower_job_launch:
job_template: "{{ jt_name2 }}"
extra_vars:
basic_name: My First Variable
option_true_false: 'no'
ignore_errors: true
register: result
- assert:
that:
- result is not failed
- name: Prompt the job templates extra_vars on launch
tower_job_template:
name: "{{ jt_name2 }}"
state: present
ask_variables_on_launch: true
- name: Kick off a job template with extra_vars
tower_job_launch:
job_template: "{{ jt_name2 }}"
extra_vars:
basic_name: My First Variable
var1: My First Variable
var2: My Second Variable
ignore_errors: true
register: result
- assert:
that:
- result is not failed
- name: Create a Job Template for testing extra_vars
tower_job_template:
name: "{{ jt_name2 }}"
project: "{{ proj_name }}"
playbook: debug.yml
job_type: run
survey_enabled: false
state: present
inventory: "Demo Inventory"
extra_vars:

View File

@@ -0,0 +1,15 @@
---
- name: Run Integration Test
hosts: localhost
connection: local
gather_facts: False
environment:
TOWER_HOST: https://ansible-tower-web-svc-tower.apps-crc.testing
TOWER_USERNAME: admin
TOWER_PASSWORD: password
TOWER_VERIFY_SSL: False
collections:
- awx.awx
tasks:
- include_tasks: main.yml

View File

@@ -66,6 +66,66 @@
- result is not failed
- "'id' in result['job_info']"
- name: Kick off a workflow with extra_vars but not enabled
tower_workflow_launch:
workflow_template: "{{ wfjt_name1 }}"
extra_vars:
var1: My First Variable
var2: My Second Variable
ignore_errors: true
register: result
- assert:
that:
- result is failed
- "'The field extra_vars was specified but the workflow job template does not allow for it to be overridden' in result.errors"
- name: Prompt the workflow's with survey
tower_workflow_job_template:
name: "{{ wfjt_name1 }}"
state: present
survey_enabled: true
ask_variables_on_launch: false
survey:
name: ''
description: ''
spec:
- question_name: Basic Name
question_description: Name
required: true
type: text
variable: basic_name
min: 0
max: 1024
default: ''
choices: ''
new_question: true
- question_name: Choose yes or no?
question_description: Choosing yes or no.
required: false
type: multiplechoice
variable: option_true_false
min:
max:
default: 'yes'
choices: |-
yes
no
new_question: true
- name: Kick off a workflow with survey
tower_workflow_launch:
workflow_template: "{{ wfjt_name1 }}"
extra_vars:
basic_name: My First Variable
option_true_false: 'no'
ignore_errors: true
register: result
- assert:
that:
- result is not failed
- name: Prompt the workflow's extra_vars on launch
tower_workflow_job_template:
name: "{{ wfjt_name1 }}"
@@ -76,6 +136,7 @@
tower_workflow_launch:
workflow_template: "{{ wfjt_name1 }}"
extra_vars:
basic_name: My First Variable
var1: My First Variable
var2: My Second Variable
ignore_errors: true

View File

@@ -0,0 +1,15 @@
---
- name: Run Integration Test
hosts: localhost
connection: local
gather_facts: False
environment:
TOWER_HOST: https://ansible-tower-web-svc-tower.apps-crc.testing
TOWER_USERNAME: admin
TOWER_PASSWORD: password
TOWER_VERIFY_SSL: False
collections:
- awx.awx
tasks:
- include_tasks: main.yml