-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yml
More file actions
83 lines (68 loc) · 2.04 KB
/
Copy pathplaybook.yml
File metadata and controls
83 lines (68 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
- hosts: localhost
connection: local
gather_facts: false
vars:
ssh_keys: "{{ lookup('env','SSH_KEYS') }}"
tasks:
- digital_ocean_droplet:
unique_name: yes
region: ams3
image: debian-10-x64
wait: yes
name: "bot"
size_id: s-1vcpu-1gb
state: present
ssh_keys: "{{ ssh_keys }}"
register: created_droplet
- digital_ocean_tag:
name: bot
resource_id: "{{ created_droplet.data.droplet.id }}"
state: present
register: tag_response
- name: add hosts
add_host:
name: "{{ created_droplet.data.ip_address }}"
groups: "do"
- name: Write the new instance host key to known hosts
shell: "ssh-keyscan -H {{ created_droplet.data.ip_address }} >> ~/.ssh/known_hosts"
- hosts: do
remote_user: root
gather_facts: no
vars:
ansible_python_interpreter: /usr/bin/python3
domain_name: "{{ lookup('env','WEB_SERVER_HOST') }}"
tasks:
- name: wait for port 22 to become available
wait_for:
host: "{{ inventory_hostname }}"
port: 22
delegate_to: localhost
- name: gather facts now that host is available
setup:
- name: Install packages
apt:
name:
- nginx
- rsync
- libtinfo5
- certbot
- python-certbot-nginx
state: latest
- name: Update all packages
apt: upgrade=dist update_cache=yes
- name: copy release
synchronize:
src: ./_build/prod/rel/anybot
dest: /
- name: Write service file
template: src=anybot.service.j2 dest=/etc/systemd/system/anybot.service owner=root group=root mode=644
- name: Write anybot.env
template: src=anybot.env.j2 dest=/etc/default/anybot.env owner=root group=root mode=644
- name: Enable anybot service
service:
name: anybot
enabled: yes
state: restarted
- name: Install nginx configuration
template: src=nginx-conf.j2 dest=/etc/nginx/sites-available/bot owner=root group=root mode=644