roles/common: Use dynamic include_tasks for packages
Basically, when using conditionals or variables in your tasks you should use include_tasks instead of import_tasks. The down side is that you now need to tag all included tasks individually or with a block, unlike when using static imports (tags are applied to all imported child tasks). I would actually like to reduce this task to a single one that uses the host's ansible_distribution variable, but Ansible 2.5.1 currently gives the following error: ansible_distribution is undefined.
This commit is contained in:
@ -8,12 +8,12 @@
|
||||
tags: ntp
|
||||
|
||||
- name: Install common packages
|
||||
import_tasks: packages_Debian.yml
|
||||
include_tasks: packages_Debian.yml
|
||||
when: ansible_distribution == 'Debian'
|
||||
tags: packages
|
||||
|
||||
- name: Install common packages
|
||||
import_tasks: packages_Ubuntu.yml
|
||||
include_tasks: packages_Ubuntu.yml
|
||||
when: ansible_distribution == 'Ubuntu'
|
||||
tags: packages
|
||||
|
||||
|
Reference in New Issue
Block a user