Closed onedr0p closed 3 months ago
Actually this looks might be related https://github.com/ansible-collections/community.sops/issues/104
For now I added a tasks to rename the sops configuration file, use sops_encrypt and then restore the sops configuration file. I wonder if there is a more elegant way to solve this though?
It is exactly #104: /dev/stdin
is not covered by any of your creation_rules
, so sops itself balks. This is essentially https://github.com/getsops/sops/issues/594.
I hope that with the new maintainers of sops we now have a chance to get this fixed (i.e. something implemented that helps to work around this).
LOL, I just realized I managed to overlook that you are one of the new maintainers :D Sorry for that.
You should be able to reproduce this when changing directory to /tmp/test/kubernetes
and running echo 'foo: bar' | sops --encrypted-regex '^(data|stringData)$' --age '...' --encrypt /dev/stdin
.
While using --output
as suggested in https://github.com/getsops/sops/issues/594 helps when doing this on the CLI (by adding --output test.sops.yaml
), it won't help sops_encrypt since it needs to make sure the file is written with the correct permissions etc. in an atomic fashion. For that, we cannot use --output
(and even if we could, it would be the wrong path to use). So basically we need another way to tell sops "assume this filename when looking up the creation rules", or (alternatively) a way to tell it "use what we provide on the command line, and not what is in .sops.yaml". AFAIK even the latter is not possible at the moment (and even if it would, we would need a new feature to allow using it).
LOL, I just realized I managed to overlook that you are one of the new maintainers :D Sorry for that.
No problem :D glad to see you are also helping out there as well!
I'll rename this issue and hopefully we can get a fix for it once upstream adds support for the issue you linked.
I'm not sure if this is exactly a good idea, but I just made a new creation_rule
with path_regex: /dev/stdin
and it works without complaining...
Thanks for creating this ticket btw, i just spent a couple of hours trying figure out why it worked just fine on the command line but not in ansible. It was a couple rounds of google before i landed here..
@clearlybaffled that works, not sure why I didn't think of that. Thanks for the tip!
I've started with https://github.com/getsops/sops/pull/1332, which allows to fix this.
--filename-override
encryption option.
Hi ππΌ
I am trying to use this module but it doesn't work when I have a
.sops.yaml
configuration file present. If I remove the.sops.yaml
config file my task works.env
sops configuration file
example task
ansible logs
It would be nice if we could unset config_path from always being present as I have confirmed that without this present I can encrypt. However maybe there is something else going on?