title: Use ansible vault passwords for ask-become-pass and ssh password
body: <p>I would like to use ansible vault passwords for the ssh and become passwords when running ansible-playbook. This way I dont need to type them in when using the parameters --ask-become-pass or the ssh password.</p>
  <p><strong>Problem:</strong>
  Every time I run my ansible-playbook command I am prompted for a ssh and become password.</p>
  <p>My original command where I need to type the SSH and become password:</p>
  <p><code>ansible-playbook playbook.yaml --ask-become-pass -e ansible_python_interpreter='/usr/bin/python3' -i inventory -k --ask-vault-pass -T 40</code></p>
  <p>Command I have tried to make ansible-playbook use my vault passwords instead of my typing them in:</p>
  <p><code>ansible-playbook playbook.yaml -e ansible_python_interpreter='/usr/bin/python3' -i inventory -k -T 40 --extra-vars @group_vars/all/main.yaml</code></p>
  <p>I tried creating the directory structure from where the command is run group_vars/all/main.yaml, where main.yaml has my ansible vault passwords for &quot;ansible_ssh_user&quot;, &quot;ansible_ssh_pass&quot;, and &quot;ansible_become_pass&quot;</p>
  <p>I even tried putting my password in the command:</p>
  <p><code>ansible-playbook playbook.yaml -e ansible_python_interpreter='/usr/bin/python3' -i inventory -k -T 40 --extra-vars ansible_ssh_pass=$'&quot;MyP455word&quot;'</code></p>
  <p><code>ansible-playbook playbook.yaml -e ansible_python_interpreter='/usr/bin/python3' -i inventory -k -T 40 --extra-vars ansible_ssh_pass='MyP455word'</code></p>
  <p>Every time I run my playbook command, I keep getting prompted for a SSH pass and become pass. What am I missing here?</p>
  <p>I have already read these two posts, both of which were not clear to me on the exact process, so neither helped:
  <a href="https://serverfault.com/questions/686347/ansible-command-line-retriving-ssh-password-from-vault">https://serverfault.com/questions/686347/ansible-command-line-retriving-ssh-password-from-vault</a></p>
  <p><a href="https://stackoverflow.com/questions/46980859/ansible-vault-password-in-group-vars-not-detected">Ansible vault password in group_vars not detected</a></p>
  <p>Any recommendations?</p>
  <p><strong>EDIT</strong>: Including my playbook, role, settings.yaml, and inventory file as well.</p>
  <p>Here is my playbook:</p>
  <pre><code>- name: Enable NFS server
    hosts: nfs_server
    gather_facts: False
    become: yes
    roles:
      - { role: nfs_enable }
  </code></pre>
  <p>Here is the role located in roles/nfs_enable/tasks/main.yaml</p>
  <pre><code>- name: Include vars
    include_vars:
        file: ../../../settings.yaml
        name: settings
  
  - name: Start NFS service on server
    systemd:
      state: restarted
      name: nfs-kernel-server.service
  </code></pre>
  <p>Here is my settings file</p>
  <pre><code>#nfs share directory
  nfs_ssh_user: admin
  nfs_share_dir: &quot;/nfs-share/logs/&quot;
  
  ansible_become_pass: !vault |
            $ANSIBLE_VAULT;1.1;AES256
            55543131373731393764333932626261383765326432613239356638616234643335643438326165
            3332363366623937386635653463656537353663326139360a316436356634386135653038643238
            61313123656332663232633833366133373630396434346165336337623364383261356234653461
            3335386135553835610a303666346561376161366330353935363937663233353064653938646263
            6539
  ansible_ssh_pass: !vault |
            $ANSIBLE_VAULT;1.1;AES256
            55543131373731393764333932626261383765326432613239356638616234643335643438326165
            3332363366623937386635653463656537353663326139360a316436356634386135653038643238
            61313123656332663232633833366133373630396434346165336337623364383261356234653461
            3335386135553835610a303666346561376161366330353935363937663233353064653938646263
            6539
  
  </code></pre>
  <p>Here is my inventory</p>
  <pre><code>[nfs_server]
  10.10.10.10 ansible_ssh_user=admin ansible_ssh_private_key_file=~/.ssh/id_ed25519
  </code></pre>