RocketChat / Rocket.Chat.Ansible

Deploy Rocket.Chat with Ansible!
MIT License
94 stars 80 forks source link

Mongod restart failed Ubuntu 18.04 #104

Open hungrymonkey opened 4 years ago

hungrymonkey commented 4 years ago
TASK [RocketChat.Server : Ensure the MongoDB service is started/enabled] ********************************************************************************************************************
fatal: [rocketchat.domain.tld]: FAILED! => {"changed": false, "msg": "Could not find the requested service mongod: host"}

requirements.yaml


- src: RocketChat.Server
  version: master
hungrymonkey commented 4 years ago

sudo systemctl status mongodb
● mongodb.service - An object/document-oriented database
   Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-04-11 21:05:59 UTC; 9min ago
     Docs: man:mongod(1)
 Main PID: 2753 (mongod)
    Tasks: 23 (limit: 1152)
   CGroup: /system.slice/mongodb.service
           └─2753 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf

Apr 11 21:05:59 ip-172-31-94-233 systemd[1]: Started An object/document-oriented database.
ubuntu@hostname:~$ sudo systemctl stop mongodb

systemctl status mongod
Unit mongod.service could not be found.
``
chrinats commented 4 years ago

At /etc/ansible/roles/defaults/main.yml change

_rocket_chat_mongodb_servicename: mongod to rocket_chat_mongodb_service_name: mongodb

hungrymonkey commented 4 years ago

https://github.com/RocketChat/Rocket.Chat.Ansible/pull/101

chrinats commented 4 years ago

@hungrymonkey Did you manage to deploy Rocket.Chat?

I'm getting an error when executing MongoDb replica Set:

_{"msg": "The conditional check '('ok' in (replSet_result.stdout | fromjson))' failed. The error was: No JSON object could be decoded"}

hungrymonkey commented 4 years ago

@chrinats

I gave up and deployed the snap releases. This ansible does not seem to be maintained. You can peak at the effort to deploy the snapd below

https://docs.rocket.chat/installation/snaps

Rocket Chat Server

Home server URL

rocketchat.domain.com

Install

  1. Start Ubuntu AWS VM with Open Ports
    • 80 (TCP HTTP)
    • 443 (TCP HTTPS)
  2. Install Rocket Snap
    • sudo snap install rocketchat-server --channel=3.x/stable
  3. Setup Lets Encrypt
    • sudo snap set rocketchat-server caddy-url=https://rocketchat.domain.com
    • sudo snap set rocketchat-server caddy=enable
    • sudo snap set rocketchat-server https=enable
    • sudo snap run rocketchat-server.initcaddy
  4. Start Server
    • sudo systemctl restart snap.rocketchat-server.rocketchat-server.service
    • sudo systemctl restart snap.rocketchat-server.rocketchat-caddy.service
  5. Check Status
    • sudo service snap.rocketchat-server.rocketchat-server status
    • sudo service snap.rocketchat-server.rocketchat-mongo status
    • sudo service snap.rocketchat-server.rocketchat-caddy status

Deploy Automated Backups

  1. Move systemd/myrocketchat-backup.timer and systemd/myrocketchat-backup.service to /etc/systemd/system/
    • /etc/systemd/system/myrocketchat-backup.timer
    • /etc/systemd/system/myrocketchat-backup.service
  2. Enable the timer
    • sudo systemctl enable myrocketchat-backup.timer
  3. Start the timer
    • sudo systemctl start myrocketchat-backup.timer

Helpful tips

  1. View Logs
    sudo journalctl -f -u snap.rocketchat-server.rocketchat-server
    sudo journalctl -f -u snap.rocketchat-server.rocketchat-mongo
    sudo journalctl -f -u snap.rocketchat-server.rocketchat-caddy

Common Errors

  1. Google Oauth2 - redirect_uri_mismatch

    • In the Authorized redirect URIs field, add both urls

      https://rocketchat.domain.com/_oauth/google
      https://rocketchat.domain.com/_oauth/google?close

Links

https://snapcraft.io/rocketchat-server

[Unit]
Description=Backup service for Rocketchat

[Service]
Environment=ROCKETCHAT_BACKUP_DIR=/var/snap/rocketchat-server/common/backup/
Type=oneshot
ExecStartPre=/usr/bin/sudo /usr/sbin/service snap.rocketchat-server.rocketchat-server stop 1
ExecStartPre=-/usr/bin/sudo /usr/bin/snap run rocketchat-server.backupdb 2
ExecStartPre=-/usr/bin/sudo /bin/sh -c 'aws s3 sync ${ROCKETCHAT_BACKUP_DIR} s3://domain-backups/rocketchat/$$(date +%%m-%%d-%%Y)/' 3
ExecStart=/usr/bin/sudo /bin/sh -c  '/bin/rm ${ROCKETCHAT_BACKUP_DIR}*; /usr/sbin/service snap.rocketchat-server.rocketchat-server start'
User=ubuntu
Group=systemd-journal

## Issue 1
## Snap has to be run with sudo
## permanently dropping privilege did not work: File exists

## Issue 2
## rm glob * become expanded when the service starts
## /var/snap/rocketchat-server/common/backup/ will be empty
## Moved the command to exec start so the glob will be
## populated properly
[Unit]
Description=Backup timer for Rocketchat
Requires=myrocketchat-backup.service

[Timer]
OnCalendar=Mon,Wed,Fri,Sun 02:00
Persistent=true

[Install]
WantedBy=timers.target