Git Product home page Git Product logo

ansible-role-systemd-notify's Introduction

ansible-role-systemd-notify

License Build Status Build Status Build Status Updates Python 3 Ansible Role GitHub tag

Install email notify for a systemd service.

Requirements

This role requires Ansible 2.4 or higher and platform requirements are listed in the metadata file.

Testing

This role use Molecule to run tests.

Local and Travis tests run tests on Docker by default. See molecule documentation to use other backend.

Currently, tests are done on:

  • Debian Stretch
  • Ubuntu Xenial
  • Ubuntu Bionic

and use:

  • Ansible 2.4.x
  • Ansible 2.5.x
  • Ansible 2.6.x
  • Ansible 2.7.x

Running tests

Using Docker driver

$ tox

Role Variables

Default role variables

# Dependencies management
systemd_notify_use_ansible_galaxy_dependencies: True  # Use role dependencies in meta
ssmtp_use_ansible_galaxy_dependencies: True


service_name_to_modify: 'sshd' #change it to modify systemd service you want alert on

notify_mail_config:
  - src: "{{ role_path }}/templates/systemd.email.j2"
    dest: '/usr/local/bin/systemd-email'
    owner: 'root'
    group: 'root'
    mode: '0755'

notify_service_systemd:
  - src: "{{ role_path }}/templates/notify.service.j2"
    dest: '/etc/systemd/system/[email protected]'
    owner: 'root'
    group: 'root'
    mode: '0644'
    options:
      Unit:
        Description: 'status email for %i to user'
        After: 'network.target'
      Service:
        Type: 'oneshot'
        ExecStart: '/usr/local/bin/systemd-email {{ notify_toEmail }} %i'
        User: 'nobody'
        Group: 'systemd-journal'

notify_fromEmail: '[email protected]'
notify_toEmail: '[email protected]'

systemd_service_states:
  - name: "{{ service_name_to_modify }}"
    state: "started"
    enabled: True
    daemon_reload: True

systemd_notify_options:
  - dest: "/etc/systemd/system/{{ service_name_to_modify }}.service"
    insertafter: '^Description'
    line: 'OnFailure=notify@%n'
    state: 'present'

Dependencies

You can disable role dependencies using systemd_notify_use_ansible_galaxy_dependencies or ssmtp_use_ansible_galaxy_dependencies and setting False

Example Playbook

- hosts: servers
  roles:
    - { role: Temelio.systemd-notify }

License

MIT

Author Information

Lise Machetel (for Temelio company)

ansible-role-systemd-notify's People

Contributors

achaussier avatar lmachetel avatar pyup-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.