From 4e881296c762329dd87d36910282830614c0b709 Mon Sep 17 00:00:00 2001 From: Florian Bittner Date: Sat, 25 Apr 2015 12:23:45 +0200 Subject: [PATCH] Fix README. Added FORMULA for Salt Package Manager More detailed: https://docs.saltstack.com/en/latest/topics/spm/ install timezone pkg and update symlink based on osfamily bugfix in symlink function ...# another symlink bugfix testing changed variable-names in jinja according to https://github.com/ansible/ansible/issues/3907 added debian to mapfile changed function names for better looking code changed FORMULA according to contents of map.jinja, other distributions may follow added Redhat in map.jinja added Redhat in map.jinja added Redhat in map.jinja install timezone data containing pkg on several distros and symlink to the choosen timezone --- FORMULA | 8 ++++++++ README.rst | 2 +- timezone/init.sls | 13 +++++++++++++ timezone/map.jinja | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 FORMULA create mode 100644 timezone/map.jinja 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) %}