community.general.crypttab module – Encrypted Linux block devices
Note
This module is part of the community.general collection (version 10.7.3).
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.crypttab.
Synopsis
- Control Linux encrypted block devices that are set up during system boot in
/etc/crypttab.
Parameters
Parameter | Comments |
|---|---|
backing_device string | Path to the underlying block device or file, or the UUID of a block-device prefixed with |
name string / required | Name of the encrypted block device as it appears in the |
opts string | A comma-delimited list of options. See |
password path | Encryption password, the path to a file containing the password, or |
path path | Path to file to use instead of This might be useful in a chroot environment. Default: |
state string / required | Use Use Use Use Choices:
|
Attributes
Attribute | Support | Description |
|---|---|---|
check_mode | Support: full | Can run in |
diff_mode | Support: none | Will return details on what has changed (or possibly needs changing in |
Examples
- name: Set the options explicitly a device which must already exist
community.general.crypttab:
name: luks-home
state: present
opts: discard,cipher=aes-cbc-essiv:sha256
- name: Add the 'discard' option to any existing options for all devices
community.general.crypttab:
name: '{{ item.device }}'
state: opts_present
opts: discard
loop: '{{ ansible_mounts }}'
when: "'/dev/mapper/luks-' in item.device"
- name: Add entry to /etc/crypttab for luks-home with password file
community.general.crypttab:
name: luks-home
backing_device: UUID=123e4567-e89b-12d3-a456-426614174000
password: /root/keys/luks-home.key
opts: discard,cipher=aes-cbc-essiv:sha256
state: present
Collection links
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/crypttab_module.html