Tasks per host same playbook.

Hello,

I have 3 differents servers with nginx. Each one has its own vhost with custom configuration. But all 3 servers uses the same piece of configuration in one section of the vhost.

My question is, im trying to do the following thing in the same playbook.

You should look into roles and using a common role between hosts.

Roles can also pass parameters to them.

I don’t see how to using roles I can solve my “problem”. I’ll try to write down a detailed example.

I have a var file in which I fill with new infomation daily, this information should be included in a section of the vhost of 3 differents nginx servers. Every nginx server has his own configuration, but one section in every vhost has the daily information that I fill, so I need to using the “template” function to populate the vhost and then populate with a “for” in the template with this info.

Daily I need to add new info to the vhost, like rolling update, but not apply all roles or playbooks to the server, only update vhost and reload nginx.

Playbook for rolling update:
update_IP.yml

If you make a common role and include it for all hosts you can set variables there.

You don’t even need to set any tasks.