Skip to content

Commit

Permalink
Adds vault-id lookup to password guesser
Browse files Browse the repository at this point in the history
  • Loading branch information
zellio committed Oct 17, 2021
1 parent 4f3c4e8 commit 450c0ba
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ansible-vault.el
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ you for a password."
:type 'string
:group 'ansible-vault)

(defcustom ansible-vault-vault-id-alist '()
"Associative list of strings containing (vault-id . password-file) pairs.
This list allows for managing `ansible-vault' password files via
the 1.2 vault-id syntax."
:type '(alist :key-type string :value-type string)
:group 'ansible-vault)

(defvar ansible-vault--file-header-regex
(rx line-start
"$ANSIBLE_VAULT;" (group "1." (in (?0 . ?2))) ";AES" (optional "256")
Expand Down Expand Up @@ -186,8 +194,10 @@ ANSIBLE_VAULT_PASSWORD_FILE, the ansible vault configuration files, and the
minor-mode configured value. If that fails, it will prompt the user for
input."
(interactive)
(let ((env-val (getenv "ANSIBLE_VAULT_PASSWORD_FILE")))
(let ((env-val (getenv "ANSIBLE_VAULT_PASSWORD_FILE"))
(vault-id-pair (assoc ansible-vault--vault-id ansible-vault-vault-id-alist)))
(cond ((> (length env-val) 0) env-val)
(vault-id-pair (cdr vault-id-pair))
((> (length (ansible-vault--process-config-files)) 0) '())
(t (or ansible-vault-password-file (ansible-vault--request-password))))
))
Expand Down

0 comments on commit 450c0ba

Please sign in to comment.