-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
35 changed files
with
588 additions
and
237 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
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
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,13 +1,13 @@ | ||
# This file is used by Vagrantfile | ||
--- | ||
hosts: | ||
- name: "fedora35" | ||
- name: "fedora" | ||
# os: "generic/fedora35" | ||
os: "alvistack/fedora-35" | ||
hostname: "fedora35.srv" | ||
os: "fedora/40-cloud-base" | ||
hostname: "fedora.srv" | ||
ip: | ||
- "10.0.0.10" | ||
cpu: "2" | ||
mem: "4096" | ||
mem: "2048" | ||
port_forward: [] | ||
hostname_alias: [] |
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
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,9 @@ | ||
--- | ||
- name: Provision VPN1 | ||
hosts: | ||
- vpn1 | ||
become: true | ||
roles: | ||
- servers/network-static-dns | ||
- servers/apps/openvpn | ||
- servers/apps/vpn-gw |
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,2 @@ | ||
--- | ||
ovpn_client_templates_path: files |
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,35 @@ | ||
client | ||
dev tun | ||
proto tcp | ||
remote pl-waw.prod.surfshark.com 1443 | ||
remote-random | ||
nobind | ||
tun-mtu 1500 | ||
mssfix 1450 | ||
ping 15 | ||
ping-restart 0 | ||
reneg-sec 0 | ||
|
||
remote-cert-tls server | ||
|
||
auth-user-pass pass.txt | ||
|
||
#comp-lzo | ||
verb 3 | ||
fast-io | ||
cipher AES-256-CBC | ||
|
||
auth SHA512 | ||
|
||
<ca> | ||
-----BEGIN CERTIFICATE----- | ||
-----END CERTIFICATE----- | ||
</ca> | ||
key-direction 1 | ||
<tls-auth> | ||
# | ||
# 2048 bit OpenVPN static key | ||
# | ||
-----BEGIN OpenVPN Static key V1----- | ||
-----END OpenVPN Static key V1----- | ||
</tls-auth> |
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,2 @@ | ||
username | ||
password |
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,23 @@ | ||
--- | ||
- name: Install openvpn | ||
dnf: | ||
name: "openvpn" | ||
state: present | ||
|
||
- name: Configure ovpn client files | ||
template: | ||
src: "{{ ovpn_client_templates_path }}/{{ item.src }}" | ||
dest: "/etc/openvpn/client/{{ item.dest }}" | ||
mode: 0664 | ||
backup: true | ||
loop: | ||
- src: client.ovpn | ||
dest: client.conf | ||
- src: pass.txt | ||
dest: pass.txt | ||
|
||
- name: Enable service [email protected] | ||
systemd: | ||
name: [email protected] | ||
enabled: true | ||
state: started |
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
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
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,27 +1,27 @@ | ||
--- | ||
# - name: Check docker-compose executable is present | ||
# shell: "which docker-compose" | ||
# register: docker_compose_result | ||
# ignore_errors: true | ||
# changed_when: false | ||
- name: Check docker-compose executable is present | ||
shell: "which docker-compose" | ||
register: docker_compose_result | ||
ignore_errors: true | ||
changed_when: false | ||
|
||
# - fail: | ||
# msg: "docker-compose is not found! You need to install it first." | ||
# when: docker_compose_result.rc != 0 | ||
- fail: | ||
msg: "docker-compose is not found! You need to install it first." | ||
when: docker_compose_result.rc != 0 | ||
|
||
# - name: Ensure passlib is installed | ||
# delegate_to: localhost | ||
# pip: | ||
# name: | ||
# - passlib | ||
# state: present | ||
- name: Ensure passlib is installed | ||
delegate_to: localhost | ||
pip: | ||
name: | ||
- passlib | ||
state: present | ||
|
||
# # TODO: add stat to check if docker-compose file exists before running cleanup | ||
# TODO: add stat to check if docker-compose file exists before running cleanup | ||
|
||
# - include_tasks: cleanup.yml | ||
# when: home_assistant_clean | ||
|
||
# - import_tasks: custom.yml | ||
- import_tasks: custom.yml | ||
- import_tasks: config.yml | ||
# - import_tasks: config_mosquitto.yml | ||
# - import_tasks: install.yml | ||
- import_tasks: config_mosquitto.yml | ||
- import_tasks: install.yml |
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,17 +1,38 @@ | ||
--- | ||
ssl_path: "/etc/openvpn/ssl" | ||
easyrsa_path: "/usr/share/easy-rsa/3" | ||
pki_path: "/etc/openvpn/pki" | ||
certs_path: "{{ pki_path }}/issued" | ||
keys_path: "{{ pki_path }}/private" | ||
openvpn_configs_path: "/etc/openvpn" | ||
|
||
common_name: "vpn.example.com" | ||
openvpn_server_config_path: "{{ openvpn_configs_path }}/server" | ||
# 995 - ssl pop3 | ||
openvpn_server_port: 995 | ||
|
||
ca_path: "{{ pki_path }}/ca.crt" | ||
dh_path: "{{ pki_path }}/dh.pem" | ||
openvpn_ssl_path: "{{ openvpn_configs_path }}/ssl" | ||
openvpn_ca_cert_path: "{{ openvpn_ssl_path }}/ca" | ||
openvpn_client_cert_path: "{{ openvpn_ssl_path }}/client" | ||
openvpn_server_cert_path: "{{ openvpn_ssl_path }}/server" | ||
openvpn_certs_common_name: "vpn.example.com" | ||
|
||
server_crt_name: server | ||
server_crt_path: "{{ certs_path }}/{{ server_crt_name }}.crt" | ||
openvpn_clients: | ||
- vagrant | ||
- test | ||
|
||
client_crts: | ||
- client | ||
openvpn_pull_client_name: "vagrant" | ||
openvpn_pull_client_config_path: "/tmp/certs_vpn" | ||
|
||
### Old | ||
# easyrsa_path: "/usr/share/easy-rsa/3" | ||
# pki_path: "/etc/openvpn/pki" | ||
# certs_path: "{{ pki_path }}/issued" | ||
# keys_path: "{{ pki_path }}/private" | ||
|
||
# common_name: "vpn.example.com" | ||
|
||
# ca_path: "{{ pki_path }}/ca.crt" | ||
# dh_path: "{{ pki_path }}/dh.pem" | ||
|
||
# server_crt_name: server | ||
# server_crt_path: "{{ certs_path }}/{{ server_crt_name }}.crt" | ||
|
||
# # client_crts: | ||
# # - client | ||
|
||
# server_port: 443 |
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,5 @@ | ||
--- | ||
- name: restart_openvpn_server | ||
service: | ||
name: openvpn-server@server | ||
state: restarted |
107 changes: 18 additions & 89 deletions
107
roles/servers/apps/openvpn/tasks/certs_ansible_openssl.yml
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,96 +1,25 @@ | ||
--- | ||
- package: | ||
- name: Install python3-pip | ||
package: | ||
name: python3-pip | ||
state: present | ||
|
||
- pip: | ||
name: pyOpenSSL | ||
- name: Install ansible pip dependencies | ||
pip: | ||
name: "{{ pkgs }}" | ||
state: present | ||
|
||
- file: | ||
path: "{{ ssl_path }}" | ||
vars: | ||
pkgs: | ||
- pyOpenSSL | ||
- packaging | ||
|
||
- name: Create directory for certs | ||
file: | ||
path: "{{ openvpn_ssl_path }}" | ||
state: directory | ||
|
||
- openssl_privatekey: | ||
path: "{{ ssl_path }}/ca.pem" | ||
|
||
- openssl_csr: | ||
path: "{{ ssl_path }}/ca.csr" | ||
privatekey_path: "{{ ssl_path }}/ca.pem" | ||
basic_constraints_critical: true | ||
basic_constraints: CA:TRUE | ||
key_usage_critical: true | ||
key_usage: | ||
- cRLSign | ||
- digitalSignature | ||
- keyCertSign | ||
common_name: "{{ certs_path }}" | ||
|
||
- name: Generate CA a Self Signed OpenSSL certificate | ||
openssl_certificate: | ||
path: "{{ ssl_path }}/ca.crt" | ||
privatekey_path: "{{ ssl_path }}/ca.pem" | ||
csr_path: "{{ ssl_path }}/ca.csr" | ||
provider: selfsigned | ||
|
||
- openssl_privatekey: | ||
path: "{{ ssl_path }}/server.pem" | ||
|
||
- openssl_csr: | ||
path: "{{ ssl_path }}/server.csr" | ||
privatekey_path: "{{ ssl_path }}/server.pem" | ||
basic_constraints_critical: true | ||
basic_constraints: CA:FALSE | ||
key_usage_critical: true | ||
key_usage: | ||
- nonRepudiation | ||
- digitalSignature | ||
- keyEncipherment | ||
- keyAgreement | ||
extended_key_usage_critical: true | ||
extended_key_usage: serverAuth | ||
common_name: "{{ certs_path }}" | ||
|
||
- name: Generate Server Self Signed OpenSSL certificate | ||
openssl_certificate: | ||
path: "{{ ssl_path }}/server.crt" | ||
privatekey_path: "{{ ssl_path }}/server.pem" | ||
csr_path: "{{ ssl_path }}/server.csr" | ||
provider: ownca | ||
ownca_path: "{{ ssl_path }}/ca.crt" | ||
ownca_privatekey_path: "{{ ssl_path }}/ca.pem" | ||
|
||
|
||
- openssl_privatekey: | ||
path: "{{ ssl_path }}/client.pem" | ||
|
||
- openssl_csr: | ||
path: "{{ ssl_path }}/client.csr" | ||
privatekey_path: "{{ ssl_path }}/client.pem" | ||
basic_constraints_critical: true | ||
basic_constraints: CA:FALSE | ||
key_usage_critical: true | ||
key_usage: | ||
- nonRepudiation | ||
- digitalSignature | ||
- keyEncipherment | ||
extended_key_usage_critical: true | ||
extended_key_usage: clientAuth | ||
common_name: "{{ certs_path }}" | ||
|
||
- name: Generate a Self Signed OpenSSL certificate | ||
community.crypto.x509_certificate: | ||
path: "{{ ssl_path }}/client.crt" | ||
privatekey_path: "{{ ssl_path }}/client.pem" | ||
csr_path: "{{ ssl_path }}/client.csr" | ||
provider: ownca | ||
ownca_path: "{{ ssl_path }}/ca.crt" | ||
ownca_privatekey_path: "{{ ssl_path }}/ca.pem" | ||
|
||
- openssl_dhparam: | ||
path: "{{ ssl_path }}/dhparams.pem" | ||
|
||
- name: Openssl TLS key_usage | ||
shell: openvpn --genkey --secret {{ ssl_path }}/tls.key | ||
args: | ||
creates: "{{ ssl_path }}/tls.key" | ||
- import_tasks: "openssl/ca.yml" | ||
- import_tasks: "openssl/server.yml" | ||
- import_tasks: "openssl/server_extras.yml" | ||
- include_tasks: "openssl/client.yml" | ||
loop: "{{ openvpn_clients }}" |
Oops, something went wrong.