community.general.htpasswd – manage user files for basic authentication¶
Note
This plugin is part of the community.general collection (version 1.3.6).
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.htpasswd
.
Synopsis¶
Add and remove username/password entries in a password file using htpasswd.
This is used by web servers such as Apache and Nginx for basic authentication.
Parameters¶
Notes¶
Note
This module depends on the passlib Python library, which needs to be installed on all target systems.
On Debian, Ubuntu, or Fedora: install python-passlib.
On RHEL or CentOS: Enable EPEL, then install python-passlib.
Examples¶
- name: Add a user to a password file and ensure permissions are set
community.general.htpasswd:
path: /etc/nginx/passwdfile
name: janedoe
password: '9s36?;fyNp'
owner: root
group: www-data
mode: 0640
- name: Remove a user from a password file
community.general.htpasswd:
path: /etc/apache2/passwdfile
name: foobar
state: absent
- name: Add a user to a password file suitable for use by libpam-pwdfile
community.general.htpasswd:
path: /etc/mail/passwords
name: alex
password: oedu2eGh
crypt_scheme: md5_crypt
Authors¶
Ansible Core Team