Added sleep state

This commit is contained in:
Gregory Ballantine 2023-05-02 21:10:40 -06:00
parent 9deffb5713
commit 8a873b3b21
4 changed files with 49 additions and 1 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) <year> <owner> Copyright (c) 2023 Gregory Ballantine
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

2
system/defaults.yaml Normal file
View File

@ -0,0 +1,2 @@
sleep:
disable: True

29
system/map.jinja Normal file
View File

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja ts=2 sw=2 expandtab
{## Start with defaults from defaults.sls ##}
{% import_yaml 'system/defaults.yaml' as default_settings %}
{##
Setup variable using grains['os_family'] based logic, only add key:values here
that differ from whats in defaults.yaml
##}
{% set flavor_map = salt['grains.filter_by'](
{
'Debian': {},
'FreeBSD': {},
'RedHat': {}
},
grain='os_family',
merge=salt['pillar.get']('system')
) %}
{## Merge the flavor_map over the default settings ##}
{% do default_settings.update(flavor_map) %}
{## Merge in changes from the system pillar ##}
{% set system_settings = salt['pillar.get'](
'system',
default=default_settings.nsswitch,
merge=True
) %}

17
system/sleep.sls Normal file
View File

@ -0,0 +1,17 @@
{% from "system/map.jinja" import system_settings.sleep as settings with context %}
disable_sleep_target:
service.masked:
- name: 'sleep.target'
disable_suspend_target:
service.masked:
- name: 'suspend.target'
disable_hibernate_target:
service.masked:
- name: 'hibernate.target'
disable_hybrid-sleep_target:
service.masked:
- name: 'hybrid-sleep.target'