diff --git a/roles/base/tasks/packages.yml b/roles/base/tasks/packages.yml index a9df955..f46ed8c 100644 --- a/roles/base/tasks/packages.yml +++ b/roles/base/tasks/packages.yml @@ -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: diff --git a/roles/client/tasks/main.yml b/roles/client/tasks/main.yml index c4dc811..32b9bfa 100644 --- a/roles/client/tasks/main.yml +++ b/roles/client/tasks/main.yml @@ -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 diff --git a/roles/docenti/tasks/main.yml b/roles/docenti/tasks/main.yml index 8bb7e7e..f69f17c 100644 --- a/roles/docenti/tasks/main.yml +++ b/roles/docenti/tasks/main.yml @@ -2,7 +2,7 @@ # Managing actions for role 'docenti' - include: epoptes.yml - when: "role == 'docenti'" + when: hostvars.localhost.role == 'docenti' tags: - role - docenti diff --git a/roles/networkpackagemanager/tasks/main.yml b/roles/networkpackagemanager/tasks/main.yml index f1b90e3..3944ca1 100644 --- a/roles/networkpackagemanager/tasks/main.yml +++ b/roles/networkpackagemanager/tasks/main.yml @@ -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 }}'