2018年3月1日木曜日

VagrantでMattermostとMySQLをインストールした仮想マシン(Ubuntu16.04)を構築する

MattermostはSlackのようなメッセージング環境を構築する事ができます。
以下のVagrantfileを使用して、MattermostとMySQLがインストールされた仮想マシンを構築する事ができます。
仮想マシン構築後、ブラウザからhttp://192.168.55.105:8065にアクセスして初期設定を行います。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.hostname = "ub1604mattermost"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1604mattermost"
     vbox.cpus = 2
     vbox.memory = 2048
     vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
  end
config.vm.network "private_network", ip: "192.168.55.105", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.105", :netmask => "255.255.255.0"
  config.vm.provision "shell", inline: <<-SHELL
sed -i.bak -e "s#http://archive.ubuntu.com/ubuntu/#http://ftp.riken.jp/pub/Linux/ubuntu/#g" /etc/apt/sources.list
apt-get update
apt-get -y install language-pack-ja
localectl set-locale LANG=ja_JP.UTF-8 LANGUAGE="ja_JP:ja"
localectl set-keymap jp106
#DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade

# install mysql
echo "mysql-server-5.7 mysql-server/root_password password root" | sudo debconf-set-selections
echo "mysql-server-5.7 mysql-server/root_password_again password root" | sudo debconf-set-selections
apt-get -y install mysql-server-5.7
mysql -uroot -proot -e "CREATE DATABASE mattermost DEFAULT CHARACTER SET utf8mb4;"
mysql -uroot -proot -e "CREATE USER mattermost@localhost IDENTIFIED BY 'mattermost';"
mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON mattermost.* TO 'mattermost'@'localhost';"
mysql -uroot -proot -e "FLUSH PRIVILEGES;"


# install mattermost
wget https://releases.mattermost.com/4.7.2/mattermost-4.7.2-linux-amd64.tar.gz
tar xvfz mattermost-4.7.2-linux-amd64.tar.gz
mv mattermost /opt
mkdir -p /opt/mattermost/data

useradd --system --user-group mattermost
chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermost

#/opt/mattermost/config/config.json
sed -i -e 's#mmuser:mostest#mattermost:mattermost#' /opt/mattermost/config/config.json
sed -i -e 's#dockerhost:3306#localhost:3306#' /opt/mattermost/config/config.json
sed -i -e 's#mattermost_test#mattermost#' /opt/mattermost/config/config.json

cat << EOF >> /etc/systemd/system/mattermost.service
[Unit]
Description=Mattermost
After=network.target
After=mysql.service
Requires=mysql.service

[Service]
Type=simple
ExecStart=/opt/mattermost/bin/platform
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152

[Install]
WantedBy=mysql.service
EOF
systemctl enable mattermost.service
systemctl start mattermost.service

echo 'access to http://192.168.55.105:8065'
SHELL
end

〇Mattermostの初期設定画面


〇Mattermostの画面


0 件のコメント:

コメントを投稿