xoxys.pve/tasks/tls.yml

58 lines
1.7 KiB
YAML
Raw Normal View History

2018-08-18 14:37:48 +00:00
---
- block:
- name: Create pki folder structure
file:
path: "{{ item }}"
state: directory
recurse: True
with_items:
- /etc/pki/tls/certs
- /etc/pki/tls/private
- name: Copy certs and private key (file)
copy:
2018-08-18 15:43:50 +00:00
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
2018-08-18 15:45:38 +00:00
- { src: "{{ pve_tls_cert_source }}", dest: "/etc/pki/tls/certs", mode: "0750" }
- { src: "{{ pve_tls_key_source }}", dest: "/etc/pki/tls/private", mode: "0600" }
2018-08-18 14:37:48 +00:00
loop_control:
2018-08-18 15:43:50 +00:00
label: "{{ item.dest }}"
2018-08-18 14:52:11 +00:00
register: __pve_copy_cert_file
when: pve_tls_source_use_files
- set_fact:
__pve_copy_cert: "{{ __pve_copy_cert_file }}"
2018-08-18 14:37:48 +00:00
when: pve_tls_source_use_files
- name: Copy certs and private key (content)
copy:
2018-08-18 15:43:50 +00:00
content: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
2018-08-18 15:45:38 +00:00
- { src: "{{ pve_tls_cert_source }}", dest: "/etc/pki/tls/certs", mode: "0750" }
- { src: "{{ pve_tls_key_source }}", dest: "/etc/pki/tls/private", mode: "0600" }
2018-08-18 14:37:48 +00:00
loop_control:
2018-08-18 15:43:50 +00:00
label: "{{ item.dest }}"
2018-08-18 14:52:11 +00:00
register: __pve_copy_cert_content
when: pve_tls_source_use_content
- set_fact:
__pve_copy_cert: "{{ __pve_copy_cert_content }}"
2018-08-18 14:37:48 +00:00
when: pve_tls_source_use_content
2018-08-18 15:16:32 +00:00
- name: Copy cert/key to pve filesystem
2018-08-18 15:43:50 +00:00
command: "/bin/cp -rf {{ item.dest }} /etc/pve/nodes/{{ item[1] }}/{{ item[0].dest | basename }}"
when: item[0].changed
changed_when: item[0].changed
with_nested:
- "{{ __pve_copy_cert.results }}"
- "{{ pve_nodes }}"
2018-08-18 15:16:32 +00:00
loop_control:
2018-08-18 15:43:50 +00:00
label: "/etc/pve/nodes/{{ item[0].dest | basename }}"
2018-08-18 15:16:32 +00:00
notify: __pveproxy_restart
2018-08-18 14:37:48 +00:00
become: True
become_user: root