community.general.systemd_creds_encrypt module – systemd‘s systemd-creds encrypt plugin
Note
This module is part of the community.general collection (version 10.7.5).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.systemd_creds_encrypt.
New in community.general 10.2.0
Synopsis
- This module encrypts input using - systemd‘s- systemd-creds encrypt.
Parameters
| Parameter | Comments | 
|---|---|
| The credential name to embed in the encrypted credential data. | |
| The time when the credential shall not be used anymore. Takes a timestamp specification in the format described in  | |
| Pretty print the output so that it may be pasted directly into a unit file. Choices: 
 | |
| The secret to encrypt. | |
| The timestamp to embed into the encrypted credential. Takes a timestamp specification in the format described in  | |
| A user name or numeric UID to encrypt the credential for. If set to the special string  Requires  | 
Attributes
| Attribute | Support | Description | 
|---|---|---|
| Support: full This action does not modify state. | Can run in  | |
| Support: N/A This action does not modify state. | Will return details on what has changed (or possibly needs changing in  | 
Notes
Note
- systemd-credsrequires- systemd250 or later.
Examples
- name: Encrypt secret
  become: true
  community.general.systemd_creds_encrypt:
    name: db
    not_after: +48hr
    secret: access_token
  register: encrypted_secret
- name: Print the encrypted secret
  ansible.builtin.debug:
    msg: "{{ encrypted_secret }}"
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Description | 
|---|---|
| The Base64 encoded encrypted secret. Returned: always Sample:  | 
