I’m creating dir in the following manner:
-
name: Playbook
hosts: CA
become: yes
gather_facts: no
vars:
cert_dir: /etc/ws_certs
csr: “{{out_csr.files | map(attribute=‘path’ | map(‘basename’) }}”
dir: “{{out_dir.files | map(attribute=‘path’ | map(‘basename’) }}”
req: “{{out_req.files | map(attribute=‘path’ | map(‘basename’) }}”
crt: “{{out_crt.files | map(attribute=‘path’ | map(‘basename’) }}”tasks:
- name: Find host dirs
ansible.builtin.find:
path: “{{ cert_dir }}”
file_type: directory
register: out_dir- name: print out_dir debug: var: dir - name: find crt files find: path: "{{ cert_dir }}" patterns: "*.our-domain.crt" file_type: file recurse: true register: out_crt - name: print out_crt debug: var: crt
Repeat the two above plays for out_req and out_csr
I wanted to register cert because I want to add a when statement to not run the openssl command if a cert if found in cert_dir