david_igou.routeros_configuration.certificate role – Create and sign RouterOS certificates over the API.
Note
This role is part of the david_igou.routeros_configuration collection (version 0.0.8-alpha).
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 david_igou.routeros_configuration.
To use it in a playbook, specify: david_igou.routeros_configuration.certificate.
Entry point main – Create and sign RouterOS certificates over the API.
Synopsis
Creates certificate requests and signs them, idempotently (by name; a cert that already exists and is signed is left untouched).
Uses
community.routeros.apibecause api_modify treatscertificateas read-only.
Parameters
Parameter |
Comments |
|---|---|
ACME (Let’s Encrypt) requests. Gated/untested on a CHR. Default: |
|
Arguments passed to /certificate add-acme. |
|
API hostname/IP of the device. Default: |
|
API password. Secret — supply via vault. The module marks it no_log. |
|
TCP port; empty lets the module choose from tls. Default: |
|
Use TLS (api-ssl). Choices:
|
|
API username. Default: |
|
Validate the device TLS certificate. Choices:
|
|
Certificates to create and sign. Default: |
|
Name of the signing CA certificate. Omit for self-signed. |
|
Certificate common name (CN). |
|
Validity period in days. Default: |
|
RSA key size. Default: |
|
Key usages (e.g. |
|
Certificate name. |
|
Certificates to export to files on the device. Default: |
|
Passphrase to encrypt the exported key. |
|
Output file name (default = name). |
|
Certificate name to export. |
|
Export type (pem/pkcs12). Default: |
|
Certificates to import from files. Default: |
|
File to import. |
|
Name for the imported certificate. |
|
Passphrase for an encrypted key. |
Examples
# Create a self-signed CA (no ca:) and a host certificate signed by it.
# Idempotent by name.
- hosts: routers
gather_facts: false
roles:
- role: david_igou.routeros_configuration.certificate
vars:
routeros_certificates:
- name: local-ca
common_name: Local CA
key_usage:
- key-cert-sign
- crl-sign
- name: api-cert
common_name: router.example.com
ca: local-ca
# Export a certificate to a PEM file on the device (passphrase-protected key).
- hosts: routers
gather_facts: false
roles:
- role: david_igou.routeros_configuration.certificate
vars:
routeros_certificates_export:
- name: local-ca
file_name: local-ca
type: pem
export_passphrase: "{{ vault_cert_passphrase }}"
# Import a certificate from a file already on the device, naming it on import.
- hosts: routers
gather_facts: false
roles:
- role: david_igou.routeros_configuration.certificate
vars:
routeros_certificates_import:
- file_name: api-cert.crt
name: api-cert-imported
passphrase: "{{ vault_cert_passphrase }}"