Install Etsy Morgue on Ubuntu 16.04

Posted on Saturday, January 21, 2017






I am going to be looking into a tool called Morgue, created by Etsy, to see if it’s a good fit for our team.

This tool is for keeping track of post mortems for a development team. 

Here are a few links to get you started.

   *  https://github.com/etsy/morgue [1]  (Github repo)
   *  http://www.slideshare.net/devopsdays/morgue-helping-better-understand-events-by-building-a-post-mortem-tool-bethany-macri [2] Slideshare
   * https://vimeo.com/77206751 [3] video presentation







Requirements


  • PHP 5.3 or higher
  • MySQL 5.5 or higher
  • PHP MySQL driver
  • Apache
  • mod_rewrite



Install Apache php7


Ubuntu 16.04 is not available via the normal repositories so I am going to attempt to use php7 and see if it will work.



  > sudo apt-get update
  > sudo apt-get upgrade
  > sudo apt-get install -y apache2 apache2-bin \
  libapache2-mod-fastcgi libapache2-mod-php
  > sudo apt-get install -y php7.0-mysql \
 php7.0-imap php7.0-gd unzip
  > sudo phpenmod imap
  > sudo service apache2 restart




Enable php7.0-fpm.conf


  > sudo vi /etc/apache2/conf-available/php7-fpm.conf


And place the following in it


<IfModule mod_fastcgi.c>
AddHandler php7-fcgi .php
Action php7-fcgi /php7-fcgi
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php7-fpm.sock -pass-header Authorization

<Directory /usr/lib/cgi-bin>
    Require all granted
</Directory>

</IfModule>






 Enable the modules


  > sudo a2enmod actions fastcgi alias
  > sudo a2enconf php7-fpm
  > sudo a2enmod rewrite


Restart Apache2


  > sudo service apache2 restart








Test apache/php


Mine instance happens to be running at 192.168.0.55 so I am going to open http://192.168.0.55/



Apache is running, but what about php? 


Create a test php file.


  > sudo vi /var/www/html/phpinfo.php


Place the following in it


<?php

phpinfo();

?>


Save it then run this to change ownership to www-data


  > sudo chown -R www-data:www-data /var/www/html/







It's working!







Make sure mod_rewrite is enabled


Search for mod_rewrite on the phpinfo page






Looks good to go.

Note: for a real build remember to remove the phpinfo.ini file don't want this valuable info falling into the wrong hands.



  > sudo rm /var/www/html/phpinfo.php







Install MySQL 5.7




  > sudo apt-get update
  > sudo apt-get install mysql-server mysql-client
  > sudo mysql_secure_installation




Set a new root user password for mysql.  For this demo I just made it mypassword


Improve MySQL security by running this command https://dev.mysql.com/doc/refman/5.7/en/mysql-secure-installation.html [3].


  > mysql_secure_installation




Enter the password and enter No

I already set a password for root…



Yes remove Anon Users.





Disallow root login remotely.



Remove test database.



Reload privileges now.  Yes!




Done!





Login to MySQL and create Database



  > mysql -u root -p


And run this sql query. See https://github.com/etsy/morgue#mysql   [4] (of course you would want to change the password)


  > CREATE DATABASE morgue;
CREATE USER 'morgue'@'localhost' IDENTIFIED BY 'morgue';
GRANT ALL ON morgue.* TO 'morgue'@'localhost';
SET PASSWORD FOR 'morgue'@'localhost' = PASSWORD('my_morgue_password');





Download the github repo


  > git clone https://github.com/etsy/morgue.git


Now upload the schemas to mysql



  > mysql -p -u morgue -h localhost \
 morgue < morgue/schemas/postmortems.sql




Use the password you set for the morgue user in mysql

Now for the rest of the schemas


  > mysql -p -u morgue -h localhost \
 morgue < morgue/schemas/images.sql






  > mysql -p -u morgue -h localhost \
 morgue < morgue/schemas/jira.sql



  > mysql -p -u morgue -h localhost \
 morgue < morgue/schemas/links.sql



  > mysql -p -u morgue -h localhost \
 morgue < morgue/schemas/irc.sql







 Copy repo to /var/www

  

  > sudo cp -R morgue /var/www


Chown


  > sudo chown -R www-data:www-data morgue /var/www/morgue




  > cd /var/www/morgue/
  > sudo php -r "copy('https://getcomposer.org/installer', \
  'composer-setup.php');"
  > sudo php -r "if (hash_file('SHA384', \
 'composer-setup.php') === \
'55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') \
{ echo 'Installer verified'; } else \
{ echo 'Installer corrupt'; unlink('composer-setup.php'); } \
 echo PHP_EOL;"
  > sudo php composer-setup.php
  > sudo php -r "unlink('composer-setup.php');"




Now use it to update



  > sudo php composer.phar update


I get a warning for running it as a super user but for now I just want to get it running




Now edit the apach configuration file


  > sudo vi /etc/apache2/sites-enabled/000-default.conf


And place the following in it.


<VirtualHost *:80>
     ServerName   morgue.hostname.com

     DocumentRoot /var/www/morgue/htdocs

     <Directory /var/www/morgue/htdocs>
       AllowOverride All
     </Directory>

     SetEnv MORGUE_ENVIRONMENT development

     php_value include_path "/var/www/morgue:/var/www/morgue/features"
</VirtualHost>



Restart Apache



  > sudo service apache2 restart


Now open morgue

http://192.168.0.55/   (that is my url)




OK got somewhere.






Configuration file



  > sudo cp config/example.json config/development.json





  > sudo vi config/development.json


I need to update the password to the database.



I think there are a lot more tweaks needed for this file… but for now reload the web page.





Hey that did something.







Kick the tires


OK now that I have it running how does it work?




Click Create



Fill it out.



Start time:  When stuff started to break
End Time:  When we got it running again
Detect Time:  When we detected the problem
Status Time:  (Optional List planned downtime near the incident)



Severity…. Hover over it to get a list







You can edit the levels in config/development.json settings.



Requires you to restart apache.





Click Create.





There is my page








Click here to make changes.









Fill it out you can use Markdown






Click Save Changes at the top.






You can drag and drop images in.





I can click on Report to list all my reports.





No images?  I wonder what I did wrong…


Ahh you need to tweak that feature see this page https://github.com/etsy/morgue/tree/master/features/upload [6]

Basically you need to set up another place to store the files see  it here in the config/development.json file.

 



I am not going to set that up now as I am just poking at it to see what it can do.




You can enter images with a URL


 

That works out of the box.
But then you are dependent on outside urls being valid in the future.  Long term, not a good solution.





Useful links


Looks like they littered README.md pages throughout their github repo.





Click on any feature and chances are it has a README page associated with it to help you set up all those features.


OK I am done I have a very basic barely working install, from here I can start setting up each feature I want to use one at a time.



References


[1]        Morgue github repo
Accessed 1/2017
[2]        Morgue slideshare
Accessed 1/2017
[3]        Morgue video presentation
Accessed 1/2017
[4]        Morgue github mysql commands
Accessed 1/2017
[5]        Composer download page
[6]        upload feature
[7]        Features



No comments:

Post a Comment