Skip to content

Instantly share code, notes, and snippets.

@zeitounator
Created March 11, 2020 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeitounator/6f5d02c1539b1edd0002d2e20c00113d to your computer and use it in GitHub Desktop.
Save zeitounator/6f5d02c1539b1edd0002d2e20c00113d to your computer and use it in GitHub Desktop.
$ cat test.yaml
---
- hosts: localhost
gather_facts: false
vars:
cache_mgmt:
dev_web:
backend_name: www_http_be
backend_hosts: dev_www
dit_web:
backend_name: www_http_be
backend_hosts: dit_www
tasks:
- set_fact:
backend_name: "{{ cache_mgmt[configs_target].backend_name }}"
- debug:
var: backend_name
$ ansible-playbook test.yaml -e '{"configs_target":"dev_web"}'
PLAY [localhost] **************************************************************************************************************************************************************************************************
TASK [set_fact] ***************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [debug] ******************************************************************************************************************************************************************************************************
ok: [localhost] => {
"backend_name": "www_http_be"
}
PLAY RECAP ********************************************************************************************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment