Files
ansible-role-certificate-au…/tasks/client_certificate.yml
T
volker.raschekandCopilot e1d6e80837
Lint Markdown files / markdown-lint (push) Successful in 8s
Ansible Linter / ansible-lint (push) Successful in 2m59s
Molecule / Molecule (push) Successful in 7m45s
Release Ansible Role / Release Ansible Role (push) Successful in 1m39s
refactor: use the file extension .yml for all yaml files
The role used .yaml while the molecule scenario used .yml, because molecule hard codes molecule.yml and has no
fallback for the other extension. Aligning all files on .yml keeps the extension consistent across the repository
and avoids surprises when a tool only supports one of both spellings.

Co-authored-by: Copilot <copilot@github.com>
2026-09-08 12:24:25 +02:00

73 lines
3.1 KiB
YAML

---
- name: Create directory to store tls keys and certificates of the client
ansible.builtin.file:
path: "{{ certificate_authority_client_path }}"
owner: "root"
group: "root"
mode: "0755"
state: directory
- name: Verify that the signing intermediate Certificate Authority (CA) is available
when: certificate_authority_client_create is defined and
certificate_authority_client_create
block:
- name: Check private key of the intermediate Certificate Authority (CA)
ansible.builtin.stat:
path: "{{ certificate_authority_intermediate_ca_path }}/privkey.pem"
register: _intermediate_ca_privkey
- name: Assert that the private key of the intermediate Certificate Authority (CA) exists
ansible.builtin.assert:
that: _intermediate_ca_privkey.stat.exists
fail_msg: >-
Signing the client certificate requires
{{ certificate_authority_intermediate_ca_path }}/privkey.pem. Either unset
certificate_authority_intermediate_ca_skip so the intermediate certificate authority is
created or imported, or point certificate_authority_intermediate_ca_path to an existing one.
- name: Create unprotected client certificate
ansible.builtin.include_tasks: client_certificate_unprotected.yml
when: certificate_authority_client_create is defined and
certificate_authority_client_create and
certificate_authority_client_tls_key_passphrase is defined and
certificate_authority_client_tls_key_passphrase | length <= 0
- name: Create passphrase protected client certificate
ansible.builtin.include_tasks: client_certificate_protected.yml
when: certificate_authority_client_create is defined and
certificate_authority_client_create and
certificate_authority_client_tls_key_passphrase is defined and
certificate_authority_client_tls_key_passphrase | length > 0
- name: Import client certificate
ansible.builtin.include_tasks: client_certificate_import.yml
when: certificate_authority_client_create is defined and
not certificate_authority_client_create
- name: Create certificate chain file
ansible.builtin.include_tasks: concatenate.yml
vars:
_concat_sources:
- "{{ certificate_authority_client_path }}/cert.pem"
- "{{ certificate_authority_intermediate_ca_path }}/cert.pem"
_concat_dest: "{{ certificate_authority_client_path }}/chain.pem"
_concat_mode: "0644"
- name: Create certificate fullchain file
ansible.builtin.include_tasks: concatenate.yml
vars:
_concat_sources:
- "{{ certificate_authority_client_path }}/cert.pem"
- "{{ certificate_authority_intermediate_ca_path }}/chain.pem"
_concat_dest: "{{ certificate_authority_client_path }}/fullchain.pem"
_concat_mode: "0644"
- name: Create file with private key and fullchain file of the client
ansible.builtin.include_tasks: concatenate.yml
vars:
_concat_sources:
- "{{ certificate_authority_client_path }}/privkey.pem"
- "{{ certificate_authority_client_path }}/fullchain.pem"
_concat_dest: "{{ certificate_authority_client_path }}/all.pem"
_concat_mode: "0600"