Reputation: 1034
I'm trying to apply task based on OS, but seems variable not working with include
:
What I've had tried
- include: {{ ansible_distribution }}_mongodb.yml
the same is working with debug mode. ansible version: 1.8.2
Upvotes: 0
Views: 1356
Reputation: 5360
As for ansible 1.7.2, variables are not expanded on the include
statement.
You can use:
- include: ubuntu_mongodb.yml
when: ansible_distribution == 'Ubuntu'
Or:
- include: ubuntu_mongodb.yml
when: ansible_distribution in ['Ubuntu']
Keep in mind that you can be more generic using the ansible_os_family
variable. For one ubuntu box, the contents of those variables are:
ansible_os_family
: "Debian"ansible_distribution
: "Ubuntu"Upvotes: 3