Try something like...
ansible --vault-id ~/.vault -e @ yourvault.yml
This will expose the variables for your use, like in your inventory
ansible_become: true
ansible_become_method: su
ansible_become_user: root
ansible_become_pass: "{{ var_from_vault }}"
inventory example
https://lathama.net/git/lathama/IaC/src/branch/master/Infrastructure/inventory.yml
How I do this with playbooks
https://lathama.net/git/lathama/IaC/src/branch/master/Infrastructure
On Mon, Oct 29, 2018, 8:00 AM Rajendra Rawat <[email protected]>
wrote:
>
> Hi All,
>
> Is it possible to use ansible-vault with ad-hoc commands.
> Use case: I have not setup ssh key and I want to use ping module on
target machine.
>
> normal way if we have setup sshkey or pass the text password
> 1: ansible <target_hostname> -m ping [if ssh key configured]
> 2: ansible <target_hostname> -m ping --extra-vars
"ansible_user=<username> ansible_password=<password>"
>
> But I want to do this with ansible-vault.
> Is it possible ? any help would be appreciated.
>
> Thanks & Regards
>
> Rajendra Rawat
>
> --
> You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAGvnwVFgUQ0Zmqfdsgi8vXbcGZCuf%3Dg0fDLrPbaBj82eaUyN2w%40mail.gmail.com
.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CA%2Bqj4S_zfOj1XPhQp_getOJDBtSJBKAgnEeLn-91n_%2B%3DZ94BZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.