2016-07-27 21:27:11 +00:00
|
|
|
---
|
2016-08-11 20:54:29 +00:00
|
|
|
- hosts: localhost
|
|
|
|
gather_facts: False
|
2017-05-08 20:34:45 +00:00
|
|
|
tags: always
|
2016-08-11 20:54:29 +00:00
|
|
|
vars_files:
|
2016-08-16 03:32:44 +00:00
|
|
|
- config.cfg
|
2016-12-15 10:33:29 +00:00
|
|
|
|
2016-08-11 20:54:29 +00:00
|
|
|
tasks:
|
2017-04-29 14:48:25 +00:00
|
|
|
- block:
|
2018-08-27 14:05:45 +00:00
|
|
|
- pause:
|
|
|
|
prompt: "Enter the IP address of your server: (or use localhost for local installation)"
|
|
|
|
register: _server
|
|
|
|
when: server is undefined
|
|
|
|
|
|
|
|
- name: Set facts based on the input
|
|
|
|
set_fact:
|
|
|
|
algo_server: >-
|
|
|
|
{% if server is defined %}{{ server }}
|
|
|
|
{%- elif _server.user_input is defined and _server.user_input != "" %}{{ _server.user_input }}
|
|
|
|
{%- else %}omit{% endif %}
|
|
|
|
|
|
|
|
- name: Import host specific variables
|
|
|
|
include_vars:
|
2019-03-10 17:16:34 +00:00
|
|
|
file: "configs/{{ algo_server }}/.config.yml"
|
2018-08-27 14:05:45 +00:00
|
|
|
|
|
|
|
- pause:
|
|
|
|
prompt: Enter the password for the private CA key
|
|
|
|
echo: false
|
|
|
|
register: _ca_password
|
2019-03-10 17:16:34 +00:00
|
|
|
when:
|
|
|
|
- ca_password is undefined
|
|
|
|
- ipsec_enabled
|
2018-08-27 14:05:45 +00:00
|
|
|
|
|
|
|
- name: Set facts based on the input
|
|
|
|
set_fact:
|
|
|
|
CA_password: >-
|
|
|
|
{% if ca_password is defined %}{{ ca_password }}
|
|
|
|
{%- elif _ca_password.user_input is defined and _ca_password.user_input != "" %}{{ _ca_password.user_input }}
|
|
|
|
{%- else %}omit{% endif %}
|
|
|
|
|
2017-04-29 14:48:25 +00:00
|
|
|
- name: Add the server to the vpn-host group
|
|
|
|
add_host:
|
2018-08-27 14:05:45 +00:00
|
|
|
name: "{{ algo_server }}"
|
|
|
|
groups: vpn-host
|
|
|
|
ansible_ssh_user: "{{ server_user|default('root') }}"
|
|
|
|
ansible_connection: "{% if algo_server == 'localhost' %}local{% else %}ssh{% endif %}"
|
2019-03-10 17:16:34 +00:00
|
|
|
ansible_python_interpreter: "/usr/bin/python3"
|
2018-08-27 14:05:45 +00:00
|
|
|
CA_password: "{{ CA_password }}"
|
2017-04-29 14:48:25 +00:00
|
|
|
rescue:
|
|
|
|
- debug: var=fail_hint
|
|
|
|
tags: always
|
|
|
|
- fail:
|
|
|
|
tags: always
|
2016-08-11 20:54:29 +00:00
|
|
|
|
2016-07-30 17:26:30 +00:00
|
|
|
- name: User management
|
2016-08-11 20:54:29 +00:00
|
|
|
hosts: vpn-host
|
2017-02-03 19:24:02 +00:00
|
|
|
gather_facts: true
|
2016-07-30 16:05:04 +00:00
|
|
|
become: true
|
2016-07-27 21:27:11 +00:00
|
|
|
vars_files:
|
2016-08-16 03:32:44 +00:00
|
|
|
- config.cfg
|
2019-03-10 17:16:34 +00:00
|
|
|
- "configs/{{ inventory_hostname }}/.config.yml"
|
2017-03-18 09:22:07 +00:00
|
|
|
|
2018-11-22 18:04:58 +00:00
|
|
|
pre_tasks:
|
|
|
|
- block:
|
|
|
|
- name: Local pre-tasks
|
|
|
|
import_tasks: playbooks/cloud-pre.yml
|
2019-01-19 04:39:08 +00:00
|
|
|
become: false
|
2018-11-22 18:04:58 +00:00
|
|
|
rescue:
|
|
|
|
- debug: var=fail_hint
|
|
|
|
tags: always
|
|
|
|
- fail:
|
|
|
|
tags: always
|
|
|
|
|
2016-10-06 17:39:53 +00:00
|
|
|
roles:
|
2018-08-27 14:05:45 +00:00
|
|
|
- role: common
|
|
|
|
- role: wireguard
|
|
|
|
tags: [ 'vpn', 'wireguard' ]
|
|
|
|
when: wireguard_enabled
|
2019-03-10 17:16:34 +00:00
|
|
|
- role: strongswan
|
|
|
|
when: ipsec_enabled
|
|
|
|
tags: ipsec
|
2018-10-08 00:33:55 +00:00
|
|
|
- role: ssh_tunneling
|
|
|
|
when: algo_ssh_tunneling
|
2016-10-06 17:39:53 +00:00
|
|
|
|
2016-12-14 15:49:47 +00:00
|
|
|
post_tasks:
|
2017-04-29 14:48:25 +00:00
|
|
|
- block:
|
|
|
|
- debug:
|
|
|
|
msg:
|
|
|
|
- "{{ congrats.common.split('\n') }}"
|
2017-05-22 02:28:18 +00:00
|
|
|
- " {% if p12.changed %}{{ congrats.p12_pass }}{% endif %}"
|
2017-04-29 14:48:25 +00:00
|
|
|
tags: always
|
|
|
|
rescue:
|
|
|
|
- debug: var=fail_hint
|
|
|
|
tags: always
|
|
|
|
- fail:
|
|
|
|
tags: always
|