Merge pull request #1 from thomic/master

automatically install timezone packages and set symlink to localtime-file
This commit is contained in:
Niels Abspoel 2016-09-29 20:07:42 +02:00 committed by GitHub
commit 8d310cd9d3
3 changed files with 34 additions and 2 deletions

View File

@ -1,6 +1,6 @@
name: timezone name: timezone
os: RedHat, Debian, Ubuntu, Suse, FreeBSD os: Debian, RedHat, Suse
os_family: RedHat, Debian, Suse, FreeBSD os_family: Debian, RedHat, Suse
version: 201504 version: 201504
release: 1 release: 1
minimum_version: 2015.5 minimum_version: 2015.5

View File

@ -2,8 +2,21 @@
{%- set timezone = salt['pillar.get']('timezone:name', 'Europe/Berlin') %} {%- set timezone = salt['pillar.get']('timezone:name', 'Europe/Berlin') %}
{%- set utc = salt['pillar.get']('timezone:utc', True) %} {%- set utc = salt['pillar.get']('timezone:utc', True) %}
{% from "timezone/map.jinja" import confmap with context %}
timezone_setting: timezone_setting:
timezone.system: timezone.system:
- name: {{ timezone }} - name: {{ timezone }}
- utc: {{ utc }} - 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 }}

19
timezone/map.jinja Normal file
View File

@ -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) %}