From 474f9123e297beef3a52af18691b320ae11e2e88 Mon Sep 17 00:00:00 2001 From: Nikolay Murga Date: Tue, 24 Jun 2014 22:03:24 +0300 Subject: [PATCH 1/6] Fix server search --- recipes/agent_registration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/agent_registration.rb b/recipes/agent_registration.rb index edc99f7..b652a4b 100644 --- a/recipes/agent_registration.rb +++ b/recipes/agent_registration.rb @@ -6,7 +6,7 @@ # if !Chef::Config[:solo] - zabbix_server = search(:node, 'recipe:zabbix\\:\\:server').first + zabbix_server = search(:node, 'recipes:zabbix\\:\\:server').first else if node['zabbix']['web']['fqdn'] zabbix_server = node From 5f331a617a245dc5d1462e99bf168ef5f4e762c3 Mon Sep 17 00:00:00 2001 From: Nikolay Murga Date: Thu, 16 Apr 2015 18:12:05 +0300 Subject: [PATCH 2/6] Update _providers_common.rb --- recipes/_providers_common.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/_providers_common.rb b/recipes/_providers_common.rb index 9c05f07..247fd4d 100644 --- a/recipes/_providers_common.rb +++ b/recipes/_providers_common.rb @@ -1,4 +1,4 @@ chef_gem 'zabbixapi' do action :install - version '~> 0.6.3' + version node['zabbix']['zabbixapi_version'] end From f1e316d984c3bbf29e2b078e149b3faffe9ebae6 Mon Sep 17 00:00:00 2001 From: Nikolay Murga Date: Thu, 16 Apr 2015 18:13:31 +0300 Subject: [PATCH 3/6] Update default.rb --- attributes/default.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/attributes/default.rb b/attributes/default.rb index f235dd6..2c2ee5f 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -28,3 +28,4 @@ default['zabbix']['gid'] = nil default['zabbix']['home'] = '/opt/zabbix' default['zabbix']['shell'] = '/bin/bash' +default['zabbix']['zabbixapi_version'] = '~> 2.4' From e1f22379f08410a55e5f80223709c950a969d4cb Mon Sep 17 00:00:00 2001 From: Nikolay Murga Date: Tue, 26 May 2015 17:41:03 +0300 Subject: [PATCH 4/6] Ignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c8a9691..966c055 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ rerun.txt .kitchen .vagrant vendor +/.idea/ +*.iml From 9cd22568764d6f12e47abac5f20f149eed89acfb Mon Sep 17 00:00:00 2001 From: Nikolay Murga Date: Tue, 26 May 2015 17:56:55 +0300 Subject: [PATCH 5/6] Remove hardcoded database installation --- metadata.rb | 6 +++- recipes/database.rb | 68 ++++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/metadata.rb b/metadata.rb index 6936993..b7d4583 100644 --- a/metadata.rb +++ b/metadata.rb @@ -13,7 +13,6 @@ supports 'windows' depends 'apache2', '>= 1.0.8' depends 'database', '>= 1.3.0' -depends 'mysql', '>= 1.3.0' depends 'ufw', '>= 0.6.1' depends 'yum' depends 'postgresql' @@ -25,3 +24,8 @@ depends 'oracle-instantclient' depends 'php' depends 'yum-epel' + +suggests 'mysql' +suggests 'postgresql' +suggests 'mysql_chef_gem', '~> 1.0' +suggests 'mysql2_chef_gem', '~> 2.0' diff --git a/recipes/database.rb b/recipes/database.rb index c11f59c..ce79711 100644 --- a/recipes/database.rb +++ b/recipes/database.rb @@ -1,10 +1,9 @@ include_recipe 'zabbix::common' +include_recipe 'mysql_chef_gem' +include_recipe 'mysql2_chef_gem' ::Chef::Recipe.send(:include, Opscode::OpenSSL::Password) -include_recipe 'database::mysql' -include_recipe 'mysql::client' - # Generates passwords if they aren't already set # This is INSECURE because node.normal persists the passwords to the chef # server, making them visible to anybody with access @@ -17,37 +16,38 @@ end case node['zabbix']['database']['install_method'] -when 'rds_mysql' - root_username = node['zabbix']['database']['rds_master_username'] - root_password = node['zabbix']['database']['rds_master_password'] - allowed_user_hosts = '%' - provider = Chef::Provider::ZabbixDatabaseMySql -when 'mysql' - unless node['mysql']['server_root_password'] - node.normal['mysql']['server_root_password'] = secure_password - end - root_username = 'root' - root_password = node['mysql']['server_root_password'] - allowed_user_hosts = node['zabbix']['database']['allowed_user_hosts'] - provider = Chef::Provider::ZabbixDatabaseMySql -when 'postgres' - unless node['postgresql']['password']['postgres'] - node.normal['postgresql']['password']['postgres'] = secure_password - end - root_username = 'postgres' - root_password = node['postgresql']['password']['postgres'] - provider = Chef::Provider::ZabbixDatabasePostgres -when 'oracle' - # No oracle database installation or configuration currently done - # This recipe expects a fully configured Oracle DB with a Zabbix - # user + schema. The instant client is just for compiling php-oci8 - # and Zabbix itself - include_recipe 'oracle-instantclient' - include_recipe 'oracle-instantclient::sdk' - # Not used yet but needs to be set - root_username = 'sysdba' - root_password = 'not_applicable' - provider = Chef::Provider::ZabbixDatabaseOracle + when 'rds_mysql' + root_username = node['zabbix']['database']['rds_master_username'] + root_password = node['zabbix']['database']['rds_master_password'] + allowed_user_hosts = '%' + provider = Chef::Provider::ZabbixDatabaseMySql + when 'mysql' + unless node['mysql']['server_root_password'] + node.normal['mysql']['server_root_password'] = secure_password + end + root_username = 'root' + root_password = node['mysql']['server_root_password'] + allowed_user_hosts = node['zabbix']['database']['allowed_user_hosts'] + provider = Chef::Provider::ZabbixDatabaseMySql + when 'postgres' + include_recipe "database::postgresql" + unless node['postgresql']['password']['postgres'] + node.normal['postgresql']['password']['postgres'] = secure_password + end + root_username = 'postgres' + root_password = node['postgresql']['password']['postgres'] + provider = Chef::Provider::ZabbixDatabasePostgres + when 'oracle' + # No oracle database installation or configuration currently done + # This recipe expects a fully configured Oracle DB with a Zabbix + # user + schema. The instant client is just for compiling php-oci8 + # and Zabbix itself + include_recipe 'oracle-instantclient' + include_recipe 'oracle-instantclient::sdk' + # Not used yet but needs to be set + root_username = 'sysdba' + root_password = 'not_applicable' + provider = Chef::Provider::ZabbixDatabaseOracle end zabbix_database node['zabbix']['database']['dbname'] do From 86351050a60f5a59f23bdb2b018b9528d34eb25d Mon Sep 17 00:00:00 2001 From: Nikolay Murga Date: Tue, 26 May 2015 18:51:01 +0300 Subject: [PATCH 6/6] Install mysql gems --- recipes/database.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/recipes/database.rb b/recipes/database.rb index ce79711..f8ef0d4 100644 --- a/recipes/database.rb +++ b/recipes/database.rb @@ -1,6 +1,5 @@ include_recipe 'zabbix::common' -include_recipe 'mysql_chef_gem' -include_recipe 'mysql2_chef_gem' + ::Chef::Recipe.send(:include, Opscode::OpenSSL::Password) @@ -17,11 +16,16 @@ case node['zabbix']['database']['install_method'] when 'rds_mysql' + mysql_chef_gem 'default' + mysql2_chef_gem 'default' root_username = node['zabbix']['database']['rds_master_username'] root_password = node['zabbix']['database']['rds_master_password'] allowed_user_hosts = '%' provider = Chef::Provider::ZabbixDatabaseMySql when 'mysql' + mysql_chef_gem 'default' + mysql2_chef_gem 'default' + unless node['mysql']['server_root_password'] node.normal['mysql']['server_root_password'] = secure_password end