1
0
Fork 0

review: block, var name, shell pipe

This commit is contained in:
juju4 2020-04-04 15:30:45 -04:00
parent cdec7e34c6
commit 1894bf07dd

View file

@ -107,11 +107,16 @@
tags: tags:
- wg-config - wg-config
- block:
- name: Create private key for unmanaged hosts - name: Create private key for unmanaged hosts
shell: "wg genkey | tee {{ wireguard_remote_directory }}/{{ item.host }}-privatekey" shell: |
set -o errexit
set -o pipefail
wg genkey | tee {{ wireguard_remote_directory }}/{{ item.host }}-privatekey
exit 0
args: args:
creates: "{{ wireguard_remote_directory }}/{{ item.host }}-privatekey" creates: "{{ wireguard_remote_directory }}/{{ item.host }}-privatekey"
register: uh_privkey register: uh_private_key
with_items: "{{ wireguard_unmanaged_hosts | default([]) }}" with_items: "{{ wireguard_unmanaged_hosts | default([]) }}"
- name: Validate permissions of unmanaged hosts' private keys - name: Validate permissions of unmanaged hosts' private keys
@ -122,7 +127,7 @@
- name: Recover existing private key for unmanaged hosts - name: Recover existing private key for unmanaged hosts
shell: "cat {{ wireguard_remote_directory }}/{{ item.host }}-privatekey" shell: "cat {{ wireguard_remote_directory }}/{{ item.host }}-privatekey"
register: uh_privkey register: uh_private_key
changed_when: false changed_when: false
with_items: "{{ wireguard_unmanaged_hosts | default([]) }}" with_items: "{{ wireguard_unmanaged_hosts | default([]) }}"
@ -138,6 +143,7 @@
register: uh_pubkey register: uh_pubkey
changed_when: false changed_when: false
with_items: "{{ wireguard_unmanaged_hosts | default([]) }}" with_items: "{{ wireguard_unmanaged_hosts | default([]) }}"
when: wireguard_unmanaged_hosts is defined and wireguard_unmanaged_hosts
- name: Generate WireGuard configuration file - name: Generate WireGuard configuration file
template: template:
@ -158,7 +164,7 @@
owner: root owner: root
group: root group: root
mode: 0600 mode: 0600
with_items: "{{ uh_privkey.results }}" with_items: "{{ uh_private_key.results }}"
- name: Check if reload-module-on-update is set - name: Check if reload-module-on-update is set
stat: stat: