awx icon indicating copy to clipboard operation
awx copied to clipboard

Feature: Programmable surveys

Open wenottingham opened this issue 7 years ago • 100 comments

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

wenottingham avatar Sep 06 '17 20:09 wenottingham

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.

j00bar avatar Oct 03 '17 15:10 j00bar

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

llaan avatar Feb 21 '18 08:02 llaan

If you really need the feature now, take a look at a hack I did in #1408. That works for me.

ooasis avatar Mar 01 '18 19:03 ooasis

I was looking for the same thing! This would be good to retrieve previously data stored by an AWX job.

stefanoabbate avatar Jul 10 '18 07:07 stefanoabbate

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

sonjz avatar Jul 31 '18 21:07 sonjz

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.

carrozzi avatar Aug 03 '18 19:08 carrozzi

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.

sumkincpp avatar Oct 31 '18 11:10 sumkincpp

I would like to see this feature added as well

RcRonco avatar Aug 05 '19 20:08 RcRonco

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.

eliranw avatar Aug 06 '19 10:08 eliranw

We are a large enterprise that needs this feature asap.

rfedida avatar Aug 06 '19 10:08 rfedida

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.

ItayZviCohen avatar Aug 19 '19 10:08 ItayZviCohen

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)

MikeQ123 avatar Aug 23 '19 06:08 MikeQ123

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!

Spreadcat avatar Sep 30 '19 07:09 Spreadcat

+1

alex-mnt avatar Oct 02 '19 15:10 alex-mnt

+1

Vuader avatar Oct 18 '19 13:10 Vuader

THAT is really what all my clients need !

Dodofox avatar Oct 31 '19 14:10 Dodofox

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.

markandrewj avatar Jan 09 '20 15:01 markandrewj

+1

uDuCkV avatar Jan 21 '20 17:01 uDuCkV

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.

markandrewj avatar Jan 21 '20 20:01 markandrewj

+1

mviniciusleal avatar Jan 24 '20 21:01 mviniciusleal

That feature would be awesome to have.

gnuheidix avatar Jan 31 '20 11:01 gnuheidix

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?

l3ender avatar Feb 10 '20 16:02 l3ender

Yes please add this. We just implemented Ansible and are very dissapointed that this feature does not exist.

kevev avatar Feb 16 '20 21:02 kevev

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.

henriavelabarbe avatar Mar 07 '20 18:03 henriavelabarbe

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

lloydwilke avatar Mar 25 '20 11:03 lloydwilke

Lots of people ask for this feature. Planned in next release since other tools already allow that?

sbarbo01 avatar Mar 26 '20 17:03 sbarbo01

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.

ghost avatar Apr 20 '20 06:04 ghost

+1

lucasafonsokremer avatar Apr 24 '20 14:04 lucasafonsokremer

+1

surajrahel avatar Apr 28 '20 09:04 surajrahel

+1

joreast avatar May 07 '20 17:05 joreast