forked from RhostMUSH/trunk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrhostinstall.yml
More file actions
167 lines (167 loc) · 5.76 KB
/
rhostinstall.yml
File metadata and controls
167 lines (167 loc) · 5.76 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---
- name: Rhost Installation Playbook
hosts: localhost
vars_prompt:
- name: rhostpath
prompt: "Enter install directory:"
private: no
default: "{{ playbook_dir }}"
- name: rhostdir
prompt: "Enter Rhost directory:"
private: no
default: "Rhost"
- name: mud_name
prompt: "Mush name:"
private: no
default: "RhostMUSH"
- name: port
prompt: "Mush port:"
private: no
default: "4201"
- name: ssl_port
prompt: "Mush SSL-port (0 for no SSL):"
private: no
default: "4202"
- name: api_port
prompt: "Mush API-port (0 for no API):"
private: no
default: "4203"
- name: api_command
prompt: "
10-30 chars, single word -- will not overwrite if existing\n
If api_port is '0' above this will be ignored\n
API Secret Command:"
private: no
default: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}"
- name: lbufsize
prompt: "
1. 4000\n
2. 8192\n
3. 16384\n
4. 32768\n
Enter LBUF Size:"
private: no
default: "2"
- name: websockets
prompt: "Enable Websockets: (1=yes, 0=no):"
private: no
default: "1"
tasks:
- name: Verifying git directory pre-existing
stat:
path: "{{ rhostpath + '/' + rhostdir }}"
register: pchk
- name: Pull down git
git:
repo: https://github.com/RhostMUSH/trunk
dest: "{{ rhostpath + '/' + rhostdir }}"
when: not pchk.stat.exists
- name: Set default values and normalize
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/bin/asksource.default' }}"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- { regexp: '^XD[1]', line: 'XD[1]="X"' }
- { regexp: '^XD[2]', line: 'XD[2]="X"' }
- { regexp: '^XL\[1\]', line: 'XL[1]=" "' }
- { regexp: '^XL\[2\]', line: 'XL[2]=" "' }
- { regexp: '^XL\[3\]', line: 'XL[3]=" "' }
- { regexp: '^XL\[4\]', line: 'XL[4]=" "' }
- name: Set LBUF size defined
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/bin/asksource.default' }}"
regexp: '^XL\[*{{ lbufsize }}*\]'
line: "XL[{{ lbufsize }}]=\"X\""
- name: Set Websockets if enabled
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/bin/asksource.default' }}"
regexp: '^X\[27\]'
line: 'X[27]="X"'
when: websockets == "1"
- name: See if Rhost has been already compiled
stat:
path: "{{ rhostpath + '/' + rhostdir + '/src/custom.defs' }}"
register: custdef
- name: Cleanup RhostMUSH source
make:
chdir: "{{ rhostpath + '/' + rhostdir + '/Server' }}"
target: clean
when: custdef.stat.exists
- name: Build RhostMUSH
make:
chdir: "{{ rhostpath + '/' + rhostdir + '/Server' }}"
target: default
- name: Creating minimal database
script:
chdir: "{{ rhostpath + '/' + rhostdir + '/Server/game'}}"
cmd: /bin/sh ./minimal.sh --noprompt
- name: Set port, mud_name
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/game/netrhost.conf' }}"
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- { regexp: '^port\s+', line: "port {{ port }}" }
- { regexp: '^debug_id\s+', line: "debug_id {{ port }}5" }
- { regexp: '^mud_name\s+', line: "mud_name {{ mud_name }}" }
- name: Clean up api port in file
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/game/netrhost.conf' }}"
regexp: "{{ item.regexp }}"
state: absent
with_items:
- { regexp: '^#api_port\s+' }
- { regexp: '^#\s+api_port\s+' }
- { regexp: '^api_port\s+' }
when: api_port != "0"
- name: Insert API port if enabled
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/game/netrhost.conf' }}"
regexp: '^api_port\s+'
insertafter: '^# The port for non-root'
line: "api_port {{ api_port }}"
when: api_port != "0"
- name: Enable SSL layer to RhostMUSH if enabled
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/game/netrhost.conf' }}"
regexp: '^sconnect_reip\s+'
insertbefore: '^# this is the last\s+'
line: "sconnect_reip 1"
when: ssl_port != "0"
- name: Disable SSL layer to RhostMUSH if disabled
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/game/netrhost.conf' }}"
regexp: '^sconnect_reip\s+'
insertbefore: '^# this is the last\s+'
line: "sconnect_reip 0"
when: ssl_port == "0"
- name: Check for existing SSL secret command
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/game/netrhost.conf' }}"
regexp: '^sconnect_cmd\s+'
state: absent
check_mode: yes
changed_when: false
register: sslcmd
- name: Add SSL command secret key if doesn't exist
lineinfile:
dest: "{{ rhostpath + '/' + rhostdir + '/Server/game/netrhost.conf' }}"
regexp: '^sconnect_cmd\s+'
insertbefore: '^# this is the last\s+'
line: "sconnect_cmd {{ api_command }}"
when: (ssl_port != "0") and (not sslcmd.found)
- name: Run stunnel config/setup
script:
chdir: "{{ rhostpath + '/' + rhostdir + '/Server/stunnel'}}"
cmd: /bin/sh ./stunnel_setup.sh --noprompt {{ ssl_port }}
when: ssl_port != "0"
- name: Start stunnel engine for SSL connector
script:
chdir: "{{ rhostpath + '/' + rhostdir + '/Server/stunnel'}}"
cmd: /bin/sh ./stunnel_start.sh
when: ssl_port != "0"
- name: Starting RhostMUSH
script:
chdir: "{{ rhostpath + '/' + rhostdir + '/Server/game'}}"
cmd: /bin/sh ./Startmush