Do you have any problem using vault with ad-hoc??
Here is a example of how it works.
I have a vault secret file under group_vars like below. You have to use
ansible-vault create.
# ansible-vault view group_vars/myserver.yml
Vault password:
---
ansible_user: root
ansible_ssh_pass: password1
I have my vault password stored in file which look like below:
# cat vault_key
myvault@pass
I am using ad-hoc command like below and it works. What is your problem?
# ansible myserver -m file -a "dest=/tmp/hello mode=755 state=directory" -u
root --vault-password-file vault_key
localhost | SUCCESS => {
"changed": false,
"gid": 0,
"group": "root",
"mode": "0755",
"owner": "root",
"path": "/tmp/hello",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 6,
"state": "directory",
"uid": 0
}
Thanks
Mohan L
On Monday, October 29, 2018 at 6:30:56 PM UTC+5:30, Rajendra Rawat 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/7f859c16-ee20-42fc-9ec4-fa57befbff92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.