forked from tjheeta/ansible-tinc-role
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# TODO: this doesn't seem to shutdown correctly | ||
- service: name=tinc state=stopped | ||
|
||
- name: "Cleanup hosts file" | ||
lineinfile: dest=/etc/hosts regexp='.*\.{{ tinc_netname }}$' state=absent | ||
|
||
- file: path=/etc/tinc/{{ tinc_netname }}/ state=absent mode=0755 | ||
|
||
- lineinfile: dest="/etc/tinc/nets.boot" line="{{ tinc_netname }}" state=absent | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,8 @@ | ||
--- | ||
- apt: name={{ item }} state=installed | ||
with_items: | ||
- runit | ||
- tinc | ||
- rsync | ||
when: ansible_os_family == 'Debian' | ||
|
||
- file: path=/etc/tinc/{{ tinc_netname }}/hosts state=directory mode=0755 recurse=true | ||
- shell: tincd -n {{ tinc_netname }} -K4096 | ||
args: | ||
creates: "/etc/tinc/{{ tinc_netname }}/rsa_key.priv" | ||
- include: setup.yml | ||
when: tinc_state == "present" | ||
|
||
- file: path={{ tinc_tmpdir }}/{{ tinc_netname }}/pubkeys state=directory recurse=true | ||
delegate_to: localhost | ||
sudo: false | ||
- file: path={{ tinc_tmpdir }}/{{ tinc_netname }}/ip state=directory recurse=true | ||
delegate_to: localhost | ||
sudo: false | ||
- file: path={{ tinc_tmpdir }}/{{ tinc_netname }}/current state=directory recurse=true | ||
delegate_to: localhost | ||
sudo: false | ||
- include: cleanup.yml | ||
when: tinc_state == "absent" | ||
|
||
- fetch: src=/etc/tinc/{{ tinc_netname }}/ansible_ipaddress dest={{ tinc_tmpdir }}/{{ tinc_netname }}/ip/{{ ansible_hostname }} flat=yes | ||
ignore_errors: yes | ||
|
||
- fetch: src=/etc/tinc/{{ tinc_netname }}/rsa_key.pub dest={{ tinc_tmpdir }}/{{ tinc_netname }}/pubkeys/{{ ansible_hostname }} flat=yes | ||
ignore_errors: yes | ||
|
||
# Set an ipaddress for each host in set if they don't have already | ||
- script: setip.py {{ tinc_tmpdir }}/{{ tinc_netname }}/pubkeys {{ tinc_tmpdir }}/{{ tinc_netname }}/ip {{ tinc_subnet }} | ||
tags: test | ||
register: ip_output | ||
delegate_to: localhost | ||
|
||
- debug: var=ip_output | ||
tags: test | ||
|
||
- template: src=host_configuration.j2 dest="{{ tinc_tmpdir }}/{{ tinc_netname }}/current/{{ ansible_hostname }}" | ||
tags: test | ||
delegate_to: localhost | ||
|
||
- template: src=tinc.conf.j2 dest="/etc/tinc/{{ tinc_netname }}/tinc.conf" mode=0644 | ||
notify: restart_tinc | ||
|
||
- template: src=tinc-up.j2 dest="/etc/tinc/{{ tinc_netname }}/tinc-up" mode=0755 | ||
notify: restart_tinc | ||
|
||
- template: src=tinc-down.j2 dest="/etc/tinc/{{ tinc_netname }}/tinc-down" mode=0755 | ||
notify: restart_tinc | ||
|
||
- copy: src="{{ tinc_tmpdir}}/{{ tinc_netname }}/ip/{{ ansible_hostname }}" dest="/etc/tinc/{{ tinc_netname }}/ansible_ipaddress" | ||
|
||
- copy: src="{{ tinc_tmpdir }}/{{ tinc_netname }}/current/" dest="/etc/tinc/{{ tinc_netname }}/hosts/" | ||
notify: restart_tinc | ||
|
||
- lineinfile: dest="/etc/tinc/nets.boot" line="{{ tinc_netname }}" state=present | ||
notify: restart_tinc | ||
|
||
- service: name=tinc state=started | ||
|
||
# The facts aren't available on first run, so copy over all the ip addresses | ||
- file: path=/etc/tinc/{{ tinc_netname }}/tmp state=directory mode=0755 recurse=true | ||
- copy: src="{{ tinc_tmpdir}}/{{ tinc_netname }}/ip/" dest="/etc/tinc/{{ tinc_netname }}/tmp" | ||
|
||
- name: "Build hosts file" | ||
lineinfile: dest=/etc/hosts regexp='.*{{ item | basename}}.{{ tinc_netname }}$' line="{{ lookup('file', item) }} {{ item | basename }}.{{ tinc_netname }}" state=present | ||
with_fileglob: | ||
- "/etc/tinc/{{ tinc_netname }}/tmp/*" | ||
tags: hostsfile | ||
|
||
- file: dest="{{ tinc_tmpdir }}/{{ tinc_netname }}" state=absent | ||
delegate_to: localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
- apt: name={{ item }} state=installed | ||
with_items: | ||
- runit | ||
- tinc | ||
- rsync | ||
when: ansible_os_family == 'Debian' | ||
|
||
- file: path=/etc/tinc/{{ tinc_netname }}/hosts state=directory mode=0755 recurse=true | ||
- shell: tincd -n {{ tinc_netname }} -K4096 | ||
args: | ||
creates: "/etc/tinc/{{ tinc_netname }}/rsa_key.priv" | ||
|
||
- file: path={{ tinc_tmpdir }}/{{ tinc_netname }}/pubkeys state=directory recurse=true | ||
delegate_to: localhost | ||
sudo: false | ||
- file: path={{ tinc_tmpdir }}/{{ tinc_netname }}/ip state=directory recurse=true | ||
delegate_to: localhost | ||
sudo: false | ||
- file: path={{ tinc_tmpdir }}/{{ tinc_netname }}/current state=directory recurse=true | ||
delegate_to: localhost | ||
sudo: false | ||
|
||
- fetch: src=/etc/tinc/{{ tinc_netname }}/ansible_ipaddress dest={{ tinc_tmpdir }}/{{ tinc_netname }}/ip/{{ ansible_hostname }} flat=yes | ||
ignore_errors: yes | ||
|
||
- fetch: src=/etc/tinc/{{ tinc_netname }}/rsa_key.pub dest={{ tinc_tmpdir }}/{{ tinc_netname }}/pubkeys/{{ ansible_hostname }} flat=yes | ||
ignore_errors: yes | ||
|
||
# Set an ipaddress for each host in set if they don't have already | ||
- script: setip.py {{ tinc_tmpdir }}/{{ tinc_netname }}/pubkeys {{ tinc_tmpdir }}/{{ tinc_netname }}/ip {{ tinc_subnet }} | ||
tags: test | ||
register: ip_output | ||
delegate_to: localhost | ||
|
||
- debug: var=ip_output | ||
tags: test | ||
|
||
- template: src=host_configuration.j2 dest="{{ tinc_tmpdir }}/{{ tinc_netname }}/current/{{ ansible_hostname }}" | ||
tags: test | ||
delegate_to: localhost | ||
|
||
- template: src=tinc.conf.j2 dest="/etc/tinc/{{ tinc_netname }}/tinc.conf" mode=0644 | ||
notify: restart_tinc | ||
|
||
- template: src=tinc-up.j2 dest="/etc/tinc/{{ tinc_netname }}/tinc-up" mode=0755 | ||
notify: restart_tinc | ||
|
||
- template: src=tinc-down.j2 dest="/etc/tinc/{{ tinc_netname }}/tinc-down" mode=0755 | ||
notify: restart_tinc | ||
|
||
- copy: src="{{ tinc_tmpdir}}/{{ tinc_netname }}/ip/{{ ansible_hostname }}" dest="/etc/tinc/{{ tinc_netname }}/ansible_ipaddress" | ||
|
||
- copy: src="{{ tinc_tmpdir }}/{{ tinc_netname }}/current/" dest="/etc/tinc/{{ tinc_netname }}/hosts/" | ||
notify: restart_tinc | ||
|
||
- lineinfile: dest="/etc/tinc/nets.boot" line="{{ tinc_netname }}" state=present | ||
notify: restart_tinc | ||
|
||
- service: name=tinc state=started | ||
|
||
# The facts aren't available on first run, so copy over all the ip addresses | ||
- file: path=/etc/tinc/{{ tinc_netname }}/tmp state=directory mode=0755 recurse=true | ||
- copy: src="{{ tinc_tmpdir}}/{{ tinc_netname }}/ip/" dest="/etc/tinc/{{ tinc_netname }}/tmp" | ||
|
||
- name: "Build hosts file" | ||
lineinfile: dest=/etc/hosts regexp='.*{{ item | basename}}.{{ tinc_netname }}$' line="{{ lookup('file', item) }} {{ item | basename }}.{{ tinc_netname }}" state=present | ||
with_fileglob: | ||
- "/etc/tinc/{{ tinc_netname }}/tmp/*" | ||
tags: hostsfile | ||
|
||
- file: dest="{{ tinc_tmpdir }}/{{ tinc_netname }}" state=absent | ||
delegate_to: localhost |