Skip to content

Commit

Permalink
Merge pull request #21 from palantirnet/drupalbox/mailhog
Browse files Browse the repository at this point in the history
Adds mailhog role
  • Loading branch information
mathewpeterson authored Aug 4, 2016
2 parents 47b2410 + e50e398 commit 89e95dd
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 0 deletions.
1 change: 1 addition & 0 deletions drupalbox/CHANGELOG-0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added

- Memcached role
- Mailhog role
4 changes: 4 additions & 0 deletions drupalbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
| __Username__ | drupal |
| __Password__ | drupal |
| __Database__ | drupal |

### Mailhog

Mailhog's smtp service listens on port 1025 and http service listens on port 8025
3 changes: 3 additions & 0 deletions drupalbox/drupalbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
hostname: drupalbox
rvm1_user: vagrant
rvm1_install_path: /home/vagrant/.rvm
vars:
php_ini_sendmail_path: "/usr/local/bin/mhsendmail"
vars_files:
- vars/default/common.yml
- vars/dev/mysql.yml
Expand All @@ -16,6 +18,7 @@
- { role: git }
- { role: rvm_io.rvm1-ruby, tags: ruby, sudo: true }
- { role: memcached }
- { role: mailhog }
- { role: apache }
- { role: mysql-client }
- { role: mysql-server }
Expand Down
12 changes: 12 additions & 0 deletions drupalbox/tests/mailhog_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require_relative 'spec_helper'

%w{mailhog mhsendmail}.each do |name|
describe command("which #{name}") do
its(:exit_status) { should eq 0 }
end
end

describe process("mailhog") do
it { should be_running }
its(:user) { should eq "mailhog" }
end
7 changes: 7 additions & 0 deletions provisioning/roles/mailhog/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
mailhog_version: v0.2.0
mailhog_user: mailhog
mailhog_group: mailhog
mailhog_home_dir: /usr/local/mailhog
mailhog_binary_url: "https://github.com/mailhog/MailHog/releases/download/{{ mailhog_version}}/MailHog_linux_amd64"
mhsendmail_binary_url: "https://github.com/mailhog/mhsendmail/releases/download/{{ mailhog_version }}/mhsendmail_linux_amd64"
99 changes: 99 additions & 0 deletions provisioning/roles/mailhog/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---

- name: Mailhog | Create Mailhog Group
become: yes
group:
name: "{{ mailhog_group }}"
system: yes
state: present
tags: mailhog

- name: Mailhog | Create Mailhog User
become: yes
user:
name: "{{ mailhog_user }}"
group: "{{ mailhog_group }}"
home: "{{ mailhog_home_dir }}"
system: yes
shell: /usr/sbin/nologin
state: present
tags: mailhog

- name: Mailhog | Create Mailhog Directories
become: yes
file:
path: "{{ item }}"
state: directory
mode: 0755
owner: "{{ mailhog_user }}"
group: "{{ mailhog_group }}"
with_items:
- "{{ mailhog_home_dir }}"
- "{{ mailhog_home_dir }}/bin"
tags: mailhog

- name: Mailhog | Download Mailhog
become: yes
get_url:
url: "{{ mailhog_binary_url }}"
dest: "{{ mailhog_home_dir }}/bin/mailhog"
mode: 0755
owner: "{{ mailhog_user }}"
group: "{{ mailhog_group }}"
tags: mailhog

- name: Mailhog | Download MHSendmail
become: yes
get_url:
url: "{{ mhsendmail_binary_url }}"
dest: "{{ mailhog_home_dir }}/bin/mhsendmail"
mode: 0755
owner: "{{ mailhog_user }}"
group: "{{ mailhog_group }}"
tags: mailhog

- name: Mailhog | Symlink Mailhog to /usr/local/bin
become: yes
file:
src: "{{ mailhog_home_dir }}/bin/mailhog"
dest: /usr/local/bin/mailhog
state: link
tags: mailhog

- name: Mailhog | Symlink Mhsendmail to /usr/local/bin
become: yes
file:
src: "{{ mailhog_home_dir }}/bin/mhsendmail"
dest: /usr/local/bin/mhsendmail
state: link
tags: mailhog

- name: Mailhog | Configure Upstart Mailhog Service
become: yes
template:
src: upstart/mailhog.conf.j2
dest: /etc/init/mailhog.conf
mode: 0755
owner: root
group: root
when: ansible_distribution_version == '14.04'
tags: mailhog

- name: Mailhog | Configure Systemd Mailhog Service
become: yes
template:
src: systemd/mailhog.service.j2
dest: /lib/systemd/system/mailhog.service
mode: 0755
owner: root
group: root
when: ansible_distribution_version == '16.04'
tags: mailhog

- name: Mailhog | Enable Mailhog
become: yes
service:
name: mailhog
enabled: yes
state: started
tags: mailhog
11 changes: 11 additions & 0 deletions provisioning/roles/mailhog/templates/systemd/mailhog.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=
Documentation=
User={{ mailhog_user }}
Group={{ mailhog_group }}

[Service]
ExecStart={{ mailhog_home_dir }}/bin/mailhog

[Install]
WantedBy=multi-user.target
11 changes: 11 additions & 0 deletions provisioning/roles/mailhog/templates/upstart/mailhog.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description "Mailhog"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

setuid {{ mailhog_user }}
setgid {{ mailhog_group }}

exec {{ mailhog_home_dir }}/bin/mailhog

0 comments on commit 89e95dd

Please sign in to comment.