Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beware of the difference between vars and facts #35

Open
ericzolf opened this issue Oct 23, 2021 · 0 comments
Open

Beware of the difference between vars and facts #35

ericzolf opened this issue Oct 23, 2021 · 0 comments

Comments

@ericzolf
Copy link
Contributor

Small quiz, who can guess what happens before trying, and explain why:

---
- name: show an important difference between vars and facts
  hosts: localhost
  gather_facts: false
  become: false

  vars:
    some_var: "{{ lookup('password', '/dev/null') }}"

  tasks:
    - name: define now a fact
      set_fact:
        some_fact: "{{ lookup('password', '/dev/null') }}"
    - name: output now the fact twice
      debug:
        msg: "{{ some_fact }} vs. {{ some_fact }}"
    - name: output again the fact
      debug:
        var: some_fact
    - name: output now the variable also twice
      debug:
        msg: "{{ some_var }} vs. {{ some_var }}"
    - name: output again the variable (uups!)
      debug:
        var: some_var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant