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:
2018-04-25 18:46:28 +03:00
parent 9445541f51
commit 8b660dcfbe
3 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,7 @@
---
- name: Configure apt mirror
template: src=sources.list.j2 dest=/etc/apt/sources.list owner=root group=root mode=0644
tags: packages
- name: Install base packages
apt: name={{ item }} update_cache=yes
@ -20,6 +21,7 @@
- lrzip
- unzip
- apt-transport-https # for https support in apt
tags: packages
- name: Configure cron-apt
import_tasks: cron-apt.yml
@ -27,5 +29,6 @@
- name: Install tarsnap
import_tasks: tarsnap.yml
tags: packages
# vim: set sw=2 ts=2: