![]() ![]() Definitely an advanced feature of Ansible, but still good to know that it exists. And this variable can be made of other variables or strings. How to parse json output in Ansible and use setfact for variable creation is published. This lookup retrieves the value of an Ansible variable. And ideally store each device information into a single csv. The magic here is done by the vars-lookup plugin. The result is lookup('vars', item + '_' + stage + '_password') - this in turn gets interpolated to the actual password from my vault-file! In this lookup I look for vars that contain my item following the _-string, then the content of the variable stage (notice the missing curly braces here), finally the _password-string. Im assuming youre using groupvars, so heres an example: groupvars/ all/ vaultedfile.yml nonvaultedfile.yml ansible-vault encrypt vaultedfile. This means that I first loop over all microservices (stored in the item-variable). This means I have nine different password-variables stored in an Ansible-vault encrypted file. These credentials are different for every microservice in every stage. Of course, every microservice needs to connect to a database using credentials. I also have a list of stages, called DEV, QA and PROD where the microservices get deployed to. The output puts quotes around everything and displays the n for a carriage return. The microservices are called foo, bar and baz. New to ansible and have a quick question. I have an Ansible role that deploys microservices, of whom I have a list of. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |