xolyu.acmesh
acme·sh
Installs acme.sh from the latest Release on GitHub.
This Role creates a normal user (called acmesh by default), if it does not exist and installes acme.sh as this user, by default in it's home directory. A certificate renewal cronjob is created for this user and a bash alias acmesh is defined.
Certificates store is separated from user's home. The certificates store path is configured with acmesh_cert_dir (defaults to /etc/acme-certs). The acmesh_cert_dir_rights defines the rights for the certificates directory: group ownership and mode. To set the correct mode for the certificates there is the script certs-fix-permissions.sh.
Only the web root mode is supported for automatically certificate issuing.
Calling the role with acmesh_certs variable set enables automated certificate management.
Requirements
- Systempackage
unzipfor Ansiblesunarchivemodule. - Systempackage
curlfor acme.sh to work, alternativelywget.
For automatic ensuring of the packages, see variable acmesh_ensure_requirements.
Role Variables
acmesh_state
Defines which state is to apply. Whilepresentensures that acme.sh is installed,updatedalways runs the installation and update routine to determine whether a new version is available or the desired version is installed.
Choices:present,updated
Default:presentacmesh_version
Specifies which version to install. Whilelatestinstalls the version of the latest release, specifying a tag name can install a special version and also allows downgrading.masterinstalls the version of the master branch.
Note thatacmesh_version: masterin combination withacmesh_state: updatedis not idempotent.
Choices:latest,master,<tag>
Default:latestacmesh_configure
Allows to limit the frequency of configuration. Whilealwaysruns the configuration every time the role is executed,on_installallows the configuration to stop when the role is executed but the application is already installed. Theon_installsetting is useful when the role is executed to issue certificates or disable renewal.
Choices:always,on_install
Default:on_installacmesh_ensure_requirements
Provides for the installation of the packages listed under requirements.
Type: bool
Default:noacmesh_user
The user for executing acme.sh.
Default:acmeshacmesh_user_home
The user home directory while creating the user. Home directory is not moved later.
Default: undefinedacmesh_install_root
The directory where acme.sh should be installed.
Default:~/acmeshacmesh_scripts_dir
The directory for scripts, shipped with acmesh role.
If it is a relative path,acmesh_install_rootis assumed to be the base path.
Default:scriptsacmesh_cert_dir
The directory for the certificates.
Default:/etc/acme-certsacmesh_challange_dir
The directory for the acme-challange on.well-known/acme-challange.
Default:/var/www/acme-challangeacmesh_cert_dir_rights
Controles the ownership and mode for the certificates directory.
Sub keys are:group,mode.
Type: Dict
Default:acmesh_cert_dir_rights: group: "{{ acmesh_user }}" mode: '0750'When
groupis defined, it makes sense to setmodeto02750.
Example:acmesh_cert_dir_rights: group: www-data mode: '02750'acmesh_certs_mode
Mode for elements in the certificates directory. Values are templated to certs-fix-permissions.sh script, used as value for chmod command.
Sub keys are:dirs,files.
Type: Dict
Default:750(dirs),640(files)
Configuration
acmesh_default_ca
Configures the default CA when requesting certificates without the explicit specification of the server. Could be a Short Name, defined by acme.sh or a URL.
Default:letsencryptacmesh_default_chain
Configures the default Chain for a specific CA (server).
Type: List of Dicts
Default:- server: letsencrypt chain: ISRGacmesh_cron_state
Whether the cronjob should be present or absent.
Choices:present,absent,ignored
Default:presentacmesh_cron_hour
The hour value for the cronjob. Defaults to*if it is unset or empty.
Default:3acmesh_cron_minute
The minute value for the cronjob. Defaults to0if it is unset or empty.
Default:40acmesh_cron_weekday
The weekday value for the cronjob. Defaults to*if it is unset or empty.
Default:0,3acmesh_cron_day
The day value for the cronjob. Defaults to*if it is unset or empty.
Default: undefinedacmesh_bash_aliases
Whether the bash aliases should be present or absent.
Choices:present,absent
Default:present
Certificate handling
acmesh_keylength_rsa
Used keylenght iftypeis defined asrsaorboth(when rsa cert is issued). Concerns certificate issue withacmesh_certs.
Choices: see acme.sh documentation
Default:4096acmesh_keylength_ecc
Used keylenght iftypeis defined aseccorboth(when ecc cert is issued). Concerns certificate issue withacmesh_certs.
Choices: see acme.sh documentation
Default:ec-384acmesh_default_cert_test
Defines if issued certificates are issued as test certificates or not. This is the fallback iftestin theacmesh_certslist is not set, sotestsetting inacmesh_certslist has a stronger effect.
Type: bool
Default:noacmesh_ignore_cert_errors
Specifies whether errors in the certification command are ignored. If errors are not ignored, the entire playbook execution stops in case of an error.
Type: bool
Default:yesacmesh_certs
The certificates that are to be issued or whose renewal is to be disabled.
Type: List of Dicts
Default:[]
Sub items (Dict):domains
List of domains. First domain is primary.state
Desired state of the certificate.
The stateissuedwill enable cert if it already exists but is disabled.
Choices:issued,renewed,enabled,disabled
Default:issuedtype
Type of the certificate. For keylength defaults seeacmesh_keylength_rsaandacmesh_keylength_ecc.
Choices:rsa,ecc,both
Default:rsaforce
Forces the certificate renewing if it's enabled. Parameter--forcefrom acme.sh.
Type: bool
Default:falsetest
Uses the test/staging area from the CA if it's enabled and supported by the CA. Parameter--testfrom acme.sh.
Type: bool
Default:falseserver
CA server for issuing.keylength
Allows to set specific keylength, overwritestype, even iftype: both.
Choices: see acme.sh documentationnotify
Notify when certificate was issued or renewed.
Type: str or List of Strings
Default:[]
Dependencies
None.
Example Playbook
Make sure that acme.sh is installed and configured to use Let's Encrypt.
---
- hosts: webservers
roles:
- xolyu.acmesh
Update acme.sh to the latest release.
---
- hosts: webservers
roles:
- role: xolyu.acmesh
acmesh_state: updated
Configure acme.sh to another default CA after the installation has been completed.
---
- hosts: webservers
roles:
- role: xolyu.acmesh
acmesh_configure: always
acmesh_default_ca: zerossl
Issue an RSA test certificates for the server.
# playbook.yml
---
- hosts: webserver
vars:
acmesh_default_cert_test: yes
acmesh_certs:
- domain:
- "{{ ansible_fqdn }}"
- domain:
- myblog.example.com
roles:
- xolyu.acmesh
Issue an ECC certificate with a task by using include_role.
- name: Issue certificate.
include_role:
name: xolyu.acmesh
vars:
acmesh_certs:
- domains:
- dummy.example.com
- www.dummy.example.com
type: ecc
License
GNU General Public License v3.0
Author Information
Xolyu.
acme.sh installation and configuration, certificate requesting
ansible-galaxy install xolyu.acmesh