Closed arrrgi closed 1 year ago
chezmoi commands such as
status
,apply
anddiff
appear to ignore the scriptEnv config object. The only way this currently works is by runningchezmoi cd
to create a subshell which inherits the scriptEnv defined environment variables before runningapply
etc.
scriptEnv
applies to run_
scripts. It does not apply to arbitrary commands invoked by chezmoi. Changing scriptEnv
to apply to all commands run by chezmoi will require some thought about the implications and side-effects.
Thanks for the consideration.
My intention behind this feature request was to remove the need to install the VLT CLI and perform vlt login
before applying a dotfiles config, using the supported non-interactive method as described at: https://developer.hashicorp.com/vault/tutorials/hcp-vault-secrets-get-started/hcp-vault-secrets-install-cli#configure-the-hcp-vault-secrets-cli
In my prototype, I am prompting the user for these values around the same time as asking for other info such as email address, etc. When Chezmoi is updating the target with templated files with secrets, there is no need to script or manually run vlt login
as a pre-requisite task if these env vars are available, and keeps these credentials out of the source controlled config
Just wanted to add a big thanks for getting this implemented. I know I've capitalized a large amount of your time and effort recently @twpayne and @halostatue - I can't sing enough praise for how you both provide constructive support and work to keep us the demanding consumers happy!
I will factor these changes into my config before the end of this week and let you know if there are any issues. If I'm to understand correctly, env
is now the preferred config object and will be what is carried over into v3 in the future.
I will factor these changes into my config before the end of this week and let you know if there are any issues. If I'm to understand correctly,
env
is now the preferred config object and will be what is carried over into v3 in the future.
That is correct. We have not yet marked scriptEnv
as deprecated.
Describe the bug
On a new system with only chezmoi installed,
vlt
throws an error:Rather than passing the
HCP_CLIENT_ID
andHCP_CLIENT_SECRET
in the CLI when runningapply
etc, the values are set as environment variables in the scriptEnv config object.chezmoi commands such as
status
,apply
anddiff
appear to ignore the scriptEnv config object. The only way this currently works is by runningchezmoi cd
to create a subshell which inherits the scriptEnv defined environment variables before runningapply
etc.I also experienced a similar issue when running before/after Bash scripts with
set -eufo pipefail
that relied on the environment variable being set.To reproduce
Repro code available here: https://github.com/arrrgi/dotfiles/tree/feature/setup-scripts
Expected behavior
apply
,execute-template
,diff
,status
and other similar commands should read the scriptEnv config object and make the environment variables available.Output of command with the
--verbose
flagOutput of
chezmoi doctor
Additional context
Add any other context about the problem here.