defaults | ||
files | ||
meta | ||
molecule | ||
tasks | ||
.gitignore | ||
.yamllint | ||
README.md | ||
role.yml |
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 tofalse
).docker_compose_package
(str): Package name for Docker Compose (defaults todocker-compose
).
Additional variables are defined within the role's defaults/main.yml file.
Usage
- Clone or copy the role directory.
- Include the role in your playbook:
---
- name: Notify SSH logins
hosts: all
become: true
roles:
- notify_ssh_login
- Customize variables (optional):
Override any default variables in your playbook's vars
section.
- 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:
- Ensure Vagrant and VirtualBox are installed.
- Navigate to the role directory.
- 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.