|
@@ -0,0 +1,140 @@
|
|
1
|
+- name: Ensure repository key for MongoDB is in place for Rocket.Chat
|
|
2
|
+ apt_key: url=https://www.mongodb.org/static/pgp/server-4.4.asc state=present
|
|
3
|
+ tags:
|
|
4
|
+ - dependencies
|
|
5
|
+
|
|
6
|
+- name: Add MongoDB repository for Rocket.Chat
|
|
7
|
+ apt_repository: repo="deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.4 main"
|
|
8
|
+ tags:
|
|
9
|
+ - dependencies
|
|
10
|
+ when: ansible_distribution_version == '9'
|
|
11
|
+
|
|
12
|
+- name: Add MongoDB repository for Rocket.Chat
|
|
13
|
+ apt_repository: repo="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main"
|
|
14
|
+ tags:
|
|
15
|
+ - dependencies
|
|
16
|
+ when: ansible_distribution_version == '10'
|
|
17
|
+
|
|
18
|
+- name: Check if Node.js is installed
|
|
19
|
+ command: dpkg-query -l nodejs
|
|
20
|
+ register: nodejs_deb_check
|
|
21
|
+
|
|
22
|
+- name: Add Node.js repository for Rocket.Chat
|
|
23
|
+ shell: curl -fsSL https://deb.nodesource.com/setup_12.x | sudo -E bash -
|
|
24
|
+ when: nodejs_deb_check.stdout.find('no packages found') != -1
|
|
25
|
+
|
|
26
|
+- name: Install MongoDB and other Rocket.Chat dependencies
|
|
27
|
+ apt:
|
|
28
|
+ name: "{{ packages }}"
|
|
29
|
+ state: present
|
|
30
|
+ update_cache: yes
|
|
31
|
+ vars:
|
|
32
|
+ packages:
|
|
33
|
+ - build-essential
|
|
34
|
+ - mongodb-org
|
|
35
|
+ - nodejs
|
|
36
|
+ - fontconfig
|
|
37
|
+ - graphicsmagick
|
|
38
|
+ tags:
|
|
39
|
+ - dependencies
|
|
40
|
+
|
|
41
|
+- name: Install proper Node.js version and dependencies for Rocket.Chat
|
|
42
|
+ shell: sudo npm install -g inherits n && sudo n 12.18.4
|
|
43
|
+
|
|
44
|
+- name: Create temporary Rocket.Chat directory
|
|
45
|
+ file: state=directory path=/root/rocketchat
|
|
46
|
+
|
|
47
|
+- name: Download Rocket.Chat {{ rocketchat_version }} release
|
|
48
|
+ get_url:
|
|
49
|
+ url="{{ rocketchat_release }}"
|
|
50
|
+ dest=/root/rocketchat/rocketchat-{{ rocketchat_version }}.tar.gz
|
|
51
|
+
|
|
52
|
+- name: Check if temporary Rocket.Chat {{ rocketchat_version }} directory already exists
|
|
53
|
+ stat:
|
|
54
|
+ path: /root/rocketchat/{{ rocketchat_version }}
|
|
55
|
+ register: rocketchat_unpack_check
|
|
56
|
+
|
|
57
|
+- name: Create temporary Rocket.Chat {{ rocketchat_version }} directory
|
|
58
|
+ file: state=directory path=/root/rocketchat/{{ rocketchat_version }}
|
|
59
|
+
|
|
60
|
+- name: Unpack Rocket.Chat {{ rocketchat_version }} source
|
|
61
|
+ shell: tar xzvf /root/rocketchat/rocketchat-{{ rocketchat_version }}.tar.gz -C /root/rocketchat/{{ rocketchat_version }}
|
|
62
|
+ args:
|
|
63
|
+ chdir: /root/rocketchat
|
|
64
|
+ creates: /root/rocketchat/{{ rocketchat_version }}/bundle
|
|
65
|
+
|
|
66
|
+- name: Install Rocket.Chat {{ rocketchat_version }} source
|
|
67
|
+ shell: cd /root/rocketchat/{{ rocketchat_version }}/bundle/programs/server && npm install --unsafe-perm
|
|
68
|
+ when: not rocketchat_unpack_check.stat.exists
|
|
69
|
+
|
|
70
|
+- name: Create /usr/local/bin/Rocket.Chat
|
|
71
|
+ file: state=directory path=/usr/local/bin/Rocket.Chat
|
|
72
|
+
|
|
73
|
+- name: Stop old Rocket.Chat instance
|
|
74
|
+ service: name=rocketchat state=stopped
|
|
75
|
+ ignore_errors: True
|
|
76
|
+
|
|
77
|
+- name: Copy Rocket.Chat to /usr/local/bin/Rocket.Chat
|
|
78
|
+ shell: cp -R /root/rocketchat/{{ rocketchat_version }}/bundle/. /usr/local/bin/Rocket.Chat/
|
|
79
|
+
|
|
80
|
+- name: Add rocketchat group
|
|
81
|
+ group:
|
|
82
|
+ name: rocketchat
|
|
83
|
+ state: present
|
|
84
|
+
|
|
85
|
+- name: Add rocketchat user
|
|
86
|
+ user:
|
|
87
|
+ name: rocketchat
|
|
88
|
+ create_home: no
|
|
89
|
+ shell: /bin/bash
|
|
90
|
+ password_lock: yes
|
|
91
|
+ state: present
|
|
92
|
+ system: yes
|
|
93
|
+ group: rocketchat
|
|
94
|
+
|
|
95
|
+- name: Fix Rocket.Chat permissions
|
|
96
|
+ shell: sudo chown -R rocketchat:rocketchat /usr/local/bin/Rocket.Chat
|
|
97
|
+
|
|
98
|
+- name: Create the Rocket.Chat service file
|
|
99
|
+ template:
|
|
100
|
+ src=lib_systemd_system_rocketchat.j2
|
|
101
|
+ dest=/lib/systemd/system/rocketchat.service
|
|
102
|
+ owner=root
|
|
103
|
+ group=root
|
|
104
|
+
|
|
105
|
+- name: Add modified MongoDB config file for Rocket.Chat
|
|
106
|
+ copy:
|
|
107
|
+ src=etc_mongod.conf
|
|
108
|
+ dest=/etc/mongod.conf
|
|
109
|
+ owner=root
|
|
110
|
+ group=root
|
|
111
|
+ notify: restart mongod
|
|
112
|
+
|
|
113
|
+- name: Register new MongoDB service for Rocket.Chat
|
|
114
|
+ systemd: name=mongod daemon_reload=yes enabled=yes
|
|
115
|
+
|
|
116
|
+- name: Start new MongoDB instance for Rocket.Chat
|
|
117
|
+ service: name=mongod state=restarted
|
|
118
|
+
|
|
119
|
+- name: Initiate MongoDB replication set for Rocket.Chat
|
|
120
|
+ shell: sudo mongo --eval "if (rs.status().codeName == \"NotYetInitialized\") printjson(rs.initiate())"
|
|
121
|
+
|
|
122
|
+- name: Register new Rocket.Chat service
|
|
123
|
+ systemd: name=rocketchat daemon_reload=yes enabled=yes
|
|
124
|
+
|
|
125
|
+- name: Start new Rocket.Chat instance
|
|
126
|
+ service: name=rocketchat state=started
|
|
127
|
+
|
|
128
|
+- name: Create the Apache Rocket.Chat sites config files
|
|
129
|
+ template:
|
|
130
|
+ src=etc_apache2_sites-available_rocketchat.j2
|
|
131
|
+ dest=/etc/apache2/sites-available/rocketchat_{{ item.name }}.conf
|
|
132
|
+ owner=root
|
|
133
|
+ group=root
|
|
134
|
+ notify: restart apache
|
|
135
|
+ with_items: "{{ virtual_domains }}"
|
|
136
|
+
|
|
137
|
+- name: Enable Apache sites (creates new sites-enabled symlinks)
|
|
138
|
+ command: a2ensite rocketchat_{{ item }}.conf creates=/etc/apache2/sites-enabled/rocketchat_{{ item }}.conf
|
|
139
|
+ notify: restart apache
|
|
140
|
+ with_items: "{{ virtual_domains | json_query('[*].name') }}"
|