1

I have several AWX job templates/playbooks all based off this one ansible script:

https://github.com/spantaleev/matrix-docker-ansible-deploy

The initial script I use to deploy a server has the variables currently defined in Inventories > ‘Custom_Inventory’ > HOSTS > ‘My_Domain’:

Deploy Server Job Template

Variables defined in Hosts

I then have further job templates setup to configure various parts of this service.

Configure Service Job Template

Configure Survey 1

Configure Survey 2

It saves input in ‘EXTRA VARIABLES’ of that script, but what I really need is a way to preserve and aggregate answers from these surveys.

At the moment when I upgrade the service (by running the original playbook again) it only applies the Host Variables saved beforehand, not any of the data entered on these surveys.

How can I save these survey variables so they can be applied to the original deployment/update script?

Any guidance/advice would be epic, I'm not sure where to begin on this one. :S

PC-Admin
  • 63
  • 1
  • 7

1 Answers1

0

You can propagate these to your desired data-set (dict|list) using set_facts and set_stats

ensure the survey key and values survives across the execution (and optional step in case you are loosing values)

- set_fact:
        survey_question: survey_ans.value

Then main step is to expose them (dict) as metadata for subsequent actions.

- set_stats:
    data:
      survey_question: survey_ans.value

This will survive the lifecycle of role/playbook/task and then exposed output can be used in workflow to aggregate the values as input for subsequent pipeline.