diff --git a/FORMULA b/FORMULA new file mode 100644 index 0000000..3cfb737 --- /dev/null +++ b/FORMULA @@ -0,0 +1,8 @@ +name: timezone +os: Debian, RedHat, Suse +os_family: Debian, RedHat, Suse +version: 201504 +release: 1 +minimum_version: 2015.5 +summary: Formula for timezone management +description: Formula for managing timezone settings diff --git a/README.rst b/README.rst index 41f2db1..8363a30 100644 --- a/README.rst +++ b/README.rst @@ -28,4 +28,4 @@ Default values are: timezone: 'Europe/Berlin' utc: True -See mopidy/pillar.example. +See timezone/pillar.example. diff --git a/timezone/init.sls b/timezone/init.sls index facd463..df41740 100644 --- a/timezone/init.sls +++ b/timezone/init.sls @@ -2,8 +2,21 @@ {%- set timezone = salt['pillar.get']('timezone:name', 'Europe/Berlin') %} {%- set utc = salt['pillar.get']('timezone:utc', True) %} +{% from "timezone/map.jinja" import confmap with context %} timezone_setting: timezone.system: - name: {{ timezone }} - utc: {{ utc }} + +timezone_packages: + pkg.installed: + - name: {{ confmap.pkgname }} + +timezone_symlink: + file.symlink: + - name: {{ confmap.path_localtime }} + - target: {{ confmap.path_zoneinfo }}{{ timezone }} + - force: true + - require: + - pkg: {{ confmap.pkgname }} diff --git a/timezone/map.jinja b/timezone/map.jinja new file mode 100644 index 0000000..89617e6 --- /dev/null +++ b/timezone/map.jinja @@ -0,0 +1,19 @@ +{% set map = { + 'Debian': { + 'path_localtime': '/etc/localtime', + 'path_zoneinfo': '/usr/share/zoneinfo/', + 'pkgname': 'tzdata', + }, + 'Redhat': { + 'path_localtime': '/etc/localtime', + 'path_zoneinfo': '/usr/share/zoneinfo/', + 'pkgname': 'tzdata', + }, + 'Suse': { + 'path_localtime': '/etc/localtime', + 'path_zoneinfo': '/usr/share/zoneinfo/', + 'pkgname': 'timezone', + }, +} %} + +{% set confmap = map.get(grains.os_family) %}