From 3fb41ca3b847a8f41a7626ee8871bd2f43cd781d Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Wed, 28 Sep 2016 16:14:08 +0200 Subject: [PATCH 01/12] install timezone pkg and update symlink based on osfamily --- timezone/init.sls | 11 +++++++++++ timezone/map.jinja | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 timezone/map.jinja diff --git a/timezone/init.sls b/timezone/init.sls index facd463..b3e01c7 100644 --- a/timezone/init.sls +++ b/timezone/init.sls @@ -2,8 +2,19 @@ {%- 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 }} + +{{ confmap.path-localtime }}: + file.symlink: + - target: {{ path-zoneinfo }}{{ timezone }} + - require: + - pkg: {{ confmap.pkgname }} diff --git a/timezone/map.jinja b/timezone/map.jinja new file mode 100644 index 0000000..49bef33 --- /dev/null +++ b/timezone/map.jinja @@ -0,0 +1,9 @@ +{% set map = { + 'Suse': { + 'path-localtime': '/etc/localtime', + 'path-zoneinfo': '/usr/share/zoneinfo/', + 'pkgname': 'timezone', + }, +} %} + +{% set confmap = map.get(grains.os_family) %} From d82f9c9a828973ca8b57251ff620e22a749b4b30 Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Wed, 28 Sep 2016 16:26:49 +0200 Subject: [PATCH 02/12] bugfix in symlink function --- timezone/init.sls | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/timezone/init.sls b/timezone/init.sls index b3e01c7..4a8ccad 100644 --- a/timezone/init.sls +++ b/timezone/init.sls @@ -13,8 +13,8 @@ timezone.packages: pkg.installed: - name: {{ confmap.pkgname }} -{{ confmap.path-localtime }}: - file.symlink: - - target: {{ path-zoneinfo }}{{ timezone }} - - require: - - pkg: {{ confmap.pkgname }} +file.symlink: + - name: {{ confmap.path-localtime }} + - target: {{ path-zoneinfo }}{{ timezone }} + - require: + - pkg: {{ confmap.pkgname }} From 136815edfb9036deab53ff94a76900ac71dd008b Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Wed, 28 Sep 2016 16:30:15 +0200 Subject: [PATCH 03/12] ...# --- timezone/init.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/timezone/init.sls b/timezone/init.sls index 4a8ccad..8393100 100644 --- a/timezone/init.sls +++ b/timezone/init.sls @@ -15,6 +15,6 @@ timezone.packages: file.symlink: - name: {{ confmap.path-localtime }} - - target: {{ path-zoneinfo }}{{ timezone }} + - target: {{ confmap.path-zoneinfo }}{{ timezone }} - require: - pkg: {{ confmap.pkgname }} From f156e4b74aead1d80fad6b92b45d579106be6177 Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Wed, 28 Sep 2016 16:35:52 +0200 Subject: [PATCH 04/12] another symlink bugfix testing --- timezone/init.sls | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/timezone/init.sls b/timezone/init.sls index 8393100..f1664d1 100644 --- a/timezone/init.sls +++ b/timezone/init.sls @@ -13,8 +13,10 @@ timezone.packages: pkg.installed: - name: {{ confmap.pkgname }} -file.symlink: - - name: {{ confmap.path-localtime }} - - target: {{ confmap.path-zoneinfo }}{{ timezone }} - - require: - - pkg: {{ confmap.pkgname }} +timezone.symlink: + file.symlink: + - name: {{ confmap.path-localtime }} + - target: {{ confmap.path-zoneinfo }}{{ timezone }} + - force: true + - require: + - pkg: {{ confmap.pkgname }} From 20b81e67f667e430a2b03177865f0e67d078670a Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Wed, 28 Sep 2016 16:44:20 +0200 Subject: [PATCH 05/12] changed variable-names in jinja according to https://github.com/ansible/ansible/issues/3907 --- timezone/init.sls | 4 ++-- timezone/map.jinja | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/timezone/init.sls b/timezone/init.sls index f1664d1..081e147 100644 --- a/timezone/init.sls +++ b/timezone/init.sls @@ -15,8 +15,8 @@ timezone.packages: timezone.symlink: file.symlink: - - name: {{ confmap.path-localtime }} - - target: {{ confmap.path-zoneinfo }}{{ timezone }} + - 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 index 49bef33..9586f2b 100644 --- a/timezone/map.jinja +++ b/timezone/map.jinja @@ -1,7 +1,7 @@ {% set map = { 'Suse': { - 'path-localtime': '/etc/localtime', - 'path-zoneinfo': '/usr/share/zoneinfo/', + 'path_localtime': '/etc/localtime', + 'path_zoneinfo': '/usr/share/zoneinfo/', 'pkgname': 'timezone', }, } %} From de9d96da1cf95f2fd3be514f3e9839a73757c687 Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Wed, 28 Sep 2016 17:24:00 +0200 Subject: [PATCH 06/12] added debian to mapfile --- timezone/map.jinja | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/timezone/map.jinja b/timezone/map.jinja index 9586f2b..3923683 100644 --- a/timezone/map.jinja +++ b/timezone/map.jinja @@ -1,4 +1,9 @@ {% set map = { + 'Debian': { + 'path_localtime': '/etc/localtime', + 'path_zoneinfo': '/usr/share/zoneinfo/', + 'pkgname': 'tzdata', + }, 'Suse': { 'path_localtime': '/etc/localtime', 'path_zoneinfo': '/usr/share/zoneinfo/', From 72ef682bff19ee98eacace8dd38052224728f269 Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Thu, 29 Sep 2016 14:56:35 +0200 Subject: [PATCH 07/12] changed function names for better looking code --- timezone/init.sls | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/timezone/init.sls b/timezone/init.sls index 081e147..df41740 100644 --- a/timezone/init.sls +++ b/timezone/init.sls @@ -9,11 +9,11 @@ timezone_setting: - name: {{ timezone }} - utc: {{ utc }} -timezone.packages: +timezone_packages: pkg.installed: - name: {{ confmap.pkgname }} -timezone.symlink: +timezone_symlink: file.symlink: - name: {{ confmap.path_localtime }} - target: {{ confmap.path_zoneinfo }}{{ timezone }} From 611d4631f157595911001c1d077dc9b91f272891 Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Thu, 29 Sep 2016 15:01:25 +0200 Subject: [PATCH 08/12] changed FORMULA according to contents of map.jinja, other distributions may follow --- FORMULA | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FORMULA b/FORMULA index 8190556..1b0827f 100644 --- a/FORMULA +++ b/FORMULA @@ -1,6 +1,6 @@ name: timezone -os: RedHat, Debian, Ubuntu, Suse, FreeBSD -os_family: RedHat, Debian, Suse, FreeBSD +os: Debian, Suse +os_family: Debian, Suse version: 201504 release: 1 minimum_version: 2015.5 From 54b6b9503a620c735b2559b344d192f4ebc07a00 Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Thu, 29 Sep 2016 15:32:32 +0200 Subject: [PATCH 09/12] added Redhat in map.jinja --- timezone/map.jinja | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/timezone/map.jinja b/timezone/map.jinja index 3923683..89617e6 100644 --- a/timezone/map.jinja +++ b/timezone/map.jinja @@ -4,6 +4,11 @@ '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/', From 5c564d8b462bb5327ef242329a3d20579052aab7 Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Thu, 29 Sep 2016 15:33:20 +0200 Subject: [PATCH 10/12] added Redhat in map.jinja --- FORMULA | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FORMULA b/FORMULA index 1b0827f..d99cdeb 100644 --- a/FORMULA +++ b/FORMULA @@ -1,6 +1,6 @@ name: timezone -os: Debian, Suse -os_family: Debian, Suse +os: Debian, Redhat, Suse +os_family: Debian, Redhat, Suse version: 201504 release: 1 minimum_version: 2015.5 From 8401d3dfa7386cfccdbe5cb9ef3baa5229602d0a Mon Sep 17 00:00:00 2001 From: Thorsten Bro Date: Thu, 29 Sep 2016 15:34:43 +0200 Subject: [PATCH 11/12] added Redhat in map.jinja --- FORMULA | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FORMULA b/FORMULA index d99cdeb..3cfb737 100644 --- a/FORMULA +++ b/FORMULA @@ -1,6 +1,6 @@ name: timezone -os: Debian, Redhat, Suse -os_family: Debian, Redhat, Suse +os: Debian, RedHat, Suse +os_family: Debian, RedHat, Suse version: 201504 release: 1 minimum_version: 2015.5 From 4e881296c762329dd87d36910282830614c0b709 Mon Sep 17 00:00:00 2001 From: Florian Bittner Date: Sat, 25 Apr 2015 12:23:45 +0200 Subject: [PATCH 12/12] 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) %}