Menu

Ansible wrote yesterday's server addresses into our load balancer from its fact cache
📰

Ansible wrote yesterday's server addresses into our load balancer from its fact cache

DEV Community: ansible·Sergey Shinder·5 days ago
#af7UQlsp
#devtoansible#devto#dev#cache#haproxy
Reading 0:00
15s threshold

Our trade portal runs on six application servers behind a pair of HAProxy machines, and Ansible writes the HAProxy configuration. The template loops over the app group and takes each server's address from its facts:

server {{ host }} {{ hostvars[host]['ansible_default_ipv4']['address'] }}:8080 check

To make playbook runs faster, we turned on fact caching: gathering = smart and a jsonfile cache on the control node. With smart gathering Ansible collects facts from a host only when the cache has none for it, and the cache keeps them for fact_caching_timeout, which defaults to a day.

On a Wednesday in October we replaced two of the application servers with new instances built from a new image. They came up with new private addresses, the site playbook configured them, and they passed their checks.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.