-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
103 lines (88 loc) · 2.46 KB
/
playbook.yml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
- hosts: hhru
remote_user: root
vars:
mojo_user: "mojo"
mojo_home: "/opt/mojo"
mojo_port: 8883
mojo_secret: "some secret to sign cookies (e.g. md5-like string)"
hhru_clientid: "place some id here"
hhru_secret: "place some secret here"
nginx_hostname: "place domain name here"
tasks:
- name: add user {{ mojo_user }}
user:
name: "{{ mojo_user }}"
shell: /bin/false
home: "{{ mojo_home }}"
- name: add {{ mojo_user }} to sudoers
lineinfile:
dest: /etc/sudoers
line: "{{ mojo_user }} ALL=(ALL:ALL) NOPASSWD:ALL"
- name: upgrade system
apt:
update_cache: yes
upgrade: full
- name: install apt dependencies
apt: name={{ item }} state=latest
with_items:
- "build-essential"
- "libssl-dev"
- "curl"
- "nginx"
- name: clone repositoy
become: yes
become_user: "{{ mojo_user }}"
git:
clone: yes
repo: https://github.com/somepad/hhru-cvupdater-perl.git
dest: "{{ mojo_home }}/hhru"
- name: install perl modules
become: yes
become_user: "{{ mojo_user }}"
shell: ./setup.sh
args:
chdir: "{{ mojo_home }}/hhru/install/"
- name: lib/CVUpdater.pm <-- mojo port
become: yes
become_user: "{{ mojo_user }}"
replace:
dest: "{{ mojo_home }}/hhru/lib/CVUpdater.pm"
regexp: '^(.+)#mojo_port#(.+)$'
replace: '\g<1>{{ mojo_port }}\g<2>'
- name: lib/CVUpdater.pm <-- mojo secret
become: yes
become_user: "{{ mojo_user }}"
replace:
dest: "{{ mojo_home }}/hhru/lib/CVUpdater.pm"
regexp: '^(.+)#mojo_secret#(.+)$'
replace: '\g<1>{{ mojo_secret }}\g<2>'
- name: place c_v_updater.conf
become: yes
become_user: "{{ mojo_user }}"
template:
src: tpl/c_v_updater.conf.tpl
dest: "{{ mojo_home }}/hhru/c_v_updater.conf"
- name: place nginx config
template:
src: tpl/hhru-nginx.tpl
dest: /etc/nginx/sites-available/hhru-nginx
- name: add nginx virtualhost
file:
src: /etc/nginx/sites-available/hhru-nginx
dest: /etc/nginx/sites-enabled/hhru-nginx
state: link
- name: create a database
become: yes
become_user: "{{ mojo_user }}"
shell: ./cvupdater deploy
args:
chdir: "{{ mojo_home }}/hhru/script/"
- name: start Mojolicious
become: yes
become_user: "{{ mojo_user }}"
shell: ./ctl start
args:
chdir: "{{ mojo_home }}/hhru/script/"
- name: start nginx
service: name=nginx state=restarted enabled=yes