algo/digitalocean.yml

131 lines
3.7 KiB
YAML
Raw Normal View History

2016-07-11 16:09:14 +00:00
- name: Configure the server and install required software
hosts: localhost
vars:
regions:
"1": "ams2"
"2": "ams3"
"3": "fra1"
"4": "lon1"
"5": "nyc1"
"6": "nyc2"
"7": "nyc3"
"8": "sfo1"
2016-07-30 17:26:30 +00:00
"9": "sfo2"
"10": "sgp1"
"11": "tor1"
"12": "blr1"
2016-07-11 16:09:14 +00:00
vars_prompt:
- name: "do_access_token"
prompt: "Enter your API Token (https://cloud.digitalocean.com/settings/api/tokens):\n"
private: yes
- name: "do_ssh_name"
prompt: "Enter a valid SSH key name (https://cloud.digitalocean.com/settings/security):\n"
private: no
- name: "do_region"
prompt: >
What region should the server be located in?
1. Amsterdam (Datacenter 2)
2. Amsterdam (Datacenter 3)
3. Frankfurt
4. London
5. New York (Datacenter 1)
6. New York (Datacenter 2)
7. New York (Datacenter 3)
2016-07-30 17:26:30 +00:00
8. San Francisco (Datacenter 1)
9. San Francisco (Datacenter 2)
10. Singapore
11. Toronto
12. Bangalore
2016-08-02 23:55:40 +00:00
Enter the number of your desired region:
2016-07-11 16:09:14 +00:00
default: "7"
private: no
2016-08-16 03:32:44 +00:00
2016-08-01 18:21:25 +00:00
- name: "do_server_name"
prompt: "Name the vpn server:\n"
2016-08-02 23:55:40 +00:00
default: "algo.local"
2016-07-11 16:09:14 +00:00
private: no
2016-08-16 03:32:44 +00:00
2016-08-11 08:54:34 +00:00
- name: "dns_enabled"
prompt: "Do you want to use a local DNS resolver to block ads while surfing? (Y or N):\n"
default: "Y"
private: no
2016-08-16 03:32:44 +00:00
2016-08-11 08:54:34 +00:00
- name: "auditd_enabled"
prompt: "Do you want to use auditd ? (Y or N):\n"
default: "Y"
2016-08-16 03:32:44 +00:00
private: no
2016-08-18 08:16:22 +00:00
- name: "easyrsa_p12_export_password"
prompt: "Enter the password for p12 certificates:\n"
default: "vpn"
private: yes
2016-08-16 03:32:44 +00:00
2016-08-11 08:54:34 +00:00
roles:
2016-08-16 04:00:26 +00:00
- cloud-digitalocean
2016-08-02 21:22:49 +00:00
- name: Post-provisioning tasks
hosts: vpn-host
gather_facts: false
2016-08-11 08:54:34 +00:00
become: true
2016-08-02 21:22:49 +00:00
vars_files:
- config.cfg
2016-08-16 03:32:44 +00:00
2016-08-02 21:22:49 +00:00
pre_tasks:
- name: Install prerequisites
raw: sudo apt-get update -qq && sudo apt-get install -qq -y python2.7
- name: Configure defaults
2016-08-16 03:32:44 +00:00
raw: sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
2016-08-11 08:54:34 +00:00
- name: Enable IPv6 on the droplet
uri:
url: "https://api.digitalocean.com/v2/droplets/{{ do_droplet_id }}/actions"
method: POST
body:
type: enable_ipv6
body_format: json
status_code: 201
HEADER_Authorization: "Bearer {{ do_access_token }}"
HEADER_Content-Type: "application/json"
2016-08-16 03:32:44 +00:00
2016-08-11 08:54:34 +00:00
- name: Get Droplet networks
uri:
url: "https://api.digitalocean.com/v2/droplets/{{ do_droplet_id }}"
method: GET
status_code: 200
HEADER_Authorization: "Bearer {{ do_access_token }}"
HEADER_Content-Type: "application/json"
register: droplet_info
2016-08-02 21:22:49 +00:00
- name: IPv6 configured
2016-08-16 13:39:39 +00:00
template: src=roles/cloud-digitalocean/templates/20-ipv6.cfg.j2 dest=/etc/network/interfaces.d/20-ipv6.cfg owner=root group=root mode=0644
2016-08-11 08:54:34 +00:00
with_items: "{{ droplet_info.json.droplet.networks.v6 }}"
notify:
2016-08-16 03:32:44 +00:00
- reload eth0
2016-08-02 21:22:49 +00:00
- name: IPv6 included into the network config
lineinfile: dest=/etc/network/interfaces line='source /etc/network/interfaces.d/20-ipv6.cfg' state=present
2016-08-11 08:54:34 +00:00
notify:
- reload eth0
2016-08-16 03:32:44 +00:00
2016-08-11 08:54:34 +00:00
- meta: flush_handlers
2016-08-02 21:22:49 +00:00
- name: Wait for SSH to become available
local_action: "wait_for port=22 host={{ inventory_hostname }} timeout=320"
2016-08-11 20:54:29 +00:00
become: false
2016-08-16 03:32:44 +00:00
2016-08-11 08:54:34 +00:00
roles:
- common
- security
2016-08-17 20:26:17 +00:00
- proxy
2016-08-11 19:36:36 +00:00
- vpn
2016-08-17 20:26:17 +00:00
- { role: dns_adblocking , when: dns_enabled is defined and dns_enabled == "Y" }
2016-08-16 03:32:44 +00:00
- { role: logging, when: auditd_enabled is defined and auditd_enabled == 'Y' }
2016-08-11 08:54:34 +00:00
handlers:
- name: reload eth0
2016-08-16 03:32:44 +00:00
shell: sh -c 'ifdown eth0; ip addr flush dev eth0; ifup eth0'