Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix agent registration #171

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ rerun.txt
.kitchen
.vagrant
vendor
/.idea/
*.iml
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
default['zabbix']['gid'] = nil
default['zabbix']['home'] = '/opt/zabbix'
default['zabbix']['shell'] = '/bin/bash'
default['zabbix']['zabbixapi_version'] = '~> 2.4'
6 changes: 5 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
2 changes: 1 addition & 1 deletion recipes/_providers_common.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
chef_gem 'zabbixapi' do
action :install
version '~> 0.6.3'
version node['zabbix']['zabbixapi_version']
end
2 changes: 1 addition & 1 deletion recipes/agent_registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
72 changes: 38 additions & 34 deletions recipes/database.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
include_recipe 'zabbix::common'

::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)

include_recipe 'database::mysql'
include_recipe 'mysql::client'
::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)

# Generates passwords if they aren't already set
# This is INSECURE because node.normal persists the passwords to the chef
Expand All @@ -17,37 +15,43 @@
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'
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
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
Expand Down