No description
Find a file
2024-07-12 14:42:48 +02:00
defaults Initial import 2024-07-12 14:38:33 +02:00
files Initial import 2024-07-12 14:38:33 +02:00
handlers fix: add missing yaml 2024-07-12 14:42:48 +02:00
meta Initial import 2024-07-12 14:38:33 +02:00
molecule Initial import 2024-07-12 14:38:33 +02:00
tasks Initial import 2024-07-12 14:38:33 +02:00
vars fix: add missing yaml 2024-07-12 14:42:48 +02:00
.gitignore Initial import 2024-07-12 14:38:33 +02:00
.yamllint Initial import 2024-07-12 14:38:33 +02:00
README.md Initial import 2024-07-12 14:38:33 +02:00
role.yml fix: add missing role.yml 2024-07-12 14:40:25 +02:00

Ansible Role: Notify SSH Login via Ntfy

This Ansible role automates the setup for sending notifications whenever a user logs in to your Linux servers via SSH. It intercepts successful SSH connections using PAM and triggers a script to send an HTTP request with details about the login event.

Features

  • Integrates with PAM to capture successful SSH login attempts.
  • Uses a customizable script to send notifications via an HTTP request.
  • Supports sending notifications to services like ntfy.sh (configurable).
  • Includes Molecule test suite using Vagrant for automated testing.

Requirements

  • Ansible >= 2.9
  • Python package requests (for Molecule tests)

Role Variables

The role utilizes the following default variables, which can be overridden in your playbook:

  • docker_install_compose_plugin (bool): Whether to install the Docker Compose plugin (defaults to false).
  • docker_compose_package (str): Package name for Docker Compose (defaults to docker-compose).

Additional variables are defined within the role's defaults/main.yml file.

Usage

  1. Clone or copy the role directory.
  2. Include the role in your playbook:
---
- name: Notify SSH logins
  hosts: all
  become: true
  roles:
    - notify_ssh_login
  1. Customize variables (optional):

Override any default variables in your playbook's vars section.

  1. Run the playbook:
ansible-playbook your_playbook.yml

Testing

The role includes a Molecule test suite that utilizes Vagrant to provision a test environment. To execute the tests:

  1. Ensure Vagrant and VirtualBox are installed.
  2. Navigate to the role directory.
  3. Run the following commands:
molecule init
molecule converge
molecule verify

Contributing

We welcome contributions to this role! Please see the contributing guidelines in the CONTRIBUTING.md file for details.

License

This role is licensed under the MIT License. See the LICENSE file for details.