title: How to generate single reusable random password with ansible
body: <p>That is to say: How to evaluate the password lookup only once?</p>
  
  <pre><code>- name: Demo
    hosts: localhost
    gather_facts: False
    vars:
      my_pass: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}"
    tasks:
    - debug:
        msg: "{{ my_pass }}"
    - debug:
        msg: "{{ my_pass }}"
    - debug:
        msg: "{{ my_pass }}"
  </code></pre>
  
  <p>each debug statement will print out a different value, e.g:</p>
  
  <pre><code>PLAY [Demo] *************
  
  TASK [debug] ************
  ok: [localhost] =&gt; {
      "msg": "ZfyzacMsqZaYqwW"
  }
  
  TASK [debug] ************
  ok: [localhost] =&gt; {
      "msg": "mKcfRedImqxgXnE"
  }
  
  TASK [debug] ************
  ok: [localhost] =&gt; {
      "msg": "POpqMQoJWTiDpEW"
  }
  
  PLAY RECAP ************
  localhost                  : ok=3    changed=0    unreachable=0    failed=0   
  </code></pre>
  
  <p>ansible 2.3.2.0</p>