Skip to content

Commit

Permalink
Move uuid creation & recording, provide uuid if missing on first use …
Browse files Browse the repository at this point in the history
…of iiab-remote-on
  • Loading branch information
jvonau committed Sep 20, 2017
1 parent 3ab8e6d commit 3466f3b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
30 changes: 0 additions & 30 deletions roles/1-prep/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,6 @@
is_F18: True
when: ansible_distribution_release == "based on Fedora 18" or ansible_distribution_version == "18"

- name: get the uuidgen program
package: name=uuid-runtime
state=present
when: is_debuntu

- name: Test for UUID file
stat: path=/etc/iiab/uuid
register: uuid_file

- name: Create folder to hold uuid
file: path=/etc/iiab state=directory
when: not uuid_file.stat.exists

- name: If no uuid exists, create one
shell: uuidgen
register: uuid_response
when: not uuid_file.stat.exists

- name: Put the uuid in place
shell: echo {{ uuid_response.stdout_lines[0] }} > /etc/iiab/uuid
when: not uuid_file.stat.exists

- name: get the uuid
command: cat /etc/iiab/uuid
register: stored_uuid

- name: get the value into a variable
set_fact:
uuid={{ stored_uuid.stdout_lines[0] }}

# for rpi, without rtc, we need time as soon as possible
- name: Install chrony package
package: name={{ item }}
Expand Down
33 changes: 32 additions & 1 deletion roles/openvpn/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,36 @@
tags:
- download

- name: get the uuidgen program
package: name=uuid-runtime
state=present
when: is_debuntu

- name: Test for UUID file
stat: path=/etc/iiab/uuid
register: uuid_file

- name: Create folder to hold uuid
file: path=/etc/iiab state=directory
when: not uuid_file.stat.exists

- name: If no uuid exists, create one
shell: uuidgen
register: uuid_response
when: not uuid_file.stat.exists

- name: Put the uuid in place
shell: echo {{ uuid_response.stdout_lines[0] }} > /etc/iiab/uuid
when: not uuid_file.stat.exists

- name: get the uuid
command: cat /etc/iiab/uuid
register: stored_uuid

- name: get the value into a variable
set_fact:
uuid={{ stored_uuid.stdout_lines[0] }}

- name: Create the directory for keys
file: dest=/etc/openvpn/keys
state=directory
Expand Down Expand Up @@ -87,7 +117,6 @@
when:
not openvpn_enabled or not openvpn_cron_enabled


- name: stop starting the openvpn tunnel at boot time
shell: systemctl disable openvpn@xscenet.service
when: not openvpn_enabled and not is_debuntu
Expand Down Expand Up @@ -119,3 +148,5 @@
value: "{{ openvpn_enabled }}"
- option: cron_enabled
value: "{{ openvpn_cron_enabled }}"
- option: 'Universal Unique ID (uuid)'
value: '{{ uuid }}'
6 changes: 6 additions & 0 deletions roles/openvpn/templates/iiab-remote-on
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ if [ $? -ne 0 ]; then
echo Cannot find the openvpn program.
exit 1
fi

if ! [ -f /etc/iiab/uuid ]; then
echo first use creating uuid
uuidgen > /etc/iiab/uuid
fi

systemctl enable openvpn@xscenet.service
systemctl start openvpn@xscenet.service

Expand Down

0 comments on commit 3466f3b

Please sign in to comment.