Created
October 1, 2020 20:11
-
-
Save dale42/cdee0a256e6f480e0899bead50ccada5 to your computer and use it in GitHub Desktop.
Ansible Playbook Vars vs Host Fact Vars Demonstration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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