community.sops.sops_encrypt – Encrypt data with sops¶
Note
This plugin is part of the community.sops collection (version 1.0.6).
To install it use: ansible-galaxy collection install community.sops
.
To use it in a playbook, specify: community.sops.sops_encrypt
.
New in version 0.1.0: of community.sops
Parameters¶
Parameter | Choices/Defaults | Comments |
---|---|---|
attributes
string
added in 2.3 of ansible.builtin
|
The attributes the resulting file or directory should have.
To get supported flags look at the man page for chattr on the target system.
This string should contain the attributes in the same order as the one displayed by lsattr.
The
= operator is assumed as default, otherwise + or - operators need to be included in the string.aliases: attr |
|
aws_access_key_id
string
added in 1.0.0 of community.sops
|
The AWS access key ID to use for requests to AWS.
Sets the environment variable
AWS_ACCESS_KEY_ID for the sops call. |
|
aws_profile
string
added in 1.0.0 of community.sops
|
The AWS profile to use for requests to AWS.
This corresponds to the sops
--aws-profile option. |
|
aws_secret_access_key
string
added in 1.0.0 of community.sops
|
The AWS secret access key to use for requests to AWS.
Sets the environment variable
AWS_SECRET_ACCESS_KEY for the sops call. |
|
aws_session_token
string
added in 1.0.0 of community.sops
|
The AWS session token to use for requests to AWS.
Sets the environment variable
AWS_SESSION_TOKEN for the sops call. |
|
azure_kv
list
/ elements=string
added in 1.0.0 of community.sops
|
Azure Key Vault URLs to use.
This corresponds to the sops
--azure-kv option. |
|
config_path
path
added in 1.0.0 of community.sops
|
Path to the sops configuration file.
If not set, sops will recursively search for the config file starting at the file that is encrypted or decrypted.
This corresponds to the sops
--config option. |
|
content_binary
string
|
The data to encrypt. Must be Base64 encoded binary data.
Please note that the module might not be idempotent if the data can be parsed as JSON or YAML.
Exactly one of content_text, content_binary, content_json and content_yaml must be specified.
|
|
content_json
dictionary
|
The data to encrypt. Must be a JSON dictionary.
Exactly one of content_text, content_binary, content_json and content_yaml must be specified.
|
|
content_text
string
|
The data to encrypt. Must be a Unicode text.
Please note that the module might not be idempotent if the text can be parsed as JSON or YAML.
Exactly one of content_text, content_binary, content_json and content_yaml must be specified.
|
|
content_yaml
dictionary
|
The data to encrypt. Must be a YAML dictionary.
Please note that Ansible only allows to pass data that can be represented as a JSON dictionary.
Exactly one of content_text, content_binary, content_json and content_yaml must be specified.
|
|
enable_local_keyservice
boolean
added in 1.0.0 of community.sops
|
|
Tell sops to use local key service.
This corresponds to the sops
--enable-local-keyservice option. |
encrypted_regex
string
added in 1.0.0 of community.sops
|
Set the encrypted key suffix.
When specified, only keys matching the regular expression will be encrypted.
This corresponds to the sops
--encrypted-regex option. |
|
encrypted_suffix
string
added in 1.0.0 of community.sops
|
Override the encrypted key suffix.
When set to an empty string, all keys will be encrypted that are not explicitly marked by unencrypted_suffix.
This corresponds to the sops
--encrypted-suffix option. |
|
encryption_context
list
/ elements=string
added in 1.0.0 of community.sops
|
List of KMS encryption context pairs of format
key:value .This corresponds to the sops
--encryption-context option. |
|
force
boolean
|
|
Force rewriting the encrypted file.
|
gcp_kms
list
/ elements=string
added in 1.0.0 of community.sops
|
GCP KMS resource IDs to use.
This corresponds to the sops
--gcp-kms option. |
|
group
string
|
Name of the group that should own the file/directory, as would be fed to chown.
|
|
hc_vault_transit
list
/ elements=string
added in 1.0.0 of community.sops
|
HashiCorp Vault key URIs to use.
For example,
https://vault.example.org:8200/v1/transit/keys/dev .This corresponds to the sops
--hc-vault-transit option. |
|
keyservice
list
/ elements=string
added in 1.0.0 of community.sops
|
Specify key services to use next to the local one.
A key service must be specified in the form
protocol://address , for example tcp://myserver.com:5000 .This corresponds to the sops
--keyservice option. |
|
kms
list
/ elements=string
added in 1.0.0 of community.sops
|
List of KMS ARNs to use.
This corresponds to the sops
--kms option. |
|
mode
raw
|
The permissions the resulting file or directory should have.
For those used to /usr/bin/chmod remember that modes are actually octal numbers. You must either add a leading zero so that Ansible's YAML parser knows it is an octal number (like
0644 or 01777 ) or quote it (like '644' or '1777' ) so Ansible receives a string and can do its own conversion from string into number.Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results.
As of Ansible 1.8, the mode may be specified as a symbolic mode (for example,
u+rwx or u=rw,g=r,o=r ). |
|
owner
string
|
Name of the user that should own the file/directory, as would be fed to chown.
|
|
path
path
/ required
|
The sops encrypt file.
|
|
pgp
list
/ elements=string
added in 1.0.0 of community.sops
|
PGP fingerprints to use.
This corresponds to the sops
--pgp option. |
|
selevel
string
|
The level part of the SELinux file context.
This is the MLS/MCS attribute, sometimes known as the
range .When set to
_default , it will use the level portion of the policy if available. |
|
serole
string
|
The role part of the SELinux file context.
When set to
_default , it will use the role portion of the policy if available. |
|
setype
string
|
The type part of the SELinux file context.
When set to
_default , it will use the type portion of the policy if available. |
|
seuser
string
|
The user part of the SELinux file context.
By default it uses the
system policy, where applicable.When set to
_default , it will use the user portion of the policy if available. |
|
shamir_secret_sharing_threshold
integer
added in 1.0.0 of community.sops
|
The number of distinct keys required to retrieve the data key with Shamir's Secret Sharing.
If not set here and in the sops config file, will default to
0 .This corresponds to the sops
--shamir-secret-sharing-threshold option. |
|
sops_binary
path
added in 1.0.0 of community.sops
|
Path to the sops binary.
By default uses
sops . |
|
unencrypted_regex
string
added in 1.0.0 of community.sops
|
Set the unencrypted key suffix.
When specified, only keys matching the regular expression will be left unencrypted.
This corresponds to the sops
--unencrypted-regex option. |
|
unencrypted_suffix
string
added in 1.0.0 of community.sops
|
Override the unencrypted key suffix.
This corresponds to the sops
--unencrypted-suffix option. |
|
unsafe_writes
boolean
added in 2.2 of ansible.builtin
|
|
Influence when to use atomic operation to prevent data corruption or inconsistent reads from the target file.
By default this module uses atomic operations to prevent data corruption or inconsistent reads from the target files, but sometimes systems are configured or just broken in ways that prevent this. One example is docker mounted files, which cannot be updated atomically from inside the container and can only be written in an unsafe manner.
This option allows Ansible to fall back to unsafe methods of updating files when atomic operations fail (however, it doesn't force Ansible to perform unsafe writes).
IMPORTANT! Unsafe writes are subject to race conditions and can lead to data corruption.
|
See Also¶
See also
- community.sops.sops lookup
The sops lookup can be used decrypt sops-encrypted files.
Examples¶
- name: Encrypt a secret text
community.sops.sops_encrypt:
path: text-data.sops
content_text: This is a secret text.
- name: Encrypt the contents of a file
community.sops.sops_encrypt:
path: binary-data.sops
content_binary: "{{ lookup('ansible.builtin.file', '/path/to/file', rstrip=false) | b64encode }}"
- name: Encrypt some datastructure as YAML
community.sops.sops_encrypt:
path: stuff.sops.yaml
content_yaml: "{{ result }}"
Authors¶
Felix Fontein (@felixfontein)