-
Notifications
You must be signed in to change notification settings - Fork 0
/
3proxy.yml
137 lines (135 loc) · 3.44 KB
/
3proxy.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
- hosts: all
gather_facts: no
pre_tasks:
- setup:
filter: ansible_env
vars:
proxy_version: 0.8.10
proxy_port: 49801
ansible_path: "{{ansible_env.HOME}}/ansible/"
task_path: "{{ansible_path}}3proxy/"
source_path: "{{task_path}}source/"
app_path: /usr/bin/
app_file: "{{app_path}}3proxy"
config_path: /etc/3proxy/
service_name: 3proxyinit
init_file: "/etc/init.d/{{service_name}}"
config_file: "{{config_path}}3proxy.cfg"
log_path: /var/log/3proxy/
users_file: "{{config_path}}.proxyauth"
group: proxy3
user: proxy3
compile_path: "{{source_path}}3proxy-{{proxy_version}}/"
archive_path: "{{source_path}}source.tgz"
download_url: "https://github.com/z3APA3A/3proxy/archive/{{proxy_version}}.tar.gz"
tasks:
- name: check that host is accessible
ping:
- name: create system group
group:
name: "{{group}}"
system: yes
become: yes
- name: create system user
user:
name: "{{user}}"
group: "{{group}}"
create_home: no
system: yes
become: yes
register: userinfo
- debug: var=userinfo
- set_fact:
user_id: "{{userinfo.uid}}"
group_id: "{{userinfo.group}}"
- debug: var=user_id
- debug: var=group_id
- name: create folder for ansible scripts
file:
path: "{{ansible_path}}"
state: directory
- name: create folder for executable
file:
path: "{{app_path}}"
state: directory
- name: create configuration folder
file:
path: "{{config_path}}"
state: directory
owner: "{{user}}"
group: "{{group}}"
become: yes
- name: create log folder
file:
path: "{{log_path}}"
state: directory
owner: "{{user}}"
group: "{{group}}"
become: yes
- name: create folder for task
file:
path: "{{task_path}}"
state: directory
- name: create source code folder
file:
path: "{{source_path}}"
state: directory
- name: download source code
get_url:
url: "{{download_url}}"
dest: "{{archive_path}}"
- name: unpack source code
unarchive:
remote_src: yes
src: "{{archive_path}}"
dest: "{{source_path}}"
creates: "{{compile_path}}"
- name: compile source code
make:
chdir: "{{compile_path}}"
file: Makefile.Linux #TODO сделать контексто-зависимым
- name: copy executable to required place
copy:
dest: "{{app_file}}"
src: "{{compile_path}}/src/3proxy"
remote_src: yes
owner: "{{user}}"
group: "{{group}}"
mode: "u=rwx,go=r"
become: yes
- name: copy config file
template:
src: templates/3proxy/3proxy.cfg.j2
dest: "{{config_file}}"
owner: "{{user}}"
group: "{{group}}"
mode: "u=rw,g=rw,o=rw"
become: yes
- name: copy users file
template:
src: templates/3proxy/proxyauth.j2
dest: "{{config_path}}.proxyauth"
owner: "{{user}}"
group: "{{group}}"
mode: "u=rw,go=---"
become: yes
- name: create initialize files
template:
src: templates/3proxy/3proxyinit.j2
dest: "{{init_file}}"
owner: "{{user}}"
group: "{{group}}"
mode: "u=rwx,go=r"
become: yes
- name: enable service
service:
enabled: yes
name: "{{service_name}}"
state: restarted
become: yes
- name: configure firewall(if any) for main port
ufw:
rule: allow
port: "{{proxy_port}}"
become: yes