Closed j0hann3s closed 1 month ago
I'm not sure I understand what is the problem, the docs says:
data:
description:
- The value of the secret. Required when C(state) is C(present).
type: str
It should be value, not the file path. If you want to use file path it will be a feature request, but currently everything works as designed and documented.
@sshnaidm Yes, the documentation inside this repo does mention what you cited above, but I am referring to Podman's documentation of the secret subcommand and how it is intended to be used.
As I understand it, Ansible modules are wrappers for the actual underlying program (in this case Podman with the secret subcommand) and are supposed to mimic the original functionality as closely as possible with some extra checks (exit status, etc.). But this module says that it uses the driver file by default (like Podman) which Podman originally refers to as an actual file containing the secret. This module, however, does not honor the option driver with the file value in the same sense as Podman originally.
The documentation on both containers.github.io and docs.ansible.com mentions:
driver Override default secrets driver, currently podman uses file which is unencrypted.
But using this option explicitly (driver: file) does still use a literal string provided in the actual Yaml/Playbook which partially defeats the Podman secret functionality which tries to separate sensitive data from configuration files (be it podman-compose files, Containerfiles, or Ansible Playbook's which easily can wind up committed into repos). In other words, the option driver with the value file should read from the passed file. Otherwise, I do not see any meaning in having the option if everything is going to be passed as stdin.
I would even consider this somewhat of a security risk due to how one transitioning from writing podman secret create <NAME> <PATH>
to a task in an Ansible play could unintentionally set a certain service access token/password to the secret's file path and not content. So that one's, for example, reverse-proxy web interface is accessible when typing in the path to the secret file (a lot easier to brute force or attack with a dictionary attack). Here one has to hope that the respective service would throw an error and mention some formatting error with the secret data which in the worst case would just be used as a seed or token as mentioned above without throwing any errors.
I see two ways this could be tackled:
(Breaking changes) The usage of the option driver with the value file (which is the current default affecting everyone) results in using the value in the option data as input for the podman secret create <NAME> <PATH>
. Using a new value, for example, stdin in the option driver results in using the literal string provided in the value of the option data.
Add the option, for example, file with the value being a file path, which ignores the data option and is used as input for the podman secret create <NAME> <PATH>
. Also, adding a warning in the documentation that using the data option without the file option will use the literal string and not a file's contents (as might expected by still having driver being the value file by default).
Alternative 1 does add an extra driver value (stdin) and encompasses breaking changes but makes it clear that either the file contents are being used as a secret or the literal string value in the data option.
Alternative 2 adds an extra option for file content usage and warns users in the documentation of the deviation from the original subcommand.
I would, even though it encompasses breaking changes, recommend the first alternative just because it makes this sensitive topic more "idiot-proof" from misconfigurations.
I strongly object to the first option, it's totally clear parameter name data
which means secret data. If we want to add a path
option to pass file, I'm only for it.
Would you like to submit a patch?
cc @amenzhinsky
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
The _containers.podman.podmansecret module does not use the default driver file correctly. The passed data value is not being used as a path to the secret file, as expected, but as a literal string. This means that Podman registers the secret as "/path/to/secret" instead of "some-password" (contents of the file). According to the Podman documentation (https://docs.podman.io/en/latest/markdown/podman-secret-create.1.html) the behavior should be: "...Create accepts a path to a file, or -, which tells podman to read the secret from stdin...". It looks like the stdin '-' option is hardcoded in this module.
Steps to reproduce the issue:
Create a text file with some data inside:
Use the following Task:
Check the contents of the Podman secret:
The output from the above command will show
"SecretData": "/tmp/some_password.secret"
(but should instead show"SecretData": "super_secret_password"
).Execute the command natively with Podman Secret:
Execute step 3 again and observe the correct SecretData value (as described at the end of step 4).
Version of the
containers.podman
collection: Either git commit if installed from git:git show --summary
Or version fromansible-galaxy
if installed from galaxy:ansible-galaxy collection list | grep containers.podman
Output of
ansible --version
:Output of
podman version
: