Last Updated: December 04, 2018
· koen

Use macOS keychain for Ansible vault passwords

Since version 1.7, Ansible allows the vault password file to be a script, which made me think that it should be able to make this work with the macOS keychain. And so I did:

I created ~/.bin/ansible-vault-pass with the following content:

NAME=$(basename "$PWD" | sed -e 's/ /-/g')
security find-generic-password -a ansible_vault_$NAME -w

And made it executable:

chmod +x ~/.bin/ansible-vault-pass

Configured ansible in ansible.cfg:

vault_password_file = ~/.bin/ansible-vault-pass

And added a password for my vault to the keychain:

security add-generic-password -a ansible_vault_my-project -s ansible -w P4ssw0rd

The "account" (-a) of the password is ansible_value_ combined with the directory name from which the Ansible command was invoked. I'm still thinking about maybe a username file in the directory to prevent any directory renames and such.

And now I can run all my Ansible commands without ever entering my password 🎉.

12 Responses
Add your response


The article is interesting and useful. I tried it and found it really useful. Thank you very much. https://wifinamesfunny.com

4 months ago ·

I am making a program for unique and very strong passwords generator which will be unbreakable but i need little help or advice any person have experience? http://www.DissertationHouse.co.uk/

3 months ago ·

I am still considering the username file in the directory to prevent any directory renaming etc https://www.dissertationstore.co.uk/.

3 months ago ·

Uk Students Assignment Help services are continue visible at the StudentsAssignmentHelp.com that's best destination for you. We are continue working quality work for all our clients and make sure that all their academic needs are fulfilled. We gives a varied range of academic writing help at a low price. https://www.studentsassignmenthelp.com/uk/

3 months ago ·

Great post for those who are interested in this sphere all necessary information is well-explained. http://www.axivasichem.com

about 2 months ago ·

Great Information sharing. I am very happy to read this article. Thanks for giving us go through info. I appreciate your work. http://www.axivafilters.com/products/lab-filtration/filtration/glass-fiber-filter/

about 2 months ago ·

Thanks for providing this amazing information. I think we can expect better success with these tips. https://web-cart.com/

about 1 month ago ·

Great post for individuals who are interested in this sphere all essential facts is nicely-defined. https://mentorshouse.co.uk/

about 1 month ago ·

MacOs keychain is good for those who don’t remember their password and username and it is also save but one thing is I also wanted to use this for me because the same problem happened to me I didn’t remember my passwords but I don’t how it works and I need help to work on this as I am now working on https://www.assignmentmaster.co.uk/hnd-assignment/ and also include this in my assignment writing.

28 days ago ·

am making a program for unique and very strong passwords generator which will be unbreakable but i need little help or advice any person have experience? https://apkmodsgames.com

28 days ago ·

I think that this will be better options and all passwords will be easily manageable using your tips and guidelines. https://www.theacademicpapers.co.uk/dissertation-writing-services-uk.php

17 days ago ·

<a href="https://adaway.pro/">open source android app</a> |
<a href="https://droid4x.online/">droi4x offline installer</a>
Tubi Tv: Do you love watching movies and TV series? Are you searching for an app that lets you watch your favorite shows and movies for free? If yes, then you are in the right place. In today’s post, we will be discussing Tubi TV. Tubi (a.k.a. TubiTV) is a movie and TV streaming service that you can download and use for absolutely free.

7 days ago ·
Filed Under