Using 'is defined' check for addpkg/delpkg in npm checkings.

This commit is contained in:
Emiliano Vavassori 2016-01-21 21:43:16 +01:00
parent 94c1240cb6
commit 08f61b11e3
1 changed files with 2 additions and 7 deletions

View File

@ -5,18 +5,13 @@
- name: Updating package cache.
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
apt:
name: '{{ item }}'
state: present
become: yes
with_items: "{{ addpkg }}"
when: str_addpkg
when: addpkg is defined
- name: Removing packages for specific role from NetworkPackageManager
apt:
@ -24,7 +19,7 @@
state: absent
purge: yes
with_items: "{{ delpkg }}"
when: str_delpkg
when: delpkg is defined
- name: Updating local hash for packages
shell: 'rm -f {{ ansible_local.checksum.pkgver_file }} && echo "{{ ansible_local.checksum.pkgver }}" > {{ ansible_local.checksum.pkgver_file }}'