ansible-vault | : key : Ansible role for Hashicorp Vault | DevOps library
kandi X-RAY | ansible-vault Summary
kandi X-RAY | ansible-vault Summary
:key: Ansible role for Hashicorp Vault
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ansible-vault
ansible-vault Key Features
ansible-vault Examples and Code Snippets
Community Discussions
Trending Discussions on ansible-vault
QUESTION
I can ssh to a remote server if I use the ansible command module
e.g
...ANSWER
Answered 2021-May-24 at 15:15My legendary colleague found a solution if anyone else comes across the same issue.
Ansible SSH private key in source control?
You need to copy your encrypted ssh private key to another file first to decrypt it and then you can use it e.g.
QUESTION
In order to connect to a windows host I will need to pass the credentials in an inventory file. Here's my inventory file:
...ANSWER
Answered 2021-Apr-18 at 13:03The ansible-vault
command encrypts a single file. Ansible decrypts this at runtime and interprets it the same way it would if the file had been unencrypted (so you can't "store both the variable file used in my inventory and the variable file used in my playbook in the same ansible-vault" because those are two different files).
I would just remove the variable from your inventory, leaving it like this:
QUESTION
I've been searching all over but there's not much on what should the Ansible vault password file look like.
For example I would like to do:
...ANSWER
Answered 2021-Apr-04 at 07:23The content of a Ansible vault password file should contain only the password for the Ansible vault.
Somewhat vaguely described in the official documentation: https://docs.ansible.com/ansible/latest/user_guide/vault.html#setting-a-default-password-source
That is if you do:
QUESTION
i have below script while gets some command output from a host and keeps that into a file /tmp/${stcl}_aggr.txt
, further this file is placed to a variable body=$(cat /tmp/${stcl}_aggr.txt)
While calling this Variable body
into a Jason arrays as "description": "$body"
its value is not getting expanded and resulting in error as KeyError: 'result'
, and the varible like incident_number
, curloutput
also not working while if i remove that body
for "description":
then script will run but the i need "description":
value to be uploaded.
ANSWER
Answered 2021-Apr-03 at 16:23I can reproduce similar to my lab, So, as per my understanding below should work for you.
QUESTION
Apologies for the lengthy post. I am a relatively newbie to Ansible and Vault (<2 months).
Environment:
- CentOS & Win2019 (90% Linux systems)
- Ansible 2.10.7 (master Ansible controller)
- AWX 17.0.1 (embedded ansible 2.9.17)
Ultimate goals:
- Use the same code from Git for both environments (Prod & Test)
- Ability to separate the 'secrets' values based on which environment
Basic Setup (currently):
- Ansible master controller is designed to be completely self-starting. Meaning all the settings/configs are contained within playbooks. This means I can blow-up the ANS controller and rebuild with 3 min.
- All secrets are encrypted strings within a variable file. Due to the fact AWX cannot import an vaulted file, all secrets are in-line (ansible-vault encrypt_string 'secret_data' --name 'my_secret')
- Same user accounts exists in both environments but different creds
Current Issues:
- If was to import the Git repo into my Prod Ansible master controller, any plays requiring secrets would fail (due it has the secret variable with the 'Test' values)
Thoughts to resolve:
- I thought about using the ansible 'default' function for any secret combined with a 'when' conditional based on the Inventory file. Basically if the inventory file is a 'Test' based system, use 'Test' secrets. If not, then use 'Prod' secrets.
This is an ugly solution from my perspective and must be a better solution.
- Use Hashicorp Vault. It has the ability to use namespace trees to classify creds. I have not played with this idea yet and not sure how viable it is.
I wonder what others in the industry are doing for this same problem. This is not unique issue and sure there are best practices for this situation.
Thanks
...ANSWER
Answered 2021-Mar-22 at 19:30As you want different variables based on your environment (vault secrets are just another variables) then you could use separate inventories for each environment, see https://docs.ansible.com/ansible/2.8/user_guide/playbooks_best_practices.html#alternative-directory-layout. Then, for example, inventories/prod/group_vars/all.yml
would have prod vault secrets... You would specify explicitly each inventory with ansible -i inventories/prod ...
.
In this inventories layout you could share a variable file between environments with symlinks, eg. inventories/prod/group_vars/all/010_cross_env_vars.yml
would be a symlink to ../../../010_cross_env_vars.yml
, thus pointing to variable files located in parent directory of per-environment subdirectories, ie. inventories/010_cross_env_vars.yaml
.
QUESTION
I've created an encrypted credent.yml file with this content:
...ANSWER
Answered 2021-Mar-11 at 18:06I've checked credent.yml and run
yamllint credent.yml
That show me the syntax errors.
I've added ---
at the top of file and escaped special chars.
Doing that the playbook runs fine.
QUESTION
I'm using ansible-vault
2.10.5. According to the encrypt_string
documentation, I can use --output
to save the encrypted result. The doc says:
--output
output file name for encrypt or decrypt; use - for stdout
But I tried several commands and the result seemed to always be printed to the console. For example:
...ANSWER
Answered 2021-Feb-09 at 22:00I'd rather put the target content to be encrypted in a file and use ansible-vault encrypt secretfile
and it will enctypt the file in place.
QUESTION
I have a kubernetes secrets manifest in the form of secret.j2 file which has a password key. This password key is supposed assigned a value from an ansible-vault encrypted string present in a dev.yml file. This dev.yml looks like below:-
...ANSWER
Answered 2021-Jan-23 at 22:52Q: "evaluate the dev_db_password ... while ansible templates secret.j2. Is there a way to achieve this in the same line by modifying dbpassword: ... ?"
A: Yes. There is. Try lookup plugin vars. See ansible-doc -t lookup vars
QUESTION
I have a csv file containing ip addresses and passwords. These passwords need to be encrypted and written to a file.
This is what I have tried so far:
...ANSWER
Answered 2020-Dec-30 at 16:28You are registering a variable on a task with a loop. This changes the structure of the data as described in the documentation. Debugging output
would have given you a clue.
output.results
is a list where each element contains a stdout
key (e.g. the first one being output.results.0.stdout
). Moreover, each element also contains an item
key containing the original element in the loop that was registered.
Modifying your last task like below should give you the expected result:
QUESTION
I have a dynamic inventory set up which pulls hosts and their variables from a MySQL database. The dynamic inventory itself is working perfectly.
Some of the variables inside the inventory are sensitive so I would prefer not to store them as plain text.
So as a test I encrypted a value using:
...ANSWER
Answered 2020-Nov-27 at 13:05You'll be better off putting the variables into the encrypted files. Store the encrypted files in MySQL instead of encrypted variables. If you already "have a dynamic inventory set up which pulls hosts and their variables from a MySQL database" there shouldn't be a problem to modify the setup. Pull the encrypted files from the database and store them in host_vars (and/or group_vars, play vars, role vars ...) instead of storing encrypted variables in the inventory (and/or in the code of playbook, role, ...). This way, in the code, you don't care whether a variable is encrypted or not.
For example
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ansible-vault
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page