blob: 4446c76572389e5f6cb30f99aefedb07b3c6122b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
---
- hosts: tinc
tasks:
- name: create tinc folder
file:
path: /etc/ansible/tinc/
state: directory
recurse: yes
- name: generate key
command: openssl genrsa -out /etc/ansible/tinc/private.pem 2048
args:
creates: /etc/ansible/tinc/private.pem
- name: generate public
command: openssl rsa -in /etc/ansible/tinc/private.pem -outform PEM -pubout -out /etc/ansible/tinc/public_{{ network.public_hostname }}.pem
args:
creates: /etc/ansible/tinc/public_{{ network.public_hostname }}.pem
- name: get public
fetch:
src: "/etc/ansible/tinc/public_{{ network.public_hostname }}.pem"
dest: /tmp/
flat: yes
- name: distribute public
copy:
src: "/tmp/public_{{ hostvars[item].network.public_hostname }}.pem"
dest: "/etc/ansible/tinc/"
with_inventory_hostnames:
- tinc
- name: regenerate hosts
command: /etc/tinc/pdp7/generate_host_{{ hostvars[item].network.tinc.location}}.sh
with_inventory_hostnames:
- tinc
- name: restart tinc
service:
name: tinc@pdp7
state: restarted
|