Skip to content

Instantly share code, notes, and snippets.

@danrough
Created November 10, 2017 11:39
Show Gist options
  • Save danrough/42b34bd87bd3d2aee9367f9a98596468 to your computer and use it in GitHub Desktop.
Save danrough/42b34bd87bd3d2aee9367f9a98596468 to your computer and use it in GitHub Desktop.
---
- hosts: localhost
gather_facts: no
vars:
database_clusters:
- { cluster_name: "test_lon", port: 5433 }
- { cluster_name: "prod_lon", port: 5434 }
tasks:
- name: Port for {{ environment }}_{{ region | lower }}
debug: var="{{ database_clusters | selectattr('cluster_name', 'equalto', '{{ environment }}_{{ region | lower }}') | map(attribute='port') | join(',') }}"
# To run:
# ansible-playbook ./dictionary-lookup.yml --extra-vars="environment=test region=LON"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment