|
1 | | -# ansible-auditship |
| 1 | +# Ansible Role: auditship |
2 | 2 |
|
3 | | -Installs auditship (https://gitlab.com/devopsworks/tools/auditship) to ship |
4 | | -audit logs to Fluentd. |
| 3 | +[](https://github.com/devops-works/ansible-auditship/actions?query=workflow%3ACI) |
5 | 4 |
|
6 | | -This role does not check if v is already installed and overrides |
7 | | -existing binary (no way to check version in v yet). |
| 5 | +An Ansible role for installing and configuring [auditship](https://gitlab.com/devopsworks/tools/auditship), a tool that ships Linux audit logs to Fluentd endpoints in real-time. |
8 | 6 |
|
9 | | -## Variables |
| 7 | +## Features |
| 8 | + |
| 9 | +- Automatically downloads the latest auditship binary from GitLab releases |
| 10 | +- Configures auditship as an auditd plugin for real-time log shipping |
| 11 | +- Sets up log rotation to prevent disk space issues |
| 12 | +- Supports multiple Linux distributions (Ubuntu, Debian) |
| 13 | +- Idempotent installation with force reinstall option |
| 14 | + |
| 15 | +## Requirements |
| 16 | + |
| 17 | +- Ansible >= 2.4 |
| 18 | +- Target systems must have `auditd` installed and running |
| 19 | +- Internet connectivity for downloading auditship binary and configuration files |
| 20 | +- Root privileges on target systems |
| 21 | + |
| 22 | +## Role Variables |
| 23 | + |
| 24 | +### Required Variables |
10 | 25 |
|
11 | 26 | - `auditship_fluent_url`: URL to Fluentd endpoint (default: `fluent://127.0.0.1:24224`) |
| 27 | + |
| 28 | +### Optional Variables |
| 29 | + |
| 30 | +- `auditship_force_install`: Forces reinstallation even if binary exists (default: `false`) |
| 31 | + |
| 32 | +### Example Variable Configuration |
| 33 | + |
| 34 | +```yaml |
| 35 | +auditship_fluent_url: "fluent://log-collector.example.com:24224" |
| 36 | +auditship_force_install: true |
| 37 | +``` |
| 38 | +
|
| 39 | +## Dependencies |
| 40 | +
|
| 41 | +None. |
| 42 | +
|
| 43 | +## Example Playbook |
| 44 | +
|
| 45 | +### Basic Usage |
| 46 | +
|
| 47 | +```yaml |
| 48 | +- hosts: servers |
| 49 | + become: true |
| 50 | + roles: |
| 51 | + - devopsworks.auditship |
| 52 | +``` |
| 53 | +
|
| 54 | +### With Custom Fluentd Endpoint |
| 55 | +
|
| 56 | +```yaml |
| 57 | +- hosts: servers |
| 58 | + become: true |
| 59 | + vars: |
| 60 | + auditship_fluent_url: "fluent://log-server.company.com:24224" |
| 61 | + roles: |
| 62 | + - devopsworks.auditship |
| 63 | +``` |
| 64 | +
|
| 65 | +### Force Reinstallation |
| 66 | +
|
| 67 | +```yaml |
| 68 | +- hosts: servers |
| 69 | + become: true |
| 70 | + vars: |
| 71 | + auditship_force_install: true |
| 72 | + roles: |
| 73 | + - devopsworks.auditship |
| 74 | +``` |
| 75 | +
|
| 76 | +## Installation |
| 77 | +
|
| 78 | +### From Ansible Galaxy |
| 79 | +
|
| 80 | +```bash |
| 81 | +ansible-galaxy install devopsworks.auditship |
| 82 | +``` |
| 83 | + |
| 84 | +### From Git Repository |
| 85 | + |
| 86 | +```bash |
| 87 | +ansible-galaxy install git+https://github.com/devops-works/ansible-auditship.git |
| 88 | +``` |
| 89 | + |
| 90 | +## What This Role Does |
| 91 | + |
| 92 | +1. **Version Detection**: Queries GitLab API to find the latest auditship release |
| 93 | +2. **Binary Download**: Downloads the compressed auditship binary for Linux AMD64 |
| 94 | +3. **Installation**: Extracts and installs the binary to `/usr/local/bin/auditship` |
| 95 | +4. **Plugin Configuration**: Creates auditd plugin configuration in `/etc/audit/plugins.d/auditship.conf` |
| 96 | +5. **Log Rotation**: Downloads and installs logrotate configuration to `/etc/logrotate.d/auditship` |
| 97 | + |
| 98 | +## File Locations |
| 99 | + |
| 100 | +- **Binary**: `/usr/local/bin/auditship` |
| 101 | +- **Plugin Config**: `/etc/audit/plugins.d/auditship.conf` |
| 102 | +- **Log Rotation**: `/etc/logrotate.d/auditship` |
| 103 | + |
| 104 | +## Supported Platforms |
| 105 | + |
| 106 | +- Ubuntu (all versions) |
| 107 | +- Debian (all versions) |
| 108 | + |
| 109 | +## Testing |
| 110 | + |
| 111 | +This role includes comprehensive testing using Molecule with Podman driver. |
| 112 | + |
| 113 | +### Prerequisites |
| 114 | + |
| 115 | +```bash |
| 116 | +pip install -r requirements.txt |
| 117 | +``` |
| 118 | + |
| 119 | +### Run Tests |
| 120 | + |
| 121 | +```bash |
| 122 | +# Run all tests |
| 123 | +make test |
| 124 | + |
| 125 | +# Run linting only |
| 126 | +make lint |
| 127 | + |
| 128 | +# Run syntax check |
| 129 | +make syntax |
| 130 | +``` |
| 131 | + |
| 132 | +### Test Platforms |
| 133 | + |
| 134 | +- Ubuntu 24.04 |
| 135 | +- Debian 11 |
| 136 | +- Debian 12 |
| 137 | + |
| 138 | +## Development |
| 139 | + |
| 140 | +### Setup Development Environment |
| 141 | + |
| 142 | +1. Clone the repository |
| 143 | +2. Install dependencies: `make install` |
| 144 | +3. Run tests: `make test` |
| 145 | + |
| 146 | +### Available Make Targets |
| 147 | + |
| 148 | +- `make help` - Show available commands |
| 149 | +- `make install` - Install Python dependencies |
| 150 | +- `make lint` - Run all linting tools |
| 151 | +- `make test` - Run molecule tests |
| 152 | +- `make clean` - Clean up test artifacts |
| 153 | +- `make syntax` - Check Ansible syntax |
| 154 | + |
| 155 | +## Troubleshooting |
| 156 | + |
| 157 | +### Common Issues |
| 158 | + |
| 159 | +1. **Internet Connectivity**: Ensure target systems can reach GitLab for downloading binaries |
| 160 | +2. **Auditd Service**: Verify auditd is installed and running before applying this role |
| 161 | +3. **Permissions**: Role requires root privileges for installation and configuration |
| 162 | + |
| 163 | +### Verification |
| 164 | + |
| 165 | +After running the role, verify installation: |
| 166 | + |
| 167 | +```bash |
| 168 | +# Check binary exists and is executable |
| 169 | +ls -la /usr/local/bin/auditship |
| 170 | + |
| 171 | +# Test auditship version |
| 172 | +/usr/local/bin/auditship -version |
| 173 | + |
| 174 | +# Verify plugin configuration |
| 175 | +cat /etc/audit/plugins.d/auditship.conf |
| 176 | + |
| 177 | +# Check auditd is using the plugin |
| 178 | +sudo service auditd status |
| 179 | +``` |
| 180 | + |
| 181 | +## License |
| 182 | + |
| 183 | +MIT |
| 184 | + |
| 185 | +## Author Information |
| 186 | + |
| 187 | +This role was created by [DevopsWorks](https://devopsworks.io/). |
| 188 | + |
| 189 | +## Contributing |
| 190 | + |
| 191 | +1. Fork the repository |
| 192 | +2. Create a feature branch |
| 193 | +3. Make your changes |
| 194 | +4. Add tests for new functionality |
| 195 | +5. Run the test suite: `make test` |
| 196 | +6. Submit a pull request |
| 197 | + |
| 198 | +## Links |
| 199 | + |
| 200 | +- [auditship project](https://gitlab.com/devopsworks/tools/auditship) |
| 201 | +- [Issue tracker](https://github.com/devops-works/ansible-auditship/issues) |
| 202 | +- [DevopsWorks](https://devopsworks.io/) |
0 commit comments