[icinga-checkins] icinga.org: chef-icinga2/master: Cleaned up setting PHP.ini' s date_timezone attribute, based on vkhatri's edit recommendations.

git at icinga.org git at icinga.org
Sun Nov 13 07:53:39 CET 2016


Module: chef-icinga2
Branch: master
Commit: 8e2b668082e53123a9537c104711b1311c1b0fef
URL:    https://git.icinga.org/?p=chef-icinga2.git;a=commit;h=8e2b668082e53123a9537c104711b1311c1b0fef

Author: Cody Sandwith <csandwith at topiatechnology.com>
Date:   Mon Oct  3 08:40:19 2016 -0700

Cleaned up setting PHP.ini's date_timezone attribute, based on vkhatri's edit recommendations.

---

 recipes/server_web2.rb |   33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/recipes/server_web2.rb b/recipes/server_web2.rb
index d9b23ed..218961c 100644
--- a/recipes/server_web2.rb
+++ b/recipes/server_web2.rb
@@ -49,26 +49,21 @@ file ::File.join(node['icinga2']['web2']['conf_dir'], 'setup.token') do
 end
 
 # set php time zone
-php_ini = node['platform_family'] == 'rhel' ? '/etc/php.ini' : '/etc/php5/apache2/php.ini'
-execute 'Setup Apache2 PHP5' do
-  command "sudo sed -i -e 's/;date.timezone =/date.timezone = UTC/g' /etc/php5/apache2/php.ini"
-  action :run
-  only_if {File.exists?('/etc/php5/apache2/php.ini')}
-  notifies :reload, 'service[apache2]', :immediately
-end
-
-execute 'Setup Apache2 PHP5.5' do
-  command "sudo sed -i -e 's/;date.timezone =/date.timezone = UTC/g' /etc/php/5.5/apache2/php.ini"
-  action :run
-  only_if {File.exists?('/etc/php/5.5/apache2/php.ini')}
-  notifies :reload, 'service[apache2]', :immediately
+if node['platform_family'] == 'rhel'
+  php_ini = '/etc/php.ini'
+else
+  if node['lsb']['codename'] == 'xenial'
+    php_ini = '/etc/php/5.5/apache2/php.ini'
+  else
+    php_ini = '/etc/php5/apache2/php.ini'
+  end
 end
-
-execute 'Setup Apache2 PHP' do
-  command "sudo sed -i -e 's/;date.timezone =/date.timezone = UTC/g' /etc/php/5.5/apache2/php.ini"
-  action :run
-  only_if {File.exists?('/etc/php.ini')}
-  notifies :reload, 'service[apache2]', :immediately
+ruby_block 'set php timezone' do
+  block do
+    fe = Chef::Util::FileEdit.new(php_ini)
+    fe.search_file_replace_line(/^;date.timezone =.*/, "date.timezone = #{node['time']['timezone']}")
+    fe.write_file
+  end
 end
 
 # install icingaweb2



More information about the icinga-checkins mailing list