Skip to content

ansible-scylla-monitoring: optional systemd boot service#536

Open
ManjotS wants to merge 3 commits into
devfrom
feat/optional-monitoring-boot-service
Open

ansible-scylla-monitoring: optional systemd boot service#536
ManjotS wants to merge 3 commits into
devfrom
feat/optional-monitoring-boot-service

Conversation

@ManjotS

@ManjotS ManjotS commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add opt-in install_scylla_monitoring_service (default false)
  • When enabled, install and enable scylla-monitoring.service so the stack starts after reboot (and when docker.service restarts via PartOf=)
  • Unit calls the existing start/stop wrapper scripts under scylla_monitoring_deploy_path

Test plan

  • Deploy monitoring with default vars — confirm no systemd unit installed
  • Deploy with -e install_scylla_monitoring_service=true — confirm unit present, enabled, and systemctl cat scylla-monitoring points at wrapper scripts
  • Reboot monitor host — stack comes back via systemd
  • systemctl restart docker — monitoring stops/starts with Docker (PartOf=docker.service)

Made with Cursor

Allow opt-in install of scylla-monitoring.service so the stack
restarts after reboot via the existing start/stop wrappers.

Co-authored-by: Cursor <cursoragent@cursor.com>

@ManjotS ManjotS left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds an opt-in systemd unit (install_scylla_monitoring_service, default false) that installs and enables scylla-monitoring.service, wiring it to the existing start/stop wrapper scripts so the monitoring stack survives reboots and docker.service restarts via PartOf=. The change is small, additive, and off by default, so it carries low risk to existing deployments.

Overall this looks solid — the Requires=/After=/PartOf=docker.service combination on the unit is the correct, idiomatic way to tie a docker-compose-style service to docker.service's lifecycle (see inline praise). A few things worth a look:

  • The unit is enabled but never started by Ansible, so systemctl status scylla-monitoring will report inactive (dead) right after a deploy even though the stack is actually running — see inline comment for details.
  • The new code path (install_scylla_monitoring_service: true) isn't exercised anywhere in the molecule suite, so CI won't catch regressions in the template or task logic.
  • A small style nit (FQCN vs. the file's existing short module names) and a question about the disable/cleanup story when the flag is flipped back off.

Nothing here is blocking — the feature is off by default and functionally sound for the stated goal (reboot survival + docker-restart propagation).

Coverage note: reviewed correctness/logic, security, reliability/operability, maintainability, and test coverage for the diff. I read the role's task graph and templates but did not have a live host to actually exercise the reboot / systemctl restart docker test-plan items from the PR description — those are assessed from the unit file and task logic, not from running them.

Comment thread ansible-scylla-monitoring/tasks/docker.yml
Comment thread ansible-scylla-monitoring/tasks/docker.yml Outdated
Comment thread ansible-scylla-monitoring/tasks/docker.yml
Comment thread ansible-scylla-monitoring/defaults/main.yml
Comment thread ansible-scylla-monitoring/templates/scylla-monitoring.service.j2
- Start the unit (state: started) so systemctl status reflects the running
  stack right after deploy, not just after reboot.
- Use short systemd module name for consistency with the rest of docker.yml.
- Add disable/remove cleanup when install_scylla_monitoring_service is false
  so flipping the flag off no longer leaves an enabled unit behind; running
  stack is left untouched.
- Add reload systemd handler for unit removal.
- Exercise the flag in molecule: enable it in converge and assert the unit is
  installed and enabled in verify.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Comment thread ansible-scylla-monitoring/templates/scylla-monitoring.service.j2
Security review flagged a local privilege escalation: the root-run systemd
unit executed a wrapper script owned by the (potentially non-root) deploy
user, who could edit it and have it run as root on boot.

- Run the unit as the deploy user by default (User=/Group={{ ansible_user_id }}),
  matching the manual start path so root no longer executes a user-owned script.
- When run_docker_with_sudo is set, docker requires root and the unit runs as
  root, so write the wrapper scripts root:root to keep them non-writable by the
  deploy user.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant