1 #####################################
2 ### someone"s ansible provisioner ###
3 #####################################
4 # Part of: https://git.somenet.org/root/pub/somesible.git
5 # 2017-2024 by someone <someone@somenet.org>
7 # its not supported to run multiple mattestmost instances on one host.
10 - name: create mattermost user
13 home: "{{mattermost_homedir}}"
19 - name: create mattermost homedir
21 path: "{{mattermost_homedir}}"
28 - name: create mattermost data-dir
30 path: "{{mattermost_homedir}}/data"
37 #- name: create postgres-db and user
39 # name: util/postgres-db-usr
42 # dbname: "{{mattermost_db_name}}"
43 # pw: "{{mattermost_db_pw}}"
44 # when: mattermost_db_create | default('True') | bool
47 - name: include vars_nginx_vhost_custom
50 name: vars_nginx_vhost_custom
52 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/vars_nginx_vhost_custom.yml"
53 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/vars_nginx_vhost_custom.yml"
54 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/vars_nginx_vhost_custom.yml"
55 - "default/vars_nginx_vhost_custom.yml"
58 - name: configure mattermost vhost
60 name: server/nginx/vhost-unified
63 vhost_name: "{{mattermost_domain}}"
64 vhost_awstats_valid_http_codes: "200 304 101"
66 vhost_custom_pre_server: "{{vars_nginx_vhost_custom.vhost_custom_pre_server}}"
67 vhost_custom: "{{vars_nginx_vhost_custom.vhost_custom}}"
70 - name: copy mattermost.service to /etc/systemd/system/
73 dest: "/etc/systemd/system/mattermost.service"
78 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/mattermost.service"
79 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/mattermost.service"
80 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/mattermost.service"
81 - "default/mattermost.service"
84 - name: download mattermost release and check checksums
86 url: "{{mattermost_download_url}}"
87 dest: "{{mattermost_homedir}}/server.tar.gz"
91 checksum: "{{mattermost_download_checksum}}"
97 - name: extract and update/install mattermost
99 - name: stop mattermost.service
101 name: mattermost.service
106 - name: remove old server files
108 path: "{{mattermost_homedir}}/server.old"
112 - name: limit access to current server files
114 path: "{{mattermost_homedir}}/server"
121 - name: move current server files away
122 command: "mv {{mattermost_homedir}}/server {{mattermost_homedir}}/server.old"
125 - name: create new server files dir, because unarchive fails to do so
127 path: "{{mattermost_homedir}}/server"
134 - name: extract mattermost files
136 src: "{{mattermost_homedir}}/server.tar.gz"
137 dest: "{{mattermost_homedir}}/server"
139 mode: "u=rwX,g=rX,o-rwx"
143 - '--strip-components=1'
144 - '--show-stored-names'
147 - name: reuse existing config file
148 command: "mv {{mattermost_homedir}}/server.old/config/config.json {{mattermost_homedir}}/server/config/config.json"
149 register: config_copy
153 - name: template new config.json
156 dest: "{{mattermost_homedir}}/server/config/config.json"
161 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/config.json.j2"
162 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/config.json.j2"
163 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/config.json.j2"
164 - "default/config.json.j2"
165 when: config_copy.failed
168 - name: enable and restart mattermost.service
169 include_role: name="base/systemd/enable-and-start"
171 service_name: mattermost.service
172 service_state: restarted
175 - name: create mattermost admin user
177 become_user: "mattermost"
178 shell: "bin/mattermost user create --system_admin --username {{mattermost_admin_user | quote}} --email {{mattermost_admin_user_email | quote}} --password {{mattermost_admin_user_pw | quote}} || true"
180 chdir: "{{mattermost_homedir}}/server"
182 changed_when: "'An account with that email already exists' not in script_res.stdout"
184 when: download.changed