community.crypto.acme_account (2.18.0) — module

Create, modify or delete ACME accounts

Authors: Felix Fontein (@felixfontein)

Install collection

Install with ansible-galaxy collection install community.crypto:==2.18.0


Add to requirements.yml

  collections:
    - name: community.crypto
      version: 2.18.0

Description

Allows to create, modify or delete accounts with a CA supporting the L(ACME protocol,https://tools.ietf.org/html/rfc8555), such as L(Let's Encrypt,https://letsencrypt.org/).

This module only works with the ACME v2 protocol.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Make sure account exists and has given contacts. We agree to TOS.
  community.crypto.acme_account:
    account_key_src: /etc/pki/cert/private/account.key
    state: present
    terms_agreed: true
    contact:
    - mailto:me@example.com
    - mailto:myself@example.org
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Make sure account has given email address. Do not create account if it does not exist
  community.crypto.acme_account:
    account_key_src: /etc/pki/cert/private/account.key
    state: present
    allow_creation: false
    contact:
    - mailto:me@example.com
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Change account's key to the one stored in the variable new_account_key
  community.crypto.acme_account:
    account_key_src: /etc/pki/cert/private/account.key
    new_account_key_content: '{{ new_account_key }}'
    state: changed_key
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete account (we have to use the new key)
  community.crypto.acme_account:
    account_key_content: '{{ new_account_key }}'
    state: absent

Inputs

    
state:
    choices:
    - present
    - absent
    - changed_key
    description:
    - The state of the account, to be identified by its account key.
    - If the state is V(absent), the account will either not exist or be deactivated.
    - If the state is V(changed_key), the account must exist. The account key will be
      changed; no other information will be touched.
    required: true
    type: str

contact:
    default: []
    description:
    - A list of contact URLs.
    - Email addresses must be prefixed with C(mailto:).
    - See U(https://tools.ietf.org/html/rfc8555#section-7.3) for what is allowed.
    - Must be specified when state is V(present). Will be ignored if state is V(absent)
      or V(changed_key).
    elements: str
    type: list

account_uri:
    description:
    - If specified, assumes that the account URI is as given. If the account key does
      not match this account, or an account with this URI does not exist, the module fails.
    type: str

acme_version:
    choices:
    - 1
    - 2
    description:
    - The ACME version of the endpoint.
    - Must be V(1) for the classic Let's Encrypt and Buypass ACME endpoints, or V(2) for
      standardized ACME v2 endpoints.
    - The value V(1) is deprecated since community.crypto 2.0.0 and will be removed from
      community.crypto 3.0.0.
    required: true
    type: int

terms_agreed:
    default: false
    description:
    - Boolean indicating whether you agree to the terms of service document.
    - ACME servers can require this to be V(true).
    type: bool

acme_directory:
    description:
    - The ACME directory to use. This is the entry point URL to access the ACME CA server
      API.
    - For safety reasons the default is set to the Let's Encrypt staging server (for the
      ACME v1 protocol). This will create technically correct, but untrusted certificates.
    - 'For Let''s Encrypt, all staging endpoints can be found here: U(https://letsencrypt.org/docs/staging-environment/).
      For Buypass, all endpoints can be found here: U(https://community.buypass.com/t/63d4ay/buypass-go-ssl-endpoints)'
    - For B(Let's Encrypt), the production directory URL for ACME v2 is U(https://acme-v02.api.letsencrypt.org/directory).
    - For B(Buypass), the production directory URL for ACME v2 and v1 is U(https://api.buypass.com/acme/directory).
    - For B(ZeroSSL), the production directory URL for ACME v2 is U(https://acme.zerossl.com/v2/DV90).
    - For B(Sectigo), the production directory URL for ACME v2 is U(https://acme-qa.secure.trust-provider.com/v2/DV).
    - The notes for this module contain a list of ACME services this module has been tested
      against.
    required: true
    type: str

allow_creation:
    default: true
    description:
    - Whether account creation is allowed (when state is V(present)).
    type: bool

validate_certs:
    default: true
    description:
    - Whether calls to the ACME directory will validate TLS certificates.
    - B(Warning:) Should B(only ever) be set to V(false) for testing purposes, for example
      when testing against a local Pebble server.
    type: bool

account_key_src:
    aliases:
    - account_key
    description:
    - Path to a file containing the ACME account RSA or Elliptic Curve key.
    - 'Private keys can be created with the M(community.crypto.openssl_privatekey) or
      M(community.crypto.openssl_privatekey_pipe) modules. If the requisite (cryptography)
      is not available, keys can also be created directly with the C(openssl) command
      line tool: RSA keys can be created with C(openssl genrsa ...). Elliptic curve keys
      can be created with C(openssl ecparam -genkey ...). Any other tool creating private
      keys in PEM format can be used as well.'
    - Mutually exclusive with O(account_key_content).
    - Required if O(account_key_content) is not used.
    type: path

request_timeout:
    default: 10
    description:
    - The time Ansible should wait for a response from the ACME API.
    - This timeout is applied to all HTTP(S) requests (HEAD, GET, POST).
    type: int
    version_added: 2.3.0
    version_added_collection: community.crypto

account_key_content:
    description:
    - Content of the ACME account RSA or Elliptic Curve key.
    - Mutually exclusive with O(account_key_src).
    - Required if O(account_key_src) is not used.
    - "B(Warning:) the content will be written into a temporary file, which will be deleted\
      \ by Ansible when the module completes. Since this is an important private key \u2014\
      \ it can be used to change the account key, or to revoke your certificates without\
      \ knowing their private keys \u2014, this might not be acceptable."
    - In case C(cryptography) is used, the content is not written into a temporary file.
      It can still happen that it is written to disk by Ansible in the process of moving
      the module with its argument to the node where it is executed.
    type: str

new_account_key_src:
    description:
    - Path to a file containing the ACME account RSA or Elliptic Curve key to change to.
    - Same restrictions apply as to O(account_key_src).
    - Mutually exclusive with O(new_account_key_content).
    - Required if O(new_account_key_content) is not used and O(state) is V(changed_key).
    type: path

select_crypto_backend:
    choices:
    - auto
    - cryptography
    - openssl
    default: auto
    description:
    - Determines which crypto backend to use.
    - The default choice is V(auto), which tries to use C(cryptography) if available,
      and falls back to C(openssl).
    - If set to V(openssl), will try to use the C(openssl) binary.
    - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/)
      library.
    type: str

account_key_passphrase:
    description:
    - Phassphrase to use to decode the account key.
    - B(Note:) this is not supported by the C(openssl) backend, only by the C(cryptography)
      backend.
    type: str
    version_added: 1.6.0
    version_added_collection: community.crypto

new_account_key_content:
    description:
    - Content of the ACME account RSA or Elliptic Curve key to change to.
    - Same restrictions apply as to O(account_key_content).
    - Mutually exclusive with O(new_account_key_src).
    - Required if O(new_account_key_src) is not used and O(state) is V(changed_key).
    type: str

external_account_binding:
    description:
    - Allows to provide external account binding data during account creation.
    - This is used by CAs like Sectigo to bind a new ACME account to an existing CA-specific
      account, to be able to properly identify a customer.
    - Only used when creating a new account. Can not be specified for ACME v1.
    suboptions:
      alg:
        choices:
        - HS256
        - HS384
        - HS512
        description:
        - The MAC algorithm provided by the CA.
        - If not specified by the CA, this is probably V(HS256).
        required: true
        type: str
      key:
        description:
        - Base64 URL encoded value of the MAC key provided by the CA.
        - Padding (V(=) symbols at the end) can be omitted.
        required: true
        type: str
      kid:
        description:
        - The key identifier provided by the CA.
        required: true
        type: str
    type: dict
    version_added: 1.1.0
    version_added_collection: community.crypto

new_account_key_passphrase:
    description:
    - Phassphrase to use to decode the new account key.
    - B(Note:) this is not supported by the C(openssl) backend, only by the C(cryptography)
      backend.
    type: str
    version_added: 1.6.0
    version_added_collection: community.crypto

Outputs

account_uri:
  description: ACME account URI, or None if account does not exist.
  returned: always
  type: str

See also