Passing encrypted variables to Script module via arguments.

83 views
Skip to first unread message

Rajesh N

unread,
Mar 17, 2017, 5:49:45 AM3/17/17
to Ansible Project
Folks,
    I have a file encrypted with Vault containing the logins for my VMware environment.
I also have a powershell script to execute some commands on my VMware environment. From ansible i execute the this file via the script module.
I now want to pass the encrypted logins to the powershell script as arguments to the script module. From the documentation i see that script module accepts arguments.

 Kindly let me know if this is feasible and any examples would be helpful


Regards,
Rajesh

J Hawkesworth

unread,
Mar 21, 2017, 5:30:14 AM3/21/17
to Ansible Project
Lots of options for doing this.

Have a read of the Vault documentation page: http://docs.ansible.com/ansible/playbooks_vault.html

I would probably put the vaulted variables into group_vars so that they apply to whatever group of hosts it makes sense for them to belong to (perhaps development / testing / production) and then just used the vaulted variable names as parameters for the script module.  Here's an example from one of my roles.  'domain' and 'user' are vaulted variables.

  script: setLogonAsAServiceRight.ps1 {{ domain }} {{ user }}

Hope this helps,

Jon
Reply all
Reply to author
Forward
0 new messages