Skip to content

Instantly share code, notes, and snippets.

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 dale42/cdee0a256e6f480e0899bead50ccada5 to your computer and use it in GitHub Desktop.
Save dale42/cdee0a256e6f480e0899bead50ccada5 to your computer and use it in GitHub Desktop.
Ansible Playbook Vars vs Host Fact Vars Demonstration
- hosts: example.com
gather_facts: no
vars:
timestamp_var: "{{ lookup('pipe', 'date +%H:%M:%S') }}"
tasks:
- name: Set the playbook timestamp (so it doesn't change)
set_fact:
timestamp_host_fact: "{{ lookup('pipe', 'date +%H:%M:%S') }}"
- debug:
msg: "timestamp_var: {{ timestamp_var }} / timestamp_host_fact: {{ timestamp_host_fact }}"
- pause:
seconds: 3
- debug:
msg: "timestamp_var: {{ timestamp_var }} / timestamp_host_fact: {{ timestamp_host_fact }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment