Add ansible_certificate custom fact

This commit is contained in:
Timo Makinen 2020-08-29 15:55:51 +00:00
parent 0ae634aed2
commit c9b21a3286
2 changed files with 26 additions and 0 deletions

View file

@ -1,4 +1,15 @@
---
- name: setup ansible custom facts
file:
dest: "{{ item }}"
mode: 0755
owner: root
group: "{{ ansible_wheel }}"
state: directory
with_items:
- /etc/ansible
- /etc/ansible/facts.d
- name: set correct hostname
hostname:
name: "{{ inventory_hostname }}"

View file

@ -30,6 +30,21 @@
owner: root
group: "{{ ansible_wheel }}"
- name: add ansible certificate fact
copy:
content: |
#!/bin/sh
[ -f {{ tls_certs }}/{{ inventory_hostname }}.crt ] && awk '
BEGIN { printf "\"" }
{ if (!/^-\-/) printf "%s",$0 }
END { print "\"" }
' {{ tls_certs }}/{{ inventory_hostname }}.crt
dest: /etc/ansible/facts.d/ansible_certificate.fact
mode: 0755
owner: root
group: "{{ ansible_wheel }}"
- name: create full chain of host certficate and ca
shell: "cat {{ tls_certs }}/{{ inventory_hostname }}.crt \
{{ tls_certs }}/ca.crt > \