sub-import tls_from_file/content to minimize skips

This commit is contained in:
Robert Kaussow 2018-09-22 15:06:35 +02:00
parent 02fa767496
commit 6155049503
3 changed files with 32 additions and 28 deletions

View File

@ -13,34 +13,10 @@
become: True become: True
become_user: root become_user: root
- block: - import_tasks: tls_from_file.yml
- name: Copy certs and private key (file) when: unifi_tls_source_use_files
copy: - import_tasks: tls_from_content.yml
src: "{{ item.src }}" when: unifi_tls_source_use_content
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
- { src: "{{ unifi_tls_key_source }}", dest: '{{ unifi_tls_key_file }}', mode: '0600' }
- { src: "{{ unifi_tls_cert_source }}", dest: '{{ unifi_tls_cert_file }}', mode: '0750' }
loop_control:
label: "{{ item.dest }}"
register: __unifi_certs_file
when: unifi_tls_source_use_files
- name: Copy certs and private key (content)
copy:
content: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
- { src: "{{ unifi_tls_key_source }}", dest: '{{ unifi_tls_key_file }}', mode: '0600' }
- { src: "{{ unifi_tls_cert_source }}", dest: '{{ unifi_tls_cert_file }}', mode: '0750' }
loop_control:
label: "{{ item.dest }}"
register: __unifi_certs_content
when: unifi_tls_source_use_content
become: True
become_user: "{{ unifi_user }}"
- block: - block:
- set_fact: - set_fact:

View File

@ -0,0 +1,14 @@
---
- name: Copy certs and private key
copy:
content: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
- { src: "{{ unifi_tls_key_source }}", dest: '{{ unifi_tls_key_file }}', mode: '0600' }
- { src: "{{ unifi_tls_cert_source }}", dest: '{{ unifi_tls_cert_file }}', mode: '0750' }
loop_control:
label: "{{ item.dest }}"
register: __unifi_certs_content
become: True
become_user: "{{ unifi_user }}"

14
tasks/tls_from_file.yml Normal file
View File

@ -0,0 +1,14 @@
---
- name: Copy certs and private key
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
with_items:
- { src: "{{ unifi_tls_key_source }}", dest: '{{ unifi_tls_key_file }}', mode: '0600' }
- { src: "{{ unifi_tls_cert_source }}", dest: '{{ unifi_tls_cert_file }}', mode: '0750' }
loop_control:
label: "{{ item.dest }}"
register: __unifi_certs_file
become: True
become_user: "{{ unifi_user }}"