Replace timezone-ii cookbook with timezone_iii

This fork supports Chef 13 and is still maintained
This commit is contained in:
Greg Karékinian 2017-06-16 13:10:46 +02:00
parent 189b66a36f
commit f93070c4c0
44 changed files with 1045 additions and 576 deletions

2
Batali
View File

@ -33,7 +33,7 @@ Batali.define do
cookbook 'database' cookbook 'database'
cookbook 'mysql2_chef_gem', '~> 2.0.1' cookbook 'mysql2_chef_gem', '~> 2.0.1'
cookbook 'chef_client_updater', '~> 1.1.1' cookbook 'chef_client_updater', '~> 1.1.1'
cookbook 'timezone-ii', '~> 0.2.0' cookbook 'timezone_iii', '~> 1.0.4'
cookbook 'nodejs', '~> 3.0.0' cookbook 'nodejs', '~> 3.0.0'
cookbook 'ark', '~> 3.1.0' cookbook 'ark', '~> 3.1.0'
cookbook 'logrotate', '~> 2.2.0' cookbook 'logrotate', '~> 2.2.0'

View File

@ -276,6 +276,18 @@
"version": "12.19.0" "version": "12.19.0"
} }
}, },
{
"name": "openssl",
"dependencies": [
],
"version": "7.1.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/openssl/versions/7.1.0/download",
"version": "7.1.0"
}
},
{ {
"name": "chef_nginx", "name": "chef_nginx",
"dependencies": [ "dependencies": [
@ -908,15 +920,15 @@
} }
}, },
{ {
"name": "timezone-ii", "name": "timezone_iii",
"dependencies": [ "dependencies": [
], ],
"version": "0.2.0", "version": "1.0.4",
"source": { "source": {
"type": "Batali::Source::Site", "type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/timezone-ii/versions/0.2.0/download", "url": "https://supermarket.chef.io:443/api/v1/cookbooks/timezone_iii/versions/1.0.4/download",
"version": "0.2.0" "version": "1.0.4"
} }
}, },
{ {
@ -950,18 +962,6 @@
"version": "3.0.0" "version": "3.0.0"
} }
}, },
{
"name": "homebrew",
"dependencies": [
],
"version": "3.0.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/3.0.0/download",
"version": "3.0.0"
}
},
{ {
"name": "ark", "name": "ark",
"dependencies": [ "dependencies": [
@ -985,6 +985,18 @@
"version": "3.1.0" "version": "3.1.0"
} }
}, },
{
"name": "homebrew",
"dependencies": [
],
"version": "3.0.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/3.0.0/download",
"version": "3.0.0"
}
},
{ {
"name": "logrotate", "name": "logrotate",
"dependencies": [ "dependencies": [
@ -997,18 +1009,6 @@
"version": "2.2.0" "version": "2.2.0"
} }
}, },
{
"name": "openssl",
"dependencies": [
],
"version": "7.1.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/openssl/versions/7.1.0/download",
"version": "7.1.0"
}
},
{ {
"name": "ntp", "name": "ntp",
"dependencies": [ "dependencies": [

View File

@ -1,4 +0,0 @@
.bundle
.cache
.kitchen
bin

View File

@ -1,50 +0,0 @@
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
# Only full ruby name is supported here, for short names use:
# echo "rvm use 1.9.3" > .rvmrc
environment_id="ruby-1.9.3-p385@chefdev"
# Uncomment the following lines if you want to verify rvm version per project
# rvmrc_rvm_version="1.18.3 (stable)" # 1.10.1 seams as a safe start
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
# return 1
# }
# First we attempt to load the desired environment directly from the environment
# file. This is very fast and efficient compared to running through the entire
# CLI and selector. If you want feedback on which environment was used then
# insert the word 'use' after --create as this triggers verbose mode.
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
else
# If the environment file has not yet been created, use the RVM CLI to select.
rvm --create "$environment_id" || {
echo "Failed to create RVM environment '${environment_id}'."
return 1
}
fi
# If you use bundler, this might be useful to you:
if [[ -s Gemfile ]] && {
! builtin command -v bundle >/dev/null ||
builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
}
then
printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
gem install bundler
fi
if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
then
bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
fi
echo -n ".rvmrc: switched Ruby to "; rvm current

View File

@ -1,13 +0,0 @@
# CHANGELOG for timezone-ii
This file is used to list changes made in each version of timezone-ii.
## 0.2.0:
* Initial release of timezone-ii (as forked from timezone)
* Added support for Fedora
* Configurable paths for localtime data and tzdata tree (just in case someone
wants them...)
* For generic Linux timezone setting, a choice of copying or symlinking timezone
data to localtime (copying is the default, to avoid surprises)

View File

@ -1,6 +0,0 @@
source "http://rubygems.org/"
group :development, :test do
gem "chef"
gem "test-kitchen"
end

View File

@ -1,133 +0,0 @@
GEM
remote: http://rubygems.org/
specs:
archive-tar-minitar (0.5.2)
builder (3.1.4)
bunny (0.7.9)
chef (10.18.2)
bunny (>= 0.6.0, < 0.8.0)
erubis
highline (>= 1.6.9)
json (>= 1.4.4, <= 1.6.1)
mixlib-authentication (>= 1.3.0)
mixlib-cli (>= 1.1.0)
mixlib-config (>= 1.1.2)
mixlib-log (>= 1.3.0)
mixlib-shellout
moneta (< 0.7.0)
net-ssh (~> 2.2.2)
net-ssh-multi (~> 1.1.0)
ohai (>= 0.6.0)
rest-client (>= 1.0.4, < 1.7.0)
treetop (~> 1.4.9)
uuidtools
yajl-ruby (~> 1.1)
childprocess (0.3.7)
ffi (~> 1.0, >= 1.0.6)
coderay (1.0.8)
erubis (2.7.0)
excon (0.16.10)
ffi (1.3.1)
fog (1.9.0)
builder
excon (~> 0.14)
formatador (~> 0.2.0)
mime-types
multi_json (~> 1.0)
net-scp (~> 1.0.4)
net-ssh (>= 2.1.3)
nokogiri (~> 1.5.0)
ruby-hmac
foodcritic (1.7.0)
erubis
gherkin (~> 2.11.1)
gist (~> 3.1.0)
nokogiri (~> 1.5.4)
pry (~> 0.9.8.4)
rak (~> 1.4)
treetop (~> 1.4.10)
yajl-ruby (~> 1.1.0)
formatador (0.2.4)
gherkin (2.11.5)
json (>= 1.4.6)
gist (3.1.1)
hashr (0.0.22)
highline (1.6.15)
i18n (0.6.1)
ipaddress (0.8.0)
json (1.5.4)
librarian (0.0.26)
archive-tar-minitar (>= 0.5.2)
chef (>= 0.10)
highline
thor (~> 0.15)
log4r (1.1.10)
method_source (0.7.1)
mime-types (1.20.1)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.2.2)
mixlib-config (1.1.2)
mixlib-log (1.4.1)
mixlib-shellout (1.1.0)
moneta (0.6.0)
multi_json (1.5.0)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-ssh (2.2.2)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
net-ssh-multi (1.1)
net-ssh (>= 2.1.4)
net-ssh-gateway (>= 0.99.0)
nokogiri (1.5.6)
ohai (6.16.0)
ipaddress
mixlib-cli
mixlib-config
mixlib-log
mixlib-shellout
systemu
yajl-ruby
polyglot (0.3.3)
pry (0.9.8.4)
coderay (~> 1.0.5)
method_source (~> 0.7.1)
slop (>= 2.4.4, < 3)
rak (1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
ruby-hmac (0.4.0)
slop (2.4.4)
systemu (2.5.2)
test-kitchen (0.7.0)
fog
foodcritic (>= 1.4.0)
hashr (~> 0.0.20)
highline (>= 1.6.9)
librarian (~> 0.0.20)
mixlib-cli (~> 1.2.2)
vagrant (~> 1.0.2)
yajl-ruby (~> 1.1.0)
thor (0.17.0)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
uuidtools (2.1.3)
vagrant (1.0.6)
archive-tar-minitar (= 0.5.2)
childprocess (~> 0.3.1)
erubis (~> 2.7.0)
i18n (~> 0.6.0)
json (~> 1.5.1)
log4r (~> 1.1.9)
net-scp (~> 1.0.4)
net-ssh (~> 2.2.2)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
chef
test-kitchen

View File

@ -1,116 +0,0 @@
Timezone II
===========
The Timezone II cookbook contains recipes for installing the latest tzdata
(a.k.a. IANA or Olson) timezone database and setting the timezone on your
system. It is a fork of the [timezone cookbook by James
Harton.](http://community.opscode.com/cookbooks/timezone)
Requirements
------------
This cookbook is known to work with:
* Amazon Linux
* CentOS
* Debian
* Fedora
* Gentoo
* Ubuntu
It _should_ work with any OS that uses the IANA/Olson timezone database and
stores local timezone data in /etc/localtime (the only OS I know of that does
_not_ do this is MS Windows). However, some OSs not mentioned above have their
own system utility for setting the timezone, and this may overwrite the changes
made by this cookbook.
Attributes
----------
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['tz']</tt></td>
<td>String</td>
<td>the timezone name as defined in tzdata</td>
<td>UTC</td>
</tr>
<tr>
<td><tt>['timezone']['tzdata_dir']</tt></td>
<td>String</td>
<td>the path to the root of the tzdata files; the default value is for
most known distributions of Linux</td>
<td>/usr/share/zoneinfo</td>
</tr>
<tr>
<td><tt>['timezone']['localtime_path']</tt></td>
<td>String</td>
<td>the path to the file used by the kernel to read the local timezone's
settings; the default works for Linux and other *ix variants</td>
<td>/etc/localtime</td>
</tr>
<tr>
<td><tt>['timezone']['use_symlink']</tt></td>
<td>Boolean</td>
<td>whether to use a symlink into the tzdata tree rather than make a copy
of the appropriate timezone data file (linux-generic recipe only)</td>
<td>false</td>
</tr>
</table>
Usage
-----
Set the "tz" attribute to your desired timezone and include the "timezone-ii"
recipe in your node's run list:
```json
{
"name": "my_node",
"tz": "Africa/Timbuktu",
"run_list": [
"recipe[timezone-ii]"
]
}
```
The `timezone-ii::default` recipe will first install or upgrade the IANA/Olson
timezone database package for your OS (`timezone-data` on Gentoo, `tzdata` on
all others). Then it will call one of the following recipes according to your
node's platform:
* `timezone-ii::debian`
* `timezone-ii::fedora`
* `timezone-ii::linux-generic`
Contributing
------------
1. Fork the [repository on GitHub](https://github.com/L2G/timezone-ii)
2. Create a named feature branch (like `add_component_x`)
3. Write your change
4. If at all possible, write test-kitchen tests for your change and ensure they
all pass
5. Submit a pull request using GitHub
License and Authors
-------------------
Copyright © 2010 James Harton <james@sociable.co.nz>
Copyright © 2013 Lawrence Leonard Gilbert <larry@L2G.to>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

View File

@ -1,11 +0,0 @@
default.tz = 'UTC'
# Path to tzdata directory
default.timezone.tzdata_dir = '/usr/share/zoneinfo'
# Path to file used by kernel for local timezone's data
default.timezone.localtime_path = '/etc/localtime'
# Whether to use a symlink to tzdata (instead of copying).
# Used only in the linux-default recipe.
default.timezone.use_symlink = false

View File

@ -1,20 +0,0 @@
require 'minitest/spec'
class TimezoneIiSpec < MiniTest::Chef::Spec
describe_recipe 'timezone-ii::default' do
localtime_path = '/etc/localtime'
#original_tz_data_path = "/usr/share/zoneinfo/#{node[:tz]}"
original_tz_data_path = "/usr/share/zoneinfo/Africa/Timbuktu"
describe localtime_path do
it "has the same data as #{original_tz_data_path}" do
localtime_data = File.read(localtime_path)
original_data = File.read(original_tz_data_path)
localtime_data.must_equal original_data
end
end
end
end

View File

@ -1,36 +0,0 @@
{
"name": "timezone-ii",
"description": "Configure the system timezone on Linux systems",
"long_description": "",
"maintainer": "Lawrence Leonard Gilbert",
"maintainer_email": "larry@L2G.to",
"license": "Apache 2.0",
"platforms": {
"amazon": ">= 0.0.0",
"centos": ">= 0.0.0",
"debian": ">= 0.0.0",
"fedora": ">= 0.0.0",
"gentoo": ">= 0.0.0",
"ubuntu": ">= 0.0.0"
},
"dependencies": {
},
"recommendations": {
},
"suggestions": {
},
"conflicting": {
},
"providing": {
},
"replacing": {
"timezone": ">= 0.0.0"
},
"attributes": {
},
"groupings": {
},
"recipes": {
},
"version": "0.2.0"
}

View File

@ -1,17 +0,0 @@
name "timezone-ii"
maintainer "Lawrence Leonard Gilbert"
maintainer_email "larry@L2G.to"
license "Apache 2.0"
description "Configure the system timezone on Linux systems"
version "0.2.0"
replaces "timezone"
# These are platform versions where this cookbook has been tested at some point
# in time
supports "amazon"
supports "centos"
supports "debian"
supports "fedora"
supports "gentoo"
supports "ubuntu"

View File

@ -1,28 +0,0 @@
#
# Cookbook Name:: timezone-ii
# Recipe:: debian
#
# Copyright 2010, James Harton <james@sociable.co.nz>
# Copyright 2013, Lawrence Leonard Gilbert <larry@L2G.to>
#
# Apache 2.0 License.
#
# Set timezone for Debian family: Put the timezone string in plain text in
# /etc/timezone and then re-run the tzdata configuration to pick it up.
template "/etc/timezone" do
source "timezone.conf.erb"
owner 'root'
group 'root'
mode 0644
notifies :run, 'bash[dpkg-reconfigure tzdata]'
end
bash 'dpkg-reconfigure tzdata' do
user 'root'
code "/usr/sbin/dpkg-reconfigure -f noninteractive tzdata"
action :nothing
end
# vim:ts=2:sw=2:

View File

@ -1,47 +0,0 @@
#
# Cookbook Name:: timezone-ii
# Recipe:: default
#
# Copyright 2010, James Harton <james@sociable.co.nz>
# Copyright 2013, Lawrence Leonard Gilbert <larry@L2G.to>
#
# Apache 2.0 License.
#
# Make sure the tzdata database is installed. (Arthur David Olson, the computer
# timekeeping field is forever in your debt.)
package value_for_platform_family(
'gentoo' => 'timezone-data',
'default' => 'tzdata'
)
case node.platform_family
when 'debian', 'fedora'
include_recipe "timezone-ii::#{node.platform_family}"
else
if node.os == "linux"
# Load the generic Linux recipe if there's no better known way to change the
# timezone. Log a warning (unless this is known to be the best way on a
# particular platform).
message = "Linux platform '#{node.platform}' is unknown to this recipe; " +
"using generic Linux method"
log message do
level :warn
not_if { %w( centos gentoo rhel ).include? node.platform_family }
end
include_recipe 'timezone-ii::linux-generic'
else
message = "Don't know how to configure timezone for " +
"'#{node.platform_family}'!"
log message do
level :error
end
end # if/else node.os
end # case node.platform_family
# vim:ts=2:sw=2:

View File

@ -1,17 +0,0 @@
#
# Cookbook Name:: timezone-ii
# Recipe:: fedora
#
# Copyright 2013, Lawrence Leonard Gilbert <larry@L2G.to>
#
# Apache 2.0 License.
#
# Set timezone for Fedora by using its timedatectl utility.
bash 'timedatectl set-timezone' do
user 'root'
code "/usr/bin/timedatectl --no-ask-password set-timezone #{node.tz}"
end
# vim:ts=2:sw=2:

View File

@ -1,46 +0,0 @@
#
# Cookbook Name:: timezone-ii
# Recipe:: linux-generic
#
# Copyright 2013, Lawrence Leonard Gilbert <larry@L2G.to>
#
# Apache 2.0 License.
#
# Generic timezone-changing method for Linux that should work for any distro
# without a platform-specific method.
timezone_data_file = File.join(node.timezone.tzdata_dir, node.tz)
localtime_path = node.timezone.localtime_path
ruby_block "confirm timezone" do
block {
unless File.exist?(timezone_data_file)
raise "Can't find #{timezone_data_file}!"
end
}
end
if node.timezone.use_symlink
link localtime_path do
to timezone_data_file
owner 'root'
group 'root'
mode 0644
end
else
file localtime_path do
content File.open(timezone_data_file, 'rb').read
owner 'root'
group 'root'
mode 0644
not_if {
File.symlink?(localtime_path) and
Chef::Log.error "You must remove symbolic link at #{localtime_path}" +
" or set attribute ['timezone']['use_symlink']=true"
}
end
end # if/else node.timezone.use_symlink
# vim:ts=2:sw=2:

View File

@ -1 +0,0 @@
<%= node[:tz] %>

View File

@ -0,0 +1,32 @@
---
engines:
duplication:
enabled: true
config:
languages:
- ruby
- javascript
- python
- php
fixme:
enabled: true
rubocop:
enabled: true
foodcritic:
enabled: true
markdownlint:
enabled: true
checks:
MD013:
enabled: false
ratings:
paths:
- "**.inc"
- "**.js"
- "**.jsx"
- "**.module"
- "**.php"
- "**.py"
- "**.rb"
- "**.md"
exclude_paths: []

21
cookbooks/timezone_iii/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
.vagrant
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
# Bundler
Gemfile.lock
bin/*
.bundle/*
# test kitchen
.kitchen/
.kitchen.local.yml
# Chef
Berksfile.lock
.zero-knife.rb
Policyfile.lock.json

View File

@ -0,0 +1,26 @@
---
driver:
name: vagrant
provisioner:
name: chef_zero
# You may wish to disable always updating cookbooks in CI or other testing environments.
# For example:
# always_update_cookbooks: <%= !ENV['CI'] %>
always_update_cookbooks: true
verifier:
name: inspec
platforms:
- name: ubuntu-16.04
- name: centos-7.3
suites:
- name: default
run_list:
- recipe[timezone_iii::default]
verifier:
inspec_tests:
- test/smoke/default
attributes:

View File

@ -0,0 +1,18 @@
AllCops:
Exclude:
- vendor/**/*
- Guardfile
TargetRubyVersion: 2.4
ClassLength:
Enabled: false
CyclomaticComplexity:
Enabled: false
LineLength:
Enabled: false
MethodLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
PerceivedComplexity:
Enabled: false

View File

@ -0,0 +1,3 @@
source 'https://supermarket.chef.io'
metadata

View File

@ -0,0 +1,21 @@
# CHANGELOG for timezone_ii
## 1.0.4 (6/6/2017)
- [badsector3] - Temp fix for recent Ubuntu releases with local time file overriding timezone file
## 1.0.3 (4/20/2017)
- [Corey Hemminger] - fixed linux include_recipe line that was being skipped
## 1.0.2 (4/19/2017)
- [Corey Hemminger] - changed hash rockets to new hash style
## 1.0.1 (4/18/2017)
- [Corey Hemminger] - fixed windows idempotency
## 1.0.0 (4/18/2017)
- [Corey Hemminger] - Initial commit

View File

@ -0,0 +1 @@
Please refer to <https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD>

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,137 @@
[![Chef cookbook](https://img.shields.io/cookbook/v/timezone_iii.svg)]()
[![Code Climate](https://codeclimate.com/github/Stromweld/timezone_iii/badges/gpa.svg)](https://codeclimate.com/github/Stromweld/timezone_iii)
[![Issue Count](https://codeclimate.com/github/Stromweld/timezone_iii/badges/issue_count.svg)](https://codeclimate.com/github/Stromweld/timezone_iii)
# timezone_iii
The Timezone III cookbook contains recipes for installing the latest tzdata (a.k.a. IANA or Olson) timezone database and setting the timezone on your system. It is a fork of the [timezone-ii cookbook by Lawrence Gilbert.](https://supermarket.chef.io/cookbooks/timezone-ii).
## Requirements
This cookbook is known to work with:
* Amazon Linux
* CentOS and RHEL
* Debian
* Fedora
* Gentoo
* PLD Linux
* Ubuntu
* Windows
It _should_ work with any OS that uses the IANA/Olson timezone database and stores local timezone data in /etc/localtime (the only OS I know of that does _not_ do this is MS Windows). However, some OSs not mentioned above have their own system utility for setting the timezone, and this may overwrite the changes made by this cookbook.
## Attributes
| Attribute | Default | Comment |
| ------------- | ------------- | ------------- |
| ['timezone_iii']['timezone'] | 'value_for_platform_family(debian: 'Etc/UTC', default: 'UTC')' | String, timezone to set OS to |
| ['timezone_iii']['tzdata_dir'] | '/usr/share/zoneinfo' | String, the path to the root of the tzdata files; the default value is for most known distributions of Linux |
| ['timezone_iii']['localtime_path'] | '/etc/localtime' | String, the path to the file used by the kernel to read the local timezone's settings; the default works for Linux and other *ix variants |
| ['timezone_iii']['use_symlink'] | false | Boolean, whether to use a symlink into the tzdata tree rather than make a copy of the appropriate timezone data file (amazon and linux_generic recipes only) |
## Usage
Set the ['timezone_iii']['timezone'] attribute to your desired timezone and include the "timezone_iii" recipe in your node's run list:
{
"name": "my_node",
"timezone_iii" {
"timezone": "Africa/Timbuktu"
},
"run_list": [
"recipe[timezone_iii]"
]
}
### timezone_iii::default
The default recipe will first install or upgrade the IANA/Olson timezone database package for your OS (`timezone-data` on Gentoo, `tzdata` on all other linux platforms). Then it will call one of the recipes below according to your node's platform.
### timezone_iii::amazon
This changes the timezone on Amazon Linux by:
1. including the "timezone_iii::linux_generic" recipe then;
2. including the "timezone_iii::rhel" recipe.
Refer to the sections for those recipes for details.
### timezone_iii::debian
This changes the timezone on Debian-family platforms by:
1. writing the value of `['timezone_iii']['timezone']` to `/etc/timezone` then;
2. calling `dpkg-reconfigure -f noninteractive tzdata`;
3. if `dpkg-reconfigure` amends the timezone value (e.g. by changing "UTC" to "Etc/UTC" or "EET" to "Europe/Helsinki"), it logs a warning.
Only the `['timezone_iii']['timezone']` attribute is used; all others are ignored.
### timezone_iii::linux_generic
This changes the time on all OSs without a more specific recipe. It assumes that the kernel gets data on the local timezone from `/etc/localtime`. (This is true for FreeBSD as well as Linux, so "linux_generic" is a bit of a misnomer.)
What this recipe does:
1. verifies that the value of `['timezone_iii']['timezone']` corresponds with a timezone data file under the directory specified in `timezone.tzdata_dir` (default:`/usr/share/zoneinfo`), then;
2. creates a copy of or symbolic link to that data file in the path specified in `timezone.localtime_path` (default: `/etc/localtime`).
The truthiness of `timezone.use_symlink` (default: `false`) determines whether a symlink or a copy is made.
### timezone_iii::pld
This changes the timezone on PLD Linux. It writes the appropriate timezone configuration file, making use of the `['timezone_iii']['timezone']` and `['timezone_iii']['tzdata_dir']` attributes. Other attributes are ignored.
### timezone_iii::rhel
This changes the timezone on RedHat Enterprise Linux (RHEL) and RHEL-family platforms such as CentOS. It is intended only for versions prior to 7.0, but should the recipe be called on a system with version 7.0 or newer, it will automatically include the "timezone_iii::rhel7" recipe and do nothing else.
This recipe updates the `/etc/sysconfig/clock` file with the value of the `['timezone_iii']['timezone']` attribute, then calls `tzdata-update` (if available) to change the timezone. All node attributes other than `['timezone_iii']['timezone']` are ignored.
### timezone_iii::rhel7
This changes the timezone on EL 7 platforms by calling `timedatectl set-timezone` with the value of `['timezone_iii']['timezone']`.
Only the `['timezone_iii']['timezone']` attribute is used; all others are ignored.
### timezone_iii::windows
This changes the timezone on windows platforms by calling `tzutil.exe` with the value of `['timezone_iii']['timezone']`. To get a list of timezones to use with windows you can run the command `tzutil.exe /l | more` on the command line and use the standard name under the offset info.
Only the `['timezone_iii']['timezone']` attribute is used; all others are ignored.
## Contributing
1. Fork the [repository on GitHub](https://github.com/Stromweld/timezone_iii);
2. Write your change;
3. If at all possible, write tests for your change and ensure they all pass;
4. Submit a pull request using GitHub.
## Acknowledgements
Thanks to:
* Larry Gilbert, for launching the timezone-ii cookbook
* James Harton, for launching the timezone cookbook
* Elan Ruusamäe, for PLD support
* Mike Conigliaro, for bringing testing up to date
* "fraD00r4", for RHEL/CentOS support
## License and Authors
* Copyright © 2010 James Harton <james@sociable.co.nz>
* Copyright © 2013-2015 Lawrence Leonard Gilbert <larry@L2G.to>
* Copyright © 2013 Elan Ruusamäe <glen@delfi.ee>
* Copyright © 2013 fraD00r4 <frad00r4@gmail.com>
* Copyright © 2017 Corey Hemminger <hemminger@hotmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

View File

@ -0,0 +1 @@
Please refer to <https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/TESTING.MD>

View File

@ -0,0 +1,33 @@
#
# Cookbook:: timezone_iii
# Attribute:: default
#
# Copyright:: 2017, Corey Hemminger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Use universal time if no other timezone is specified
default['timezone_iii']['timezone'] = value_for_platform_family(
debian: 'Etc/UTC',
default: 'UTC'
)
# Path to tzdata directory
default['timezone_iii']['tzdata_dir'] = '/usr/share/zoneinfo'
# Path to file used by kernel for local timezone's data
default['timezone_iii']['localtime_path'] = '/etc/localtime'
# Whether to use a symlink to tzdata (instead of copying).
# Used only in the linux-default recipe.
default['timezone_iii']['use_symlink'] = false

View File

@ -0,0 +1,107 @@
# Put files/directories that should be ignored in this file when uploading
# to a chef-server or supermarket.
# Lines that start with '# ' are comments.
# OS generated files #
######################
.DS_Store
Icon?
nohup.out
ehthumbs.db
Thumbs.db
# SASS #
########
.sass-cache
# EDITORS #
###########
\#*
.#*
*~
*.sw[a-z]
*.bak
REVISION
TAGS*
tmtags
*_flymake.*
*_flymake
*.tmproj
.project
.settings
mkmf.log
## COMPILED ##
##############
a.out
*.o
*.pyc
*.so
*.com
*.class
*.dll
*.exe
*/rdoc/
# Testing #
###########
.watchr
.rspec
spec/*
spec/fixtures/*
test/*
features/*
examples/*
Guardfile
Procfile
.kitchen*
.rubocop.yml
spec/*
Rakefile
.travis.yml
.foodcritic
.codeclimate.yml
# SCM #
#######
.git
*/.git
.gitignore
.gitmodules
.gitconfig
.gitattributes
.svn
*/.bzr/*
*/.hg/*
*/.svn/*
# Berkshelf #
#############
Berksfile
Berksfile.lock
cookbooks/*
tmp
# Policyfile #
##############
Policyfile.rb
Policyfile.lock.json
# Cookbooks #
#############
CONTRIBUTING*
CHANGELOG*
TESTING*
MAINTAINERS.toml
# Strainer #
############
Colanderfile
Strainerfile
.colander
.strainer
# Vagrant #
###########
.vagrant
Vagrantfile

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,27 @@
name 'timezone_iii'
maintainer 'Corey Hemminger'
maintainer_email 'hemminger@hotmail.com'
license 'Apache-2.0'
description 'Configures the timezone for node'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.0.4'
chef_version '>= 12.1' if respond_to?(:chef_version)
# The `issues_url` points to the location where issues for this cookbook are
# tracked. A `View Issues` link will be displayed on this cookbook's page when
# uploaded to a Supermarket.
#
issues_url 'https://github.com/Stromweld/timezone_iii/issues'
# The `source_url` points to the development reposiory for this cookbook. A
# `View Source` link will be displayed on this cookbook's page when uploaded to
# a Supermarket.
#
source_url 'https://github.com/Stromweld/timezone_iii'
%w(amazon centos debian fedora gentoo ubuntu pld redhat windows).each do |os|
supports os
end
replaces 'timezone'
replaces 'timezone-ii'

View File

@ -0,0 +1,27 @@
#
# Cookbook:: timezone_iii
# Recipe:: amazon
#
# Copyright:: 2017, Corey Hemminger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Amazon recommends editing /etc/sysconfig/clock as in the rhel recipe, but then
# creating a link for /etc/localtime. It doesn't have a tzdata-update command
# like the other flavors of RHEL.
#
# Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html
# (as of 2014-12-18)
include_recipe 'timezone_iii::linux_generic'
include_recipe 'timezone_iii::rhel'

View File

@ -0,0 +1,61 @@
#
# Cookbook:: timezone_iii
# Recipe:: debian
#
# Copyright:: 2017, Corey Hemminger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Set timezone for Debian family: Put the timezone string in plain text in
# /etc/timezone and then re-run the tzdata configuration to pick it up.
TIMEZONE_FILE = '/etc/timezone'.freeze
if File.file?('/etc/localtime') then
bash 'check-localtime' do
user 'root'
cwd '/tmp'
code <<-EOH
ls -la /etc/localtime >> /tmp/check.txt
if grep node['timezone_iii']['timezone'] /tmp/check.txt ; then
echo "Nothing to do!!!"
else
rm /etc/localtime
fi
rm /tmp/check.txt
EOH
end
end
template TIMEZONE_FILE do
source 'timezone.conf.erb'
owner 'root'
group 'root'
mode '0644'
notifies :run, 'execute[dpkg-reconfigure-tzdata]'
end
execute 'dpkg-reconfigure-tzdata' do
command '/usr/sbin/dpkg-reconfigure -f noninteractive tzdata'
action :nothing
end
# Certain values get normalized by dpkg-reconfigure, causing this recipe to try
# to rewrite the file over and over. This raises a red flag in such a case.
log 'if-unexpected-timezone-change' do
message "dpkg-reconfigure is amending the value #{node['timezone_iii']['timezone'].inspect} in #{TIMEZONE_FILE}"
level :warn
not_if { ::File.read(TIMEZONE_FILE).chomp == node['timezone_iii']['timezone'] }
action :nothing
subscribes :write, 'execute[dpkg-reconfigure-tzdata]', :immediately
end

View File

@ -0,0 +1,46 @@
#
# Cookbook:: timezone_iii
# Recipe:: default
#
# Copyright:: 2017, Corey Hemminger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
case node['os']
when 'linux'
package value_for_platform_family(
gentoo: 'timezone-data',
default: 'tzdata'
)
case node['platform_family']
when 'rhel', 'fedora'
include_recipe node['platform_version'].split('.')[0].to_i >= 7 ? 'timezone_iii::rhel7' : 'timezone_iii::rhel'
when 'debian', 'pld', 'amazon'
include_recipe "timezone_iii::#{node['platform_family']}"
else
# Load the generic Linux recipe if there's no better known way to change the
# timezone. Log a warning (unless this is known to be the best way on a
# particular platform).
message = "Linux platform '#{node['platform']}' is unknown to this recipe; using generic Linux method"
log message do
level :warn
not_if { %w(centos gentoo rhel amazon).include? node['platform_family'] }
only_if { node['os'] == 'linux' }
end
include_recipe 'timezone_iii::linux_generic'
end
when 'windows'
include_recipe 'timezone_iii::windows'
else
raise 'OS Unsuported'
end

View File

@ -0,0 +1,49 @@
#
# Cookbook:: timezone_iii
# Recipe:: linux_generic
#
# Copyright:: 2017, Corey Hemminger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Generic timezone-changing method for Linux that should work for any distro
# without a platform-specific method.
timezone_data_file = File.join(node['timezone_iii']['tzdata_dir'], node['timezone_iii']['timezone'])
localtime_path = node['timezone_iii']['localtime_path']
ruby_block 'confirm timezone' do
block do
unless File.exist?(timezone_data_file)
raise "Can't find #{timezone_data_file}!"
end
end
end
if node['timezone_iii']['use_symlink']
link localtime_path do
to timezone_data_file
owner 'root'
group 'root'
mode '0644'
end
else
file localtime_path do
content File.open(timezone_data_file, 'rb').read
owner 'root'
group 'root'
mode '0644'
not_if { File.symlink?(localtime_path) && Chef::Log.error("You must remove symbolic link at #{localtime_path} or set attribute ['timezone']['use_symlink'] = true") }
end
end

View File

@ -0,0 +1,32 @@
#
# Cookbook:: timezone_iii
# Recipe:: pld
#
# Copyright:: 2017, Corey Hemminger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Set timezone for PLD family: Put the timezone string in plain text in
# /etc/sysconfig/timezone and then re-run the timezone service to pick it up.
template '/etc/sysconfig/timezone' do
source 'pld/timezone.conf.erb'
owner 'root'
group 'root'
mode '0644'
notifies :reload, 'service[timezone]'
end
service 'timezone' do
action :nothing
end

View File

@ -0,0 +1,38 @@
#
# Cookbook:: timezone_iii
# Recipe:: rhel
#
# Copyright:: 2017, Corey Hemminger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This recipe sets the timezone on EL 6 and older (RedHat Enterprise Linux,
# CentOS, etc.)
#
# If it is being run on EL 7 or newer, the recipe will be skipped and
# the "rhel7" recipe will be included instead.
template '/etc/sysconfig/clock' do
source 'rhel/clock.erb'
owner 'root'
group 'root'
mode '0644'
notifies :run, 'execute[tzdata-update]'
end
execute 'tzdata-update' do
command '/usr/sbin/tzdata-update'
action :nothing
# Amazon Linux doesn't have this command!
only_if { ::File.executable?('/usr/sbin/tzdata-update') }
end

View File

@ -0,0 +1,35 @@
#
# Cookbook:: timezone_iii
# Recipe:: amazon
#
# Copyright:: 2017, Corey Hemminger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This sets the timezone on EL 7 distributions (e.g. RedHat and CentOS)
execute "timedatectl --no-ask-password set-timezone #{node['timezone_iii']['timezone']}"
template '/etc/sysconfig/clock' do
source 'rhel/clock.erb'
owner 'root'
group 'root'
mode '0644'
notifies :run, 'execute[tzdata-update]'
end
execute 'tzdata-update' do
command '/usr/sbin/tzdata-update'
action :nothing
# Amazon Linux doesn't have this command!
only_if { ::File.executable?('/usr/sbin/tzdata-update') }
end

View File

@ -0,0 +1,24 @@
#
# Cookbook:: timezone_iii
# Recipe:: amazon
#
# Copyright:: 2017, Corey Hemminger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
powershell_script 'set windows timezone' do
code <<-EOH
tzutil.exe /s "#{node['timezone_iii']['timezone']}"
EOH
not_if { shell_out('tzutil.exe /g').stdout.include?(node['timezone_iii']['timezone']) }
end

View File

@ -0,0 +1,10 @@
# Time zone information.
# Directory containing zone information files.
ZONE_INFO_DIR="<%= node['timezone_iii']['tzdata_dir'] %>"
# Scheme you would like to use in your system.
ZONE_INFO_SCHEME="posix"
# Name of the time zone for your system.
TIMEZONE="<%= node['timezone_iii']['timezone'] %>"

View File

@ -0,0 +1 @@
ZONE="<%= node['timezone_iii']['timezone'] %>"

View File

@ -0,0 +1 @@
<%= node['timezone_iii']['timezone'] %>

View File

@ -13,5 +13,5 @@ depends 'kosmos-postfix'
depends 'hostname' depends 'hostname'
depends 'firewall' depends 'firewall'
depends 'chef_client_updater' depends 'chef_client_updater'
depends 'timezone-ii' depends 'timezone_iii'
depends 'ntp' depends 'ntp'

View File

@ -8,7 +8,7 @@
# #
include_recipe 'apt' include_recipe 'apt'
include_recipe 'timezone-ii' include_recipe 'timezone_iii'
include_recipe 'ntp' include_recipe 'ntp'
# Update chef to the chosen version # Update chef to the chosen version