Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Last active August 29, 2015 14:05
Show Gist options
  • Save StanAngeloff/5a2a95752e2f6c571668 to your computer and use it in GitHub Desktop.
Save StanAngeloff/5a2a95752e2f6c571668 to your computer and use it in GitHub Desktop.
Ansible dictionary merge, can be used to allow inventory/hosts/groups to override defaults
---
- name: Create PgBouncer configuration
sudo: true
ini_file: >
backup=yes
dest=/etc/pgbouncer/pgbouncer.ini
section=pgbouncer
option="{{ item.key }}"
value="{{ item.value }}"
state="{% if item.value != None %}present{% else %}absent{% endif %}"
owner=postgres group=postgres
mode=0640
# Merge pgbouncer_defaults with pgbouncer_configuration
with_dict: "{% set merged = ( pgbouncer_defaults | default({}) ) %}{% set noop = merged.update( pgbouncer_configuration | default({}) ) %}{{ merged }}"
notify: restart pgbouncer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment