Trying to add better variable management not to break build chain.

This commit is contained in:
Emiliano Vavassori 2016-01-21 21:38:49 +01:00
parent 0f5dab90eb
commit 94c1240cb6

View File

@ -5,13 +5,18 @@
- name: Updating package cache. - name: Updating package cache.
apt: update_cache=yes cache_valid_time=180 apt: update_cache=yes cache_valid_time=180
- name: Defining new variable to manage additional packages
set_fact:
str_addpkg: "{{ addpkg|join(' ')|trim != '' }}"
str_delpkg: "{{ delpkg|join(' ')|trim != '' }}"
- name: Installing packages for specific role from NetworkPackageManager - name: Installing packages for specific role from NetworkPackageManager
apt: apt:
name: '{{ item }}' name: '{{ item }}'
state: present state: present
become: yes become: yes
with_items: "{{ addpkg }}" with_items: "{{ addpkg }}"
when: addpkg|join(' ')|trim != '' when: str_addpkg
- name: Removing packages for specific role from NetworkPackageManager - name: Removing packages for specific role from NetworkPackageManager
apt: apt:
@ -19,7 +24,7 @@
state: absent state: absent
purge: yes purge: yes
with_items: "{{ delpkg }}" with_items: "{{ delpkg }}"
when: delpkg|join(' ')|trim != '' when: str_delpkg
- name: Updating local hash for packages - name: Updating local hash for packages
shell: 'rm -f {{ ansible_local.checksum.pkgver_file }} && echo "{{ ansible_local.checksum.pkgver }}" > {{ ansible_local.checksum.pkgver_file }}' shell: 'rm -f {{ ansible_local.checksum.pkgver_file }} && echo "{{ ansible_local.checksum.pkgver }}" > {{ ansible_local.checksum.pkgver_file }}'