Is it possible to do something like the following:
- include: os/${ansible_distribution}.yml
As so, it’s not working, but I’m hoping there’s a way to accomplish something like this.
Best,
Ed.
Is it possible to do something like the following:
As so, it’s not working, but I’m hoping there’s a way to accomplish something like this.
Best,
Ed.
No, it’s not, because tasks must apply uniformly across all hosts in a play.
Also I should point out that Ansible 1.2 and later strongly prefers {{ variable }} for variable replacement.
Excerpts from Michael DeHaan's message of 2013-07-11 23:13:00 -0400:
No, it's not, because tasks must apply uniformly across all hosts in a play.
Something like this would work, though, no?
- include: centos.yaml
when: ansible_distribution == 'CentOS'
- include: debian.yaml
when: ansible_distribution == 'Debian'
Yes, indeed.
What this does is affix the “when” statement to each task included, anding it with any other when statements, if neccessary.
You can also attach a when to a role.