Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

An ansible role to make a host shutdown after the work is done.

License

Notifications You must be signed in to change notification settings

victorklos/ansible-role-shutdown-on-idle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is archived

Feel free to fork.


Build Status

Ansible role to shutdown a server after the work is done.

This role installs a systemd service with timer that monitors a server for activity and shuts it down after it has been idling for a specific period. Ideal for special-purpose servers with few users, like my deep learning/blender server.

Features

This ansible role:

  • uses systemd timers to periodically
  • monitor ssh connections, CPU and GPU load
  • shuts down the server when it is idling too long

Suitable for headless servers.

Example playbook

- hosts: all

  vars:
    shutdown_on_idle_max_idle_time: 1800

  roles:
    - victorklos.shutdown-on-idle

Supported role variables

See example playbook above, default value as indicated.

Notes

Remember to also kick inactive ssh users or otherwise the host will never be considered idle.

You can see what is going on by issueing one of these:

systemctl status shutdown_on_idle.timer             # the timer part
systemctl status shutdown_on_idle.service           # the monitoring part
journalctl --boot --unit=shutdown_on_idle.service   # all logs since boot

Licence

MIT

About

An ansible role to make a host shutdown after the work is done.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages