Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add encrypt_file/decrypt_file methods #301

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion cc-ansible
msherman64 marked this conversation as resolved.
Show resolved Hide resolved
msherman64 marked this conversation as resolved.
Show resolved Hide resolved
msherman64 marked this conversation as resolved.
Show resolved Hide resolved
msherman64 marked this conversation as resolved.
Show resolved Hide resolved
msherman64 marked this conversation as resolved.
Show resolved Hide resolved
msherman64 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ while [[ $# -gt 0 ]]; do
# Add proper flag support for --check as an option for dry-runs
export EXTRA_OPTS="${EXTRA_OPTS:-} --check"
;;
decrypt_passwords|edit_passwords|help|install_deps|init|view_passwords)
decrypt_passwords|edit_passwords|help|install_deps|init|view_passwords|encrypt_file|decrypt_file)
# Special subcommand!
command="$key"
;;
Expand Down Expand Up @@ -137,6 +137,18 @@ init() {
echo
}

encrypt_file() {
ansible-vault encrypt \
--vault-password-file "$CC_ANSIBLE_VAULT_PASSWORD" \
${POSARGS[@]}
msherman64 marked this conversation as resolved.
Show resolved Hide resolved
}

decrypt_file() {
ansible-vault decrypt \
--vault-password-file "$CC_ANSIBLE_VAULT_PASSWORD" \
${POSARGS[@]}
msherman64 marked this conversation as resolved.
Show resolved Hide resolved
}

edit_passwords() {
local tmpfile
local venv_bin_path="${VIRTUALENV}/bin"
Expand Down Expand Up @@ -213,6 +225,10 @@ Examples:

# Update the passwords file for the environment
cc-ansible edit_passwords

# use ansible-vault to encrypt or decrypt a file
cc-ansible encrypt_file path/to/file
cc-ansible decrypt_file path/to/file
USAGE
exit 1
}
Expand Down
Loading