vagrant - Ansible not caching facts for later use -


i'm using vagrant , ansible 1.9 create qa environment haproxy front-end (in loadbalancer group) , 2 jetty backend servers (in webservers group). haproxy.cfg template following lines display ansible caching:

{% host in groups['webservers'] %}     server {{ host }} {{ hostvars[host] }}:8080 maxconn 1024 {% endfor %} 

the final config use like:

server {{ host }} {{ hostvars[host]['ansible_eth1']['ipv4']['address'] }}:8080 maxconn 1024 

to configure ip address of each backend service.

based on this: http://docs.ansible.com/guide_rolling_upgrade.html i'm using following try provoke ansible cache ip address of each webserver:

- hosts: webservers   user: vagrant   name: gather facts webservers   tasks: [] 

the webservers built first, , loadbalancer last. however, webservers' ip addresses not being cached. that's there:

server qa01 {'ansible_ssh_host': '127.0.0.1', 'group_names': ['webservers'], 'inventory_hostname': 'qa01', 'ansible_ssh_port': 2222, 'inventory_hostname_short': 'qa01'}:8080 maxconn 1024 

what need values cache? seems ansible knows values, since:

- hosts:   user: vagrant   sudo: yes   tasks:   - name: display variables/facts known host     debug: var=hostvars[inventory_hostname] 

will display full collection of values, including ip address need.

i learned @ http://jpmens.net/2015/01/29/caching-facts-in-ansible/ cached facts flushed between groups default. facts, including info need webservers, can made available when provisioning loadbalancer configuring ansible drop cache on disk. creating ansible.cfg in same folder vagrantfile fixes issue:

[defaults] fact_caching = jsonfile fact_caching_connection = /tmp/mycachedir 

this block unnecessary , removed it:

- hosts: webservers   user: vagrant   name: gather facts webservers   tasks: [] 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -