Skip to content

Instantly share code, notes, and snippets.

@halberom
Created June 14, 2014 20:00
Show Gist options
  • Save halberom/9efbf19ce2a600951efb to your computer and use it in GitHub Desktop.
Save halberom/9efbf19ce2a600951efb to your computer and use it in GitHub Desktop.
ansible - setting a source ip var based on other interface vars
TASK: [debug var=source_ip] ***************************************************
ok: [localhost] => {
"source_ip": "127.0.0.1"
}
---
- hosts: all
vars:
foo: localhost
pn_if: lo
tasks:
- set_fact: source_ip="{{hostvars[foo]['ansible_' + hostvars[foo]['pn_if']]['ipv4']['address']}}"
- debug: var=source_ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment