2

So I'm basically trying to load the config files through an task so in the first part of the task it would use the configuration variables for domain 1 for example with the nginx vhost file and the second part it would use the configuration variables for domain 2 which basically has the same keys but a different set of values.

The idea here is to have the task load the first config file variables then run the vhost tasks and then after this it would load the second config file variables and run the same vhost task but with new values.

How would this be done?

user3254198
  • 763
  • 6
  • 23

1 Answers1

2

a quick option would be to group these tasks into a new role called setup_config (or something else more meaningful). on your playbook you can do

- name: some play
  hosts: somegroup

  roles:
    - { role: setup_config, domain: var_domain1 }
    - { role: setup_config, domain: var_domain2 }

It will execute the exact same tasks contained on the setup_config role but with different variables.

A similar example of this can be found @ Ansible docs : Playbook Roles and Include Statements

Pedro Salgado
  • 836
  • 5
  • 6