Browse Source

[mailhog] Add mailhog role

Colin Powell 4 years ago
parent
commit
168e6e69b0

+ 4 - 0
ansible/hosts

@@ -19,6 +19,7 @@ search.local
 tor.local
 ttrss.local
 fifteen5.local
+mailhog.local
 
 [vms]
 mopidy.local
@@ -90,3 +91,6 @@ fifteen5.local
 
 [pgadmin]
 db.local
+
+[mailhog]
+mailhog.local

+ 4 - 0
ansible/playbook.yml

@@ -3,6 +3,10 @@
   roles:
     - role: avahi
 
+- hosts: mailhog
+  roles:
+    - role: mailhog
+
 - hosts: pgadmin
   roles:
     - role: pgadmin4

+ 9 - 0
ansible/roles/mailhog/files/supervisor.conf

@@ -0,0 +1,9 @@
+[program:mailhog]
+directory=/root
+environment=MH_HOSTNAME='mailhog.local',MH_UI_BIND_ADDR='0.0.0.0:80',MH_API_BIND_ADDR='0.0.0.0:80'
+command=/usr/local/bin/mailhog
+autostart=true
+autorestart=true
+stdout_logfile=/var/log/mailhog.log
+stderr_logfile=/var/log/mailhog.err.log
+stopsignal=QUIT

+ 8 - 0
ansible/roles/mailhog/files/supervisord.conf.patch

@@ -0,0 +1,8 @@
+@@ -125,5 +125,5 @@
+ ; interpreted as relative to this file.  Included files *cannot*
+ ; include files themselves.
+
+-;[include]
+-;files = relative/directory/*.ini
++[include]
++files = supervisor/conf.d/*.conf

+ 5 - 0
ansible/roles/mailhog/handlers/main.yml

@@ -0,0 +1,5 @@
+---
+- name: Supervisor restarted
+  service:
+    name: supervisord
+    state: restarted

+ 33 - 0
ansible/roles/mailhog/tasks/main.yml

@@ -0,0 +1,33 @@
+---
+- name: Package cache updated
+  shell: pkg update -f
+
+- name: Mailhog binary downloaded
+  get_url:
+    url: https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_freebsd_amd64
+    dest: /usr/local/bin/mailhog
+    validate_certs: no
+    mode: '0744'
+
+- name: Dependencies installed
+  pkgng:
+    name: "py37-pip py37-supervisor"
+    state: present
+
+- name: Supervisor enabled
+  shell: sysrc supervisord_enable="YES"
+
+- name: Supervisor config file patched
+  patch:
+    src: supervisord.conf.patch
+    dest: /usr/local/etc/supervisord.conf
+
+  notify: Supervisor restarted
+
+- name: Supervisor file installed
+  copy:
+    src: supervisor.conf
+    dest: /usr/local/etc/supervisor/conf.d/
+    owner: root
+    mode: 0644
+  notify: Supervisor restarted