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:
|
2019-05-21 15:17:58 +00:00
|
|
|
- name: Get list of installed config files
|
|
|
|
find:
|
|
|
|
paths: configs/
|
|
|
|
depth: 2
|
|
|
|
recurse: true
|
|
|
|
hidden: true
|
|
|
|
patterns: ".config.yml"
|
|
|
|
register: _configs_list
|
|
|
|
|
|
|
|
- name: Verify servers
|
|
|
|
assert:
|
|
|
|
that: _configs_list.matched > 0
|
|
|
|
msg: No servers found, nothing to update.
|
|
|
|
|
|
|
|
- name: Build list of installed servers
|
|
|
|
set_fact:
|
|
|
|
server_list: >-
|
|
|
|
[{% for i in _configs_list.files %}
|
2019-05-30 05:20:45 +00:00
|
|
|
{% set config = lookup('file', i.path)|from_yaml %}
|
|
|
|
'{{ config.server }}'
|
2019-05-21 15:17:58 +00:00
|
|
|
{{ ',' if not loop.last else '' }}
|
|
|
|
{% endfor %}]
|
|
|
|
|
2019-04-26 15:48:28 +00:00
|
|
|
- name: Server address prompt
|
|
|
|
pause:
|
2019-05-21 15:17:58 +00:00
|
|
|
prompt: |
|
|
|
|
Select the server to update user list below:
|
|
|
|
{% for r in server_list %}
|
|
|
|
{{ loop.index }}. {{ r }}
|
|
|
|
{% endfor %}
|
2018-08-27 14:05:45 +00:00
|
|
|
register: _server
|
2019-05-21 15:17:58 +00:00
|
|
|
when: server is undefined
|
2018-08-27 14:05:45 +00:00
|
|
|
|
2019-05-21 15:17:58 +00:00
|
|
|
- block:
|
2018-08-27 14:05:45 +00:00
|
|
|
- name: Set facts based on the input
|
|
|
|
set_fact:
|
|
|
|
algo_server: >-
|
|
|
|
{% if server is defined %}{{ server }}
|
2019-05-21 15:17:58 +00:00
|
|
|
{%- elif _server.user_input %}{{ server_list[_server.user_input | int -1 ] }}
|
2018-08-27 14:05:45 +00:00
|
|
|
{%- 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
|
|
|
|
2019-05-30 05:20:45 +00:00
|
|
|
- when: ipsec_enabled
|
|
|
|
block:
|
|
|
|
- name: CA password prompt
|
|
|
|
pause:
|
|
|
|
prompt: Enter the password for the private CA key
|
|
|
|
echo: false
|
|
|
|
register: _ca_password
|
|
|
|
when: ca_password is undefined
|
|
|
|
|
|
|
|
- name: Set facts based on the input
|
|
|
|
set_fact:
|
|
|
|
CA_password: >-
|
|
|
|
{% if ca_password is defined %}{{ ca_password }}
|
|
|
|
{%- elif _ca_password.user_input %}{{ _ca_password.user_input }}
|
|
|
|
{%- else %}omit{% endif %}
|
2018-08-27 14:05:45 +00:00
|
|
|
|
2019-05-01 09:51:06 +00:00
|
|
|
- name: Local pre-tasks
|
|
|
|
import_tasks: playbooks/cloud-pre.yml
|
|
|
|
become: false
|
|
|
|
|
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"
|
2019-05-30 05:20:45 +00:00
|
|
|
CA_password: "{{ CA_password|default(omit) }}"
|
2017-04-29 14:48:25 +00:00
|
|
|
rescue:
|
2019-04-08 20:20:34 +00:00
|
|
|
- include_tasks: playbooks/rescue.yml
|
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
|
|
|
|
2019-04-08 20:20:34 +00:00
|
|
|
tasks:
|
2018-11-22 18:04:58 +00:00
|
|
|
- block:
|
2019-04-08 20:20:34 +00:00
|
|
|
- import_role:
|
|
|
|
name: common
|
2016-10-06 17:39:53 +00:00
|
|
|
|
2019-04-08 20:20:34 +00:00
|
|
|
- import_role:
|
|
|
|
name: wireguard
|
|
|
|
when: wireguard_enabled
|
|
|
|
|
|
|
|
- import_role:
|
|
|
|
name: strongswan
|
|
|
|
when: ipsec_enabled
|
|
|
|
tags: ipsec
|
|
|
|
|
|
|
|
- import_role:
|
|
|
|
name: ssh_tunneling
|
|
|
|
when: algo_ssh_tunneling
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg:
|
|
|
|
- "{{ congrats.common.split('\n') }}"
|
2019-05-30 05:20:45 +00:00
|
|
|
- " {{ congrats.p12_pass if algo_ssh_tunneling or ipsec_enabled else '' }}"
|
2019-07-10 16:31:25 +00:00
|
|
|
- " {{ congrats.ca_key_pass if algo_store_pki and ipsec_enabled else '' }}"
|
2019-05-30 05:20:45 +00:00
|
|
|
- " {{ congrats.ssh_access if algo_provider != 'local' else ''}}"
|
2019-04-08 20:20:34 +00:00
|
|
|
tags: always
|
2017-04-29 14:48:25 +00:00
|
|
|
rescue:
|
2019-04-08 20:20:34 +00:00
|
|
|
- include_tasks: playbooks/rescue.yml
|