I have a playbook that runs on all database servers, gathers information about every database found, does error checking and eliminated duplicates (same db on mulitple servers). The result is an output file that contains three fields for every database “DBNAME SCRIPTNAME HOSTNAME”
Next I want to read every line in that local file, connect to only those hosts specified, and run the script providing the dbname as an argument. How can I read that dynamic local file and populated multiple variables for additional use?
Example file
ProdDB script1.sh host1
DevDB script47.sh host4
I want to do something like this
- name: retrieve tablespace data
shell: /path/{{ scriptname }} {{ dbname }}
delegate_to: {{ hostname }}
with items from file local.generated where field 1 is dbname, field 2 is scriptname, and field 3 is hostname
register: tablespace_data
whether or not I use delegate_to, or call another playbook with extra vars, I still need to populate variables based on their position in a 1-n row text file. Any ideas how I can pull something like that off?