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
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'manifests/config.pp', line 26
class couchbase::config (
$size = 1024,
$user = $::couchbase::user,
$password = $::couchbase::password,
$server_group = 'default',
$ensure = $::couchbase::ensure,
$autofailover = $::couchbase::params::autofailover,
) {
include ::couchbase::params
if $autofailover == false {
$_autofailover = 0
} else {
$_autofailover = 1
}
# Intitialize a script file
concat { $::couchbase::params::node_init_script:
owner => '0',
group => '0',
mode => '0655',
}
# Node_init (configure data directory location, etc - be careful to change it will destroy current data)
if $ensure == present {
concat::fragment { "${server_group}_couchbase_server_${name}_node_init":
order => "15-${server_group}-${::server_name}-node-init",
target => $::couchbase::params::node_init_script,
content => template('couchbase/couchbasenode_init.erb'),
}
}
else {
concat::fragment { "${server_group}_couchbase_server_${name}_node_init":
order => "15-${server_group}-${::server_name}-node-init",
target => $::couchbase::params::node_init_script,
content => "#!/bin/bash\necho 'Skip Init - removing node from cluster.'",
}
}
exec { 'couchbase-node-init':
path => ['/opt/couchbase/bin', '/usr/bin', '/bin', '/sbin', '/usr/sbin' ],
command => $::couchbase::params::node_init_script,
require => [ Class['couchbase::install'] ],
creates => $::couchbase::params::node_init_lock,
logoutput => true,
tries => 5,
try_sleep => 10,
notify => Exec['couchbase-init'],
}
# Cluster_init (configure memory, etc)
# Initialize a script file
concat { $::couchbase::params::cluster_init_script:
owner => '0',
group => '0',
mode => '0655',
}
concat::fragment { '00_cluster_init_script_header':
target => $::couchbase::params::cluster_init_script,
order => '01',
content => template('couchbase/couchbase-cluster-setup.sh.erb'),
}
concat::fragment { "${server_group}_couchbase_server_${name}_init":
order => "15-${server_group}-${::server_name}-init",
target => $::couchbase::params::cluster_init_script,
content => template('couchbase/couchbase-cluster-init.sh.erb'),
notify => Exec['couchbase-init'],
}
exec { 'couchbase-init':
path => ['/opt/couchbase/bin', '/usr/bin', '/bin', '/sbin', '/usr/sbin' ],
command => $::couchbase::params::cluster_init_script,
require => [ Class['couchbase::install'], Exec['couchbase-node-init']],
logoutput => true,
tries => 5,
try_sleep => 10,
refreshonly => true,
notify => Exec['couchbase-cluster-setup'],
}
# Initialize the cluster-building script
concat { $::couchbase::params::cluster_script:
owner => '0',
group => '0',
mode => '0655',
}
concat::fragment { '00_script_header':
target => $::couchbase::params::cluster_script,
order => '01',
content => template('couchbase/couchbase-cluster-setup.sh.erb'),
notify => Exec['couchbase-cluster-setup'],
}
# Collect cluster node entries for config (from stored configs & PuppetDB)
Couchbase::Couchbasenode <<| server_group == $server_group |>> ->
exec { 'couchbase-cluster-setup':
path => ['/usr/local/bin', '/usr/bin/', '/sbin', '/bin', '/usr/sbin',
'/opt/couchbase/bin'],
cwd => '/usr/local/bin',
command => 'couchbase-cluster-setup.sh',
require => [ Concat[$::couchbase::params::cluster_script], Exec['couchbase-init'] ],
returns => [0, 2],
logoutput => true,
refreshonly => true,
}
}
|