Folks,
Were dealing with some weird issue that we want to clarify, clearly were
understanding something wrong
Heres is our current playbook distribution, with roles and stuff
deploy/
├── ansible.cfg
├── filter_plugins
│ ├── search_hostvars.py
│ └── search_hostvars.pyc
├── group_vars
│ ├── all
├── install_ansible.sh
├── inventory
│ └── inventory
├── openstack.yaml
├── roles
│ ├── apt-cacher
│ │ ├── defaults
│ │ │ ├── main.yaml
│ │ │ └── trackfile
│ │ ├── files
│ │ │ └── trackfile
│ │ ├── handlers
│ │ │ └── trackfile
│ │ ├── meta
│ │ │ └── trackfile
│ │ ├── tasks
│ │ │ ├── main.yaml
│ │ │ └── trackfile
│ │ ├── templates
│ │ │ ├── etc
│ │ │ │ └── apt
│ │ │ │ └── apt.conf.d
│ │ │ │ └── 000apt-cacher-ng-proxy
│ │ │ └── trackfile
│ │ ├── trackfile
│ │ └── vars
│ │ ├── main.yaml
│ │ └── trackfile
In the apt-cacher role task main.yaml we have :
---
- name: update apt cache
sudo: yes
apt:
update_cache: yes
- name: Display all variables/facts known for a host
sudo: yes
debug: var=hostvars
- name: Configure APT to use cache server if available
sudo: yes
template: src=etc/apt/apt.conf.d/000apt-cacher-ng-proxy
dest=/etc/apt/apt.conf.d/000apt-cacher-ng-proxy owner=root group=root
mode=0644
- name: Install apt-cacher-ng on cache server
sudo: yes
apt: pkg=apt-cacher-ng state=latest install_recommends=no
In this scenario hostvars is printed ok, BUT if we try to call some value
INSIDE hostvars, it fails with template failed expected "," got "CHAR"
For example - debug: msg="{{ hostvars['rabbithost'] }}" and the KEY is
present and we see it OK on on the dict when we print hostvars
What its the way to call hostvars variables from a task in a role and
access the whole hostvars tree just fine ?
Best
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/bb1af1c6-9df6-4006-87b6-366fbca670a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.