Tentative fix for hostvars not taken correctly.

This commit is contained in:
Emiliano Vavassori 2016-02-18 01:22:05 +01:00
parent 14e7126cca
commit b6e1cf7711
6 changed files with 26 additions and 10 deletions

View File

@ -16,7 +16,7 @@
purge: yes
with_items: "{{ base_client_delpkg }}"
become: yes
when: hostvars.hostname.role == 'client' and base_client_delpkg|length > 0
when: ansible_local.noderole.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: hostvars.hostname.role == 'docenti' and base_docenti_delpkg|length > 0
when: ansible_local.noderole.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: hostvars.hostname.role == 'client' and base_client_addpkg|length > 0
when: ansible_local.noderole.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: hostvars.hostname.role == 'docenti' and base_docenti_addpkg|length > 0
when: ansible_local.noderole.role == 'docenti' and base_docenti_addpkg|length > 0
- name: Correggo NetworkManager per gestire la rete
lineinfile:

View File

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

View File

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

View File

@ -10,16 +10,16 @@
name: '{{ item }}'
state: present
become: yes
with_items: "{{ hostvars.localhost.addpkg }}"
when: hostvars.localhost.addpkg is defined and hostvars.localhost.addpkg|join(' ')|trim != ''
with_items: "{{ ansible_local.noderole.addpkg }}"
when: ansible_local.noderole.addpkg is defined and ansible_local.noderole.addpkg|join(' ')|trim != ''
- name: Removing packages for specific role from NetworkPackageManager
apt:
name: '{{ item }}'
state: absent
purge: yes
with_items: "{{ hostvars.localhost.delpkg }}"
when: hostvars.localhost.delpkg is defined and hostvars.localhost.delpkg|join(' ')|trim != ''
with_items: "{{ ansible_local.noderole.delpkg }}"
when: ansible_local.noderole.delpkg is defined and ansible_local.noderole.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 }}'

View File

@ -39,5 +39,13 @@
owner: root
group: root
- name: Creating facts.d script for node role
template:
src: noderole.fact
dest: /etc/ansible/facts.d/noderole.fact
mode: 0755
owner: root
group: root
- name: Loading repo/pkg versions
setup: filter=ansible_local

View File

@ -0,0 +1,8 @@
#!/usr/bin/env python
from urllib import urlopen
from yaml import load
from json import dumps
with urlopen('http://' + {{ ansible_local.domain.serverfqdn }} + ':3000/ansible_host?host=localhost') as file:
print(dumps(load(file)))