awx
awx copied to clipboard
Feature: Programmable surveys
AWX Feature Spec - Programmable Surveys
User Persona
Administrator delegating jobs to user Delegated automation user
Usage Cases
High-level:
- Administrator wants to present to the user a list of builds to choose to deploy.
- Administrator wants to present to the user a verified list of configuration parameters to push to the chosen network devices.
- Adminsitrator wants to present survey chocies that depend on prior survey choices, such as a choice to select an AWS region based on 'AWS' being a prior survey answer.
API Considerations
We must keep the survey JSON specification stable, or CLEARLY notify users when it changes. This may require a v2 survey spec.
http://json-schema.org/ may be of use.
UI/UX Considerations
Larger surveys should have options to collapse questions until needed. (c.f. https://github.com/ansible/awx/issues/290)
Docs
Should have sample survey examples
QA Suggestions
Notes
Updates/Changelog
2017-09-06: initial/updated spec 2017-09-25: added note about collapsible surveys
There's a happy medium to be found here between usable simplicity and encompassing an entire range of user possibilities in a JSON/YAML markup language. I'm going to strongly recommend that at most we support dependency chaining between fields and support data-url
attributes for fields that GET
option values given partial user provided input. Users writing their own logic in their own server-hosted microservices will allow almost anything the user can imagine without making an overly complicated schema.
I would really like to see this added as well. We're currently using Ansible to roll out stacks in AWS and we need to be able to select the application version to deploy which we want to populate from the version tags set on the available AMI's
If you really need the feature now, take a look at a hack I did in #1408. That works for me.
I was looking for the same thing! This would be good to retrieve previously data stored by an AWX job.
Some variables/lists I'd be interested in templating into a survey:
- Current User in AWX (and less-so User Lists)
- Inventory Host Lists
- Inventory Group Lists
I'm not sure how I missed this before now, but just stumbled across this. I would really like this as well. We are trying to put together almost a wizard like interface to configure network devices. We already have a playbook that gathers data form devices and uses the REST API to build drop-down lists for surveys, but it would really be nice to have:
-
The ability to pick a switch from a list and have that then change the options for the interface question to those on the chosen switch
-
have certain questions appear only if the answer to a previous question is a certain value. I see no one is assigned this yet, but has anyone worked towards it? (aside from #1408 ) I'd definitely be willing to help out, but I haven't had the chance to dig into the code yet.
Also would be great to have :
- Inventory lists
All cases might be covered with custom type of multichoice selector with values from fact or variable, where
- "{{ awx_users }}" for awx users can be used
- "{{ awx_inventories }}" for inventories can be used
- "{{ awx_hosts }}" or something with jinja filter for hosts from current inventories
Though, this doesn't cover REST API multichoices.
I would like to see this feature added as well
I am part of a large company that needs this feature to switch their Ansible infrastructure completely from Rundeck to AWX, so I will be happy to see this implemented.
We are a large enterprise that needs this feature asap.
Would like to have that feature/ability as well. Every large company that I've worked for so far thought it's a mandatory feature for a Rundeck replacement. Currently my (very large) company wants to migrate all of our operations to AWX, and we can't without this feature.
I wrote python script to update surveys choices with tower-cli. In my case I need to automate updating backup files list in awx survey. This script can be easily adopted to any other tasks. Script can be executed by cron.
#!/usr/bin/python
import json
import os
import random
import string
######################
smb_creds='/etc/tower/smbcredentials.conf'
backup_path='\\\\\\\\backup01\\\\sql'
backup_folder='\\\\SRV-NAV18-SQL\\\\ASR_PROD\\\\'
survey_name='SBL Deploy ASOR Test Environment'
survey_question='DataBase backup file path'
#####################
cmd = 'smbclient ' + backup_path + ' -D ' + backup_folder + ' -A ' + smb_creds + ' -c ls 2>/dev/null | awk \'{print $1}\' | grep -e \'^\..*$\' -v | grep \'.bak\''
choices = ""
for file in os.popen(cmd).readlines():
choices = choices + '\n' + backup_path + backup_folder + file.rstrip()
choices = choices[2:]
choices = choices.replace('\\\\','\\')
cmd = 'tower-cli job_template survey -n "' + survey_name + '"'
survey_content = os.popen(cmd).read()
survey_obj = json.loads(survey_content)
for question in survey_obj['spec']:
if question["question_name"] == survey_question:
question["choices"] = choices
filename='/tmp/' + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5)) + '.json'
f = open(filename, "w")
f.write(json.dumps(survey_obj, sort_keys=True, indent=4))
f.close()
cmd = 'tower-cli job_template modify -n "' + survey_name + '" --survey-spec=@' + filename + ' --survey-enabled=true'
survey_mod = os.popen(cmd).read()
os.remove(filename)
I'd also like to put in my request to get this feature implemented. There are just many situations where external parameter need to be in a survey and the user has not the capacity to know all available values. As mentioned above I also see this requirement mostly in bigger enterprise setups. The workaround with the python script by MikeQ123 is a nice workaround though, which at least implements one part of the functionality. Thanks for that, Mike!
+1
+1
THAT is really what all my clients need !
This would be really useful. I was looking at dynamically creating a list of packages from a repository today for a survey drop down list. Initially for the project I am working on I tried using disablerepo: "*", enablerepo: "repoa, reopb, repoc", to try and allow some users to be able to self install packages from only the specified repositories via yum using an input box. When I tried to do this however the packages the user was trying to install had dependencies located in the main RHEL repositories. I have started to create a static list of packages the user can pick from. I was thinking it would be really nice if I could dynamically populate the list somehow. This is a bit different then some of the use cases listed in this issue, so I thought I would mention it. I will probably end up trying something like @MikeQ123 suggested.
+1
I am not sure if this is helpful for people, but I tried modifying the survey_spec resource with the new awx-cli (since tower-cli is being depreciated), and it doesn't look like the action has been built in yet (unless there is a way to do it that wasn't documented). However, it was easy enough to just use a raw post request to the endpoint ('/api/v2/job_templates/{id}/survey_spec/). You can use a personal access token or basic auth (I used a token). You can find the JSON format the endpoint expects via the API documentation https://docs.ansible.com/ansible-tower/latest/html/towerapi/api_ref.html.
+1
That feature would be awesome to have.
Given the demand for this (add our organization to the list), is there anything in process to add this as a feature? What would need to be done to help move it forward?
Yes please add this. We just implemented Ansible and are very dissapointed that this feature does not exist.
I want to believe referencing inventory variables in a dropdown list should not be so difficult to implement. That feature alone would help me a lot for my customer needs.
I would also like to see this feature added as we are building plays with options based on the different roles and would ensure the user doesnt skip a field that needs to be completed
Lots of people ask for this feature. Planned in next release since other tools already allow that?
We need this feature too. Our case is mostly with communicating MySQL servers. It should go something like this (just one example, we need it for many other cases):
Survey Wizard | Step 1: Select DB host (available hosts from inventory group)
>>> Execute Play/Task that connects to a host, runs a query and registers a result list (ex. list of available databases on host)
Survey Wizard | Step 2: Select Database (dropdown)
>>> Execure Play/Task that runs a query on that DB and registers a result list (ex. list of tables)
Survey Wizard | Step 3: Select Tables (dropdown, multiselect)
>>> Execute Play/Task with gathered table info ...
It would be very nice and user friendly to have this feature.
+1
+1
+1