buluma.mailhog

Ansible role mailhog

MailHog for Linux

GitHub Version Issues Pull Requests Downloads
github Version Issues PullRequests Ansible Role

Example Playbook

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: all
  become: false

  pre_tasks:
    - name: Update apt cache.
      apt: update_cache=true cache_valid_time=600
      when: ansible_os_family == 'Debian'

    - name: Ensure build dependencies are installed (RedHat).
      ansible.builtin.package:
        name:
          - "@Development tools"
          - tar
          - unzip
          - net-tools
          - curl
        state: present
      when: ansible_os_family == 'RedHat'

    - name: Ensure build dependencies are installed (Debian).
      ansible.builtin.apt:
        name:
          - build-essential
          - tar
          - unzip
          - net-tools
          - curl
        state: present
      when: ansible_os_family == 'Debian'

  roles:
    - buluma.daemonize
    - buluma.mailhog

  post_tasks:
    - name: Copy test message into place.
      ansible.builtin.copy:
        src: test-message
        dest: /tmp/test-message
        mode: 0644

    - name: Send an email via mhsendmail.
      shell: cat /tmp/test-message | /opt/mailhog/mhsendmail [email protected]
      changed_when: false

    - name: Test retrieiving messages from the MailHog API.
      ansible.builtin.uri:
        url: http://localhost:8025/api/v2/messages
      register: result
      until: result.status == 200
      retries: 60
      delay: 1

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: false

  roles:
    - role: buluma.bootstrap

Also see a full explanation and example on how to use these roles.

Role Variables

The default values for the variables are set in defaults/main.yml:

---
mailhog_install_dir: /opt/mailhog
mailhog_version: "1.0.0"
mailhog_binary_url: "https://github.com/mailhog/MailHog/releases/download/v{{ mailhog_version }}/MailHog_linux_amd64"
mhsendmail_version: "0.2.0"
mhsendmail_binary_url: "https://github.com/mailhog/mhsendmail/releases/download/v{{ mhsendmail_version }}/mhsendmail_linux_amd64"

# Path to daemonize, which is used to launch MailHog via init script.
mailhog_daemonize_bin_path: /usr/sbin/daemonize

Requirements

State of used roles

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub Version
buluma.bootstrap Ansible Molecule Version
buluma.daemonize Ansible Molecule Version

Dependencies

Most roles require some kind of preparation, this is done in molecule/default/prepare.yml. This role has a "hard" dependency on the following roles:

  • {'role': 'buluma.daemonize'}

Context

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles:

dependencies

Compatibility

This role has been tested on these container images:

container tags
EL 8, 9
Ubuntu all
Debian all

The minimum version of Ansible required is 2.4, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub

Changelog

Role History

License

Apache-2.0

Author Information

Shadow Walker

Install
ansible-galaxy install buluma.mailhog
GitHub repository
License
apache-2.0
Downloads
82
Owner
DevOps Engineer