Skip to content

Commit

Permalink
Merge pull request #4 from migibert/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
migibert authored Aug 27, 2019
2 parents bffedd3 + 5648cec commit 59393e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions tasks/certificate.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
- name: Generate key
command: openssl genrsa -out {{stunnel_key_file}} 2048
when: stunnel_certificate_generation
when: stunnel_certificate_generation | bool

- name: Generate certificate
command: openssl req -new -x509 -key {{stunnel_key_file}} -newkey rsa:4096 -keyout {{stunnel_certificate_domain}} -out {{stunnel_certificate_file}} -days {{stunnel_certificate_duration}} -nodes -subj "/C={{stunnel_certificate_country}}/ST={{stunnel_certificate_state_name}}/L={{stunnel_certificate_locality}}/O={{stunnel_certificate_organization}}/CN={{stunnel_certificate_domain}}"
when: stunnel_certificate_generation
when: stunnel_certificate_generation | bool

- name: Copy certificate
shell: cat {{stunnel_key_file}} {{stunnel_certificate_file}} >> /etc/stunnel/stunnel.pem
Expand Down
23 changes: 12 additions & 11 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
---
# tasks file for stunnel-role
- name: Install SSL backend
apt:
package:
name: openssl
update_cache: yes
register: install_ssl_backend

- name: Install package
apt:
package:
name: stunnel4
force: yes
register: install_stunnel_4

- name: Enable stunnel
lineinfile:
dest: /etc/default/stunnel4
state: present
regexp: ENABLED=
line: ENABLED=1
register: enable_stunnel

- include: certificate.yml

- name: Stunnel configuration
Expand All @@ -28,8 +20,17 @@
dest: /etc/stunnel/stunnel.conf
register: stunnel_configuration

- name: Enable stunnel
lineinfile:
dest: /etc/default/stunnel4
state: present
regexp: ENABLED=
line: ENABLED=1
register: enable_stunnel

- name: Start stunnel service
service:
name: stunnel4
state: restarted
when: install_stunnel_4.changed or enable_stunnel.changed or stunnel_configuration.changed
enabled: true
when: install_stunnel_4 is changed or enable_stunnel is changed or stunnel_configuration is changed

0 comments on commit 59393e3

Please sign in to comment.