Correcting tasks with new syntax for hostvars.

This commit is contained in:
Emiliano Vavassori 2016-02-17 22:41:55 +01:00
parent bbf6eb5a10
commit 95e48b21ab
4 changed files with 10 additions and 12 deletions

View File

@ -16,7 +16,7 @@
purge: yes
with_items: "{{ base_client_delpkg }}"
become: yes
when: role == 'client' and base_client_delpkg|length > 0
when: hostvars.hostname.role == 'client' and base_client_delpkg|length > 0
- name: Removing packages from docenti machines
apt:
@ -25,7 +25,7 @@
purge: yes
with_items: "{{ base_docenti_delpkg }}"
become: yes
when: role == 'docenti' and base_docenti_delpkg|length > 0
when: hostvars.hostname.role == 'docenti' and base_docenti_delpkg|length > 0
- name: Cleanup of unneeded packages
shell: apt-get -y autoremove
@ -47,7 +47,7 @@
state: present
with_items: "{{ base_client_addpkg }}"
become: yes
when: role == 'client' and base_client_addpkg|length > 0
when: hostvars.hostname.role == 'client' and base_client_addpkg|length > 0
- name: Installing additional packages for docenti role
apt:
@ -55,7 +55,7 @@
state: present
with_items: "{{ base_docenti_addpkg }}"
become: yes
when: role == 'docenti' and base_docenti_addpkg|length > 0
when: hostvars.hostname.role == 'docenti' and base_docenti_addpkg|length > 0
- name: Correggo NetworkManager per gestire la rete
lineinfile:

View File

@ -1,10 +1,8 @@
---
# Managing actions for role 'client'
- debug: var=hostvars.localhost.role
- include: epoptes.yml
when: "{{ role }} == 'client'"
when: hostvars.localhost.role == 'client'
tags:
- role
- client

View File

@ -2,7 +2,7 @@
# Managing actions for role 'docenti'
- include: epoptes.yml
when: "role == 'docenti'"
when: hostvars.localhost.role == 'docenti'
tags:
- role
- docenti

View File

@ -10,16 +10,16 @@
name: '{{ item }}'
state: present
become: yes
with_items: "{{ addpkg }}"
when: addpkg is defined and addpkg|join(' ')|trim != ''
with_items: "{{ hostvars.localhost.addpkg }}"
when: hostvars.localhost.addpkg|join(' ')|trim != ''
- name: Removing packages for specific role from NetworkPackageManager
apt:
name: '{{ item }}'
state: absent
purge: yes
with_items: "{{ delpkg }}"
when: delpkg is defined and delpkg|join(' ')|trim != ''
with_items: "{{ hostvars.localhost.delpkg }}"
when: hostvars.localhost.delpkg|join(' ')|trim != ''
- name: Updating local hash for packages
shell: 'rm -f {{ ansible_local.checksum.pkgver_file }} && echo "{{ ansible_local.checksum.pkgver }}" > {{ ansible_local.checksum.pkgver_file }}'