I want to refactor the following vars file/playbook pair, to avoid
hard-coding the app name in the value for log_dir attributes.
---
# some-role-vars.yml
some_role_config:
- name: app1
log_dir: "/var/log/app1/app1.log"
- name: app2
log_dir: "/var/log/app2/app2.log"
- name: app3
log_dir: "/var/log/app3/app3.log"
# some-playbook.yml
- hosts: all
become: True
gather_facts: True
vars_files:
- some-role-vars.yml
roles:
- role: some-role
config: "{{ some_role_config }}"
Other than using set_fact in a way similar to this, what other approaches
(best practices/conventions) are available?
- name: Set some_role_config
set_fact:
some_role_config: "{{ some_role_config|default([]) + [ {'name': item,
'path': '/var/log/' + item + '/' + item + '.log' } ] }}"
with_items:
- app1
- app2
- app3
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/e9826698-2c75-413f-8814-4adaa188c071%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.