default.rb
4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#
# Author:: Earth U (<sysadmin @ chromedia.com>)
# Cookbook Name:: cfe-mariadb
# Attributes:: default
#
# Copyright 2016, Chromedia Far East, Inc.
#
# 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.
#
## The 'db_map' should contain this format:
# default['cfe-mariadb']['db_map'] = {
# 'example_db_name' => {
# :db_user => 'example_db_username',
# :db_pass => 'example_db_password',
# :bak_filename => 'example_db_name.sql',
# :bak_maxcopies => 30
## Optional:
# :char_set => 'utf8',
# :collate => 'utf8_general_ci',
# :bak_encrypted => false,
## Whether to include in backup script, and reload DB data during Chef run:
# :backup => true,
# :reload => true
# }
# }
default['cfe-mariadb']['db_map'] = {}
# Make sure to set replication on only when necessary
default['cfe-mariadb']['replication'] = false
default['cfe-mariadb']['s3_region'] = 'us-east-1'
default['cfe-mariadb']['s3_bucket'] = 'example-bucket'
if node['platform'] == 'ubuntu' and node['platform_version'].to_f == 14.04
default['cfe-mariadb']['backup']['aws_bin'] = '/usr/local/bin/aws'
default['cfe-mariadb']['backup']['mysqldump_bin'] = '/usr/bin/mysqldump'
else
# Haven't tested on other platforms yet, so same as above for now.
default['cfe-mariadb']['backup']['aws_bin'] = '/usr/local/bin/aws'
default['cfe-mariadb']['backup']['mysqldump_bin'] = '/usr/bin/mysqldump'
end
# Path to directory where the backup script should be placed.
# Uncomment to set custom locations.
#default['cfe-mariadb']['backup']['script_dir'] = ::File.join(
# node['mariadb']['configuration']['path'], 'scripts'
#)
default['cfe-mariadb']['backup']['log_dir'] = '/var/log/backup_db_to_s3'
default['cfe-mariadb']['backup']['cron']['sched'] = '0 0 * * *'
default['cfe-mariadb']['backup']['cron']['mailto'] = "''" # Empty single quotes
# Basic options for logrotate
default['cfe-mariadb']['backup']['logrotate']['conf_dir'] = '/etc/logrotate.d'
default['cfe-mariadb']['backup']['logrotate']['options'] = %w{
weekly
rotate\ 12
missingok
compress
notifempty
}
default['cfe-mariadb']['reload']['file_stamp'] =
"#{node['mariadb']['configuration']['path']}/reloaded.stamp"
# Optional attributes for recipe 'reload_from_s3' only
# (Usually used during testing)
# Recommend: use EC2 instances with proper S3 access roles and
# leave these attributes unset:
#default['cfe-mariadb']['reload']['aws_access_key_id'] = 'MYKEYID'
#default['cfe-mariadb']['reload']['aws_secret_access_key'] = 'MYSECRETKEY'
# Whether to encrypt the backup DB dumps before storing them in S3.
# 'priv_key': String. Contents of the private key file.
#
# Used only in recipe 'reload_from_s3' if some/all DB dumps
# to be reloaded are encrypted.
#
# File is automatically deleted after the recipe is run.
# 'pub_key': String. Contents of the public key file.
#
# Used by the backup script to encrypt the DB dump
# if ':bak_encrypted' is set to true for that DB.
#
# The key file will be stored in the same directory
# as the script as 'pub.key'.
default['cfe-mariadb']['encrypt']['priv_key'] = nil
default['cfe-mariadb']['encrypt']['pub_key'] = nil
default['mariadb']['server_root_password'] = 'secretpassword'
default['mariadb']['mysqld']['bind_address'] = '127.0.0.1'
default['mariadb']['mysqld']['port'] = '3306'
default['mariadb']['install']['type'] = 'package'
default['mariadb']['install']['version'] = '10.0'
default['mariadb']['use_default_repository'] = true
default['mariadb']['forbid_remote_root'] = true
# io_capacity has to be roughly the IO capacity of the EC2 instance.
# buffer_pool_size can be increased to 75% (0.75) of RAM if dedicated server.
default['mariadb']['innodb']['io_capacity'] = '40'
default['mariadb']['innodb']['buffer_pool_size'] =
( %x(free -m).split(' ')[7].to_i * 0.5 ).round.to_s
# Set innodb_open_files value same as table_open_cache.
# But set open_files_limit as highest.
default['mariadb']['innodb']['open_files'] = '2000'
default['mariadb']['mysqld']['table_open_cache'] = '2000'
default['mariadb']['mysqld']['open_files_limit'] = '24000'
## Tip:
## For encrypted attributes like passwords,
## the following is possible in the attributes file:
##
# secret = Chef::EncryptedDataBagItem.load(
# my_data_bag, my_secret_data_bag_item
# )
# default['cfe-mariadb']['some_prop'] = secret['db_password']