cloud-mu 3.6.10 → 3.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Berksfile +2 -3
- data/Berksfile.lock +11 -14
- data/bin/mu-aws-setup +16 -4
- data/bin/mu-configure +2 -1
- data/cloud-mu.gemspec +2 -2
- data/cookbooks/mu-firewall/Berksfile +1 -1
- data/cookbooks/mu-firewall/attributes/default.rb +2 -2
- data/cookbooks/mu-firewall/metadata.rb +3 -3
- data/cookbooks/mu-firewall/recipes/default.rb +11 -2
- data/cookbooks/mu-master/Berksfile +1 -1
- data/cookbooks/mu-master/attributes/default.rb +14 -1
- data/cookbooks/mu-master/files/default/389ds-perl/ASDialogs.pm +173 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminMigration.pm +569 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminServer.pm +952 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminUtil.pm +983 -0
- data/cookbooks/mu-master/files/default/389ds-perl/ConfigDSDialogs.pm +449 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSCreate.pm +1551 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSDialogs.pm +233 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSMigration.pm +1175 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdate.pm +534 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdateDialogs.pm +152 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUtil.pm +1710 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Dialog.pm +249 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DialogManager.pm +212 -0
- data/cookbooks/mu-master/files/default/389ds-perl/FileConn.pm +461 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Inf.pm +268 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Migration.pm +327 -0
- data/cookbooks/mu-master/files/default/389ds-perl/RegDSDialogs.pm +94 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Resource.pm +137 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Setup.pm +240 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupDialogs.pm +243 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupLog.pm +82 -0
- data/cookbooks/mu-master/files/default/setCertName.ldif +4 -0
- data/cookbooks/mu-master/libraries/mu.rb +2 -2
- data/cookbooks/mu-master/metadata.rb +1 -1
- data/cookbooks/mu-master/recipes/389ds.rb +71 -32
- data/cookbooks/mu-master/recipes/basepackages.rb +5 -0
- data/cookbooks/mu-master/recipes/default.rb +16 -5
- data/cookbooks/mu-master/recipes/init.rb +36 -3
- data/cookbooks/mu-master/recipes/ssl-certs.rb +6 -0
- data/cookbooks/mu-master/recipes/sssd.rb +85 -62
- data/cookbooks/mu-master/recipes/update_nagios_only.rb +7 -1
- data/cookbooks/mu-master/templates/default/389-directory-setup.inf.erb +11 -26
- data/cookbooks/mu-master/templates/default/sssd.conf.erb +18 -8
- data/cookbooks/mu-tools/files/default/Mu_CA.pem +33 -0
- data/cookbooks/mu-tools/metadata.rb +0 -1
- data/cookbooks/mu-tools/recipes/set_local_fw.rb +7 -1
- data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +5 -1
- data/cookbooks/nagios/CHANGELOG.md +679 -0
- data/cookbooks/nagios/LICENSE +201 -0
- data/cookbooks/nagios/README.md +340 -0
- data/cookbooks/nagios/attributes/config.rb +163 -0
- data/cookbooks/nagios/attributes/default.rb +204 -0
- data/cookbooks/nagios/libraries/base.rb +311 -0
- data/cookbooks/nagios/libraries/command.rb +68 -0
- data/cookbooks/nagios/libraries/contact.rb +229 -0
- data/cookbooks/nagios/libraries/contactgroup.rb +111 -0
- data/cookbooks/{firewall/recipes/disable_firewall.rb → nagios/libraries/custom_option.rb} +20 -7
- data/cookbooks/nagios/libraries/data_bag_helper.rb +23 -0
- data/cookbooks/nagios/libraries/default.rb +90 -0
- data/cookbooks/nagios/libraries/helpers.rb +229 -0
- data/cookbooks/nagios/libraries/host.rb +410 -0
- data/cookbooks/nagios/libraries/hostdependency.rb +178 -0
- data/cookbooks/nagios/libraries/hostescalation.rb +170 -0
- data/cookbooks/nagios/libraries/hostgroup.rb +117 -0
- data/cookbooks/nagios/libraries/nagios.rb +277 -0
- data/cookbooks/nagios/libraries/resource.rb +59 -0
- data/cookbooks/nagios/libraries/service.rb +449 -0
- data/cookbooks/nagios/libraries/servicedependency.rb +213 -0
- data/cookbooks/nagios/libraries/serviceescalation.rb +193 -0
- data/cookbooks/nagios/libraries/servicegroup.rb +142 -0
- data/cookbooks/nagios/libraries/timeperiod.rb +159 -0
- data/cookbooks/nagios/libraries/users_helper.rb +54 -0
- data/cookbooks/nagios/metadata.json +44 -0
- data/cookbooks/nagios/metadata.rb +22 -0
- data/cookbooks/nagios/recipes/_load_databag_config.rb +153 -0
- data/cookbooks/nagios/recipes/_load_default_config.rb +241 -0
- data/cookbooks/nagios/recipes/apache.rb +114 -0
- data/cookbooks/nagios/recipes/default.rb +41 -0
- data/cookbooks/nagios/recipes/nginx.rb +114 -0
- data/cookbooks/nagios/recipes/pagerduty.rb +95 -0
- data/cookbooks/nagios/recipes/server.rb +182 -0
- data/cookbooks/nagios/recipes/server_package.rb +85 -0
- data/cookbooks/nagios/recipes/server_source.rb +137 -0
- data/cookbooks/nagios/resources/command.rb +34 -0
- data/cookbooks/nagios/resources/conf.rb +52 -0
- data/cookbooks/nagios/resources/contact.rb +34 -0
- data/cookbooks/nagios/resources/contactgroup.rb +35 -0
- data/cookbooks/nagios/resources/host.rb +35 -0
- data/cookbooks/nagios/resources/hostdependency.rb +35 -0
- data/cookbooks/nagios/resources/hostescalation.rb +36 -0
- data/cookbooks/nagios/resources/hostgroup.rb +35 -0
- data/cookbooks/nagios/resources/resource.rb +34 -0
- data/cookbooks/nagios/resources/service.rb +35 -0
- data/cookbooks/nagios/resources/servicedependency.rb +35 -0
- data/cookbooks/nagios/resources/serviceescalation.rb +35 -0
- data/cookbooks/nagios/resources/servicegroup.rb +35 -0
- data/cookbooks/nagios/resources/timeperiod.rb +35 -0
- data/cookbooks/nagios/templates/apache2.conf.erb +102 -0
- data/cookbooks/nagios/templates/cgi.cfg.erb +266 -0
- data/cookbooks/nagios/templates/commands.cfg.erb +13 -0
- data/cookbooks/nagios/templates/contacts.cfg.erb +37 -0
- data/cookbooks/nagios/templates/hostgroups.cfg.erb +25 -0
- data/cookbooks/nagios/templates/hosts.cfg.erb +15 -0
- data/cookbooks/nagios/templates/htpasswd.users.erb +6 -0
- data/cookbooks/nagios/templates/nagios.cfg.erb +22 -0
- data/cookbooks/nagios/templates/nginx.conf.erb +80 -0
- data/cookbooks/nagios/templates/pagerduty.cgi.erb +185 -0
- data/cookbooks/nagios/templates/resource.cfg.erb +27 -0
- data/cookbooks/nagios/templates/servicedependencies.cfg.erb +15 -0
- data/cookbooks/nagios/templates/servicegroups.cfg.erb +14 -0
- data/cookbooks/nagios/templates/services.cfg.erb +14 -0
- data/cookbooks/nagios/templates/spawn-fcgi.erb +10 -0
- data/cookbooks/nagios/templates/templates.cfg.erb +31 -0
- data/cookbooks/nagios/templates/timeperiods.cfg.erb +13 -0
- data/extras/platform_berksfile_base +3 -3
- data/extras/python_rpm/build.sh +4 -4
- data/extras/python_rpm/muthon.spec +2 -4
- data/extras/vault_tools/export_vaults.sh +11 -1
- data/install/installer +1 -1
- data/modules/mu/kittens.rb +27523 -0
- data/modules/mu/master/ldap.rb +48 -31
- data/modules/mu/master.rb +69 -0
- data/modules/mu/mu.yaml.rb +351 -0
- data/modules/mu/providers/aws/firewall_rule.rb +3 -1
- data/modules/mu/providers/aws.rb +11 -5
- data/modules/mu.rb +5 -4
- metadata +99 -48
- data/cookbooks/firewall/CHANGELOG.md +0 -488
- data/cookbooks/firewall/LICENSE +0 -202
- data/cookbooks/firewall/README.md +0 -366
- data/cookbooks/firewall/TODO.md +0 -6
- data/cookbooks/firewall/attributes/default.rb +0 -5
- data/cookbooks/firewall/attributes/firewalld.rb +0 -8
- data/cookbooks/firewall/attributes/iptables.rb +0 -17
- data/cookbooks/firewall/attributes/ufw.rb +0 -12
- data/cookbooks/firewall/attributes/windows.rb +0 -8
- data/cookbooks/firewall/libraries/helpers.rb +0 -105
- data/cookbooks/firewall/libraries/helpers_firewalld.rb +0 -116
- data/cookbooks/firewall/libraries/helpers_firewalld_dbus.rb +0 -72
- data/cookbooks/firewall/libraries/helpers_iptables.rb +0 -112
- data/cookbooks/firewall/libraries/helpers_nftables.rb +0 -170
- data/cookbooks/firewall/libraries/helpers_ufw.rb +0 -142
- data/cookbooks/firewall/libraries/helpers_windows.rb +0 -129
- data/cookbooks/firewall/libraries/provider_firewall_firewalld.rb +0 -179
- data/cookbooks/firewall/libraries/provider_firewall_iptables.rb +0 -171
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu1404.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_rule.rb +0 -34
- data/cookbooks/firewall/libraries/provider_firewall_ufw.rb +0 -138
- data/cookbooks/firewall/libraries/provider_firewall_windows.rb +0 -126
- data/cookbooks/firewall/libraries/resource_firewall.rb +0 -26
- data/cookbooks/firewall/libraries/resource_firewall_rule.rb +0 -52
- data/cookbooks/firewall/metadata.json +0 -40
- data/cookbooks/firewall/metadata.rb +0 -15
- data/cookbooks/firewall/recipes/default.rb +0 -76
- data/cookbooks/firewall/recipes/firewalld.rb +0 -87
- data/cookbooks/firewall/resources/firewalld.rb +0 -28
- data/cookbooks/firewall/resources/firewalld_config.rb +0 -39
- data/cookbooks/firewall/resources/firewalld_helpers.rb +0 -106
- data/cookbooks/firewall/resources/firewalld_icmptype.rb +0 -88
- data/cookbooks/firewall/resources/firewalld_ipset.rb +0 -104
- data/cookbooks/firewall/resources/firewalld_policy.rb +0 -115
- data/cookbooks/firewall/resources/firewalld_service.rb +0 -98
- data/cookbooks/firewall/resources/firewalld_zone.rb +0 -118
- data/cookbooks/firewall/resources/nftables.rb +0 -71
- data/cookbooks/firewall/resources/nftables_rule.rb +0 -113
- data/cookbooks/firewall/templates/default/ufw/default.erb +0 -13
- /data/cookbooks/{firewall → nagios}/chefignore +0 -0
- /data/cookbooks/{firewall → nagios}/renovate.json +0 -0
@@ -0,0 +1,534 @@
|
|
1
|
+
# BEGIN COPYRIGHT BLOCK
|
2
|
+
# Copyright (C) 2009 Red Hat, Inc.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# License: GPL (version 3 or any later version).
|
6
|
+
# See LICENSE for details.
|
7
|
+
# END COPYRIGHT BLOCK
|
8
|
+
#
|
9
|
+
|
10
|
+
###########################
|
11
|
+
#
|
12
|
+
# This perl module provides code to update/upgrade directory
|
13
|
+
# server shared files/config and instance specific files/config
|
14
|
+
#
|
15
|
+
##########################
|
16
|
+
|
17
|
+
package DSUpdate;
|
18
|
+
use DSUtil;
|
19
|
+
use Inf;
|
20
|
+
use FileConn;
|
21
|
+
use DSCreate qw(setDefaults createInstanceScripts makeOtherConfigFiles
|
22
|
+
makeDSDirs updateSelinuxPolicy updateTmpfilesDotD updateSystemD);
|
23
|
+
|
24
|
+
use File::Basename qw(basename dirname);
|
25
|
+
|
26
|
+
# load perldap
|
27
|
+
use Mozilla::LDAP::Conn;
|
28
|
+
use Mozilla::LDAP::Utils qw(normalizeDN);
|
29
|
+
use Mozilla::LDAP::API qw(ldap_explode_dn);
|
30
|
+
use Mozilla::LDAP::LDIF;
|
31
|
+
|
32
|
+
use Exporter;
|
33
|
+
@ISA = qw(Exporter);
|
34
|
+
@EXPORT = qw(updateDS isOffline);
|
35
|
+
@EXPORT_OK = qw(updateDS isOffline);
|
36
|
+
|
37
|
+
use strict;
|
38
|
+
|
39
|
+
use SetupLog;
|
40
|
+
|
41
|
+
# the default location of the updates - this is a subdir
|
42
|
+
# of the directory server data dir (e.g. /usr/share/dirsrv)
|
43
|
+
# the default directory is read-only - if you need to provide
|
44
|
+
# additional updates, pass in additional update directories
|
45
|
+
# to updateDS
|
46
|
+
my $DS_UPDATE_PATH = "/usr/share/dirsrv/updates";
|
47
|
+
|
48
|
+
my $PRE_STAGE = "pre";
|
49
|
+
my $PREINST_STAGE = "preinst";
|
50
|
+
my $RUNINST_STAGE = "runinst";
|
51
|
+
my $POSTINST_STAGE = "postinst";
|
52
|
+
my $POST_STAGE = "post";
|
53
|
+
|
54
|
+
my @STAGES = ($PRE_STAGE, $PREINST_STAGE, $RUNINST_STAGE, $POSTINST_STAGE, $POST_STAGE);
|
55
|
+
my @INSTSTAGES = ($PREINST_STAGE, $RUNINST_STAGE, $POSTINST_STAGE);
|
56
|
+
|
57
|
+
# used to create unique package names for loading updates
|
58
|
+
# from perl scriptlets
|
59
|
+
my $pkgname = "Package00000000000";
|
60
|
+
|
61
|
+
# generate and return a unique package name that is a
|
62
|
+
# subpackage of our current package
|
63
|
+
sub get_pkgname {
|
64
|
+
return __PACKAGE__ . "::" . $pkgname++;
|
65
|
+
}
|
66
|
+
|
67
|
+
sub loadUpdates {
|
68
|
+
my $errs = shift;
|
69
|
+
my $dirs = shift;
|
70
|
+
my $mapinfo = shift || {};
|
71
|
+
my @updates; # a list of hash refs, sorted in execution order
|
72
|
+
|
73
|
+
for my $dir (@{$dirs}) {
|
74
|
+
for my $file (glob("$dir/*")) {
|
75
|
+
my $name = basename($file);
|
76
|
+
next if $name !~ /^\d\d/; # we only consider files that begin with two digits
|
77
|
+
# print "name = $name\n";
|
78
|
+
my $href = { path => $file, name => $name };
|
79
|
+
if ($file =~ /\.(pl|pm)$/) { # a perl file
|
80
|
+
my $fullpkg = get_pkgname(); # get a unique package name for the file
|
81
|
+
# this will import the update functions from the given file
|
82
|
+
# each file is given its own private namespace via the package
|
83
|
+
# directive below
|
84
|
+
# we have to use the eval because package takes a "bareword" -
|
85
|
+
# you cannot pass a dynamically constructed string to package
|
86
|
+
eval "package $fullpkg; require q($file)"; # "import" it
|
87
|
+
if ($@) {
|
88
|
+
if ($@ =~ /did not return a true value/) {
|
89
|
+
# this usually means the file did not end with 1; - just use it anyway
|
90
|
+
debug(3, "notice: $file does not return a true value - using anyway\n");
|
91
|
+
} else {
|
92
|
+
# probably a syntax or other compilation error in the file
|
93
|
+
# we can't safely use it, so log it and skip it
|
94
|
+
push @{$errs}, ['error_loading_update', $file, $@];
|
95
|
+
debug(0, "Error: not applying update $file. Error: $@\n");
|
96
|
+
next; # skip this one
|
97
|
+
}
|
98
|
+
}
|
99
|
+
# grab the hook functions from the update
|
100
|
+
for my $fn (@STAGES) {
|
101
|
+
# this is some deep perl magic - see the perl Symbol Table
|
102
|
+
# documentation for the gory details
|
103
|
+
# We're trying to find if the file defined a symbol called
|
104
|
+
# pre, run, post, etc. and if so, if that symbol is code
|
105
|
+
no strict 'refs'; # turn off strict refs to use magic
|
106
|
+
if (*{$fullpkg . "::" . $fn}{CODE}) {
|
107
|
+
debug(5, "$file $fn is defined\n");
|
108
|
+
# store the "function pointer" in the href for this update
|
109
|
+
$href->{$fn} = \&{$fullpkg . "::" . $fn};
|
110
|
+
} else {
|
111
|
+
debug(5, "$file $fn is not defined or not a subroutine\n");
|
112
|
+
}
|
113
|
+
}
|
114
|
+
} else { # some other type of file
|
115
|
+
$href->{file} = 1;
|
116
|
+
}
|
117
|
+
if ($mapinfo->{$file}) {
|
118
|
+
$href->{mapper} = $mapinfo->{$file}->{mapper};
|
119
|
+
$href->{infary} = $mapinfo->{$file}->{infary};
|
120
|
+
}
|
121
|
+
push @updates, $href;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
# we have all the updates now - sort by the name
|
126
|
+
@updates = sort { $a->{name} cmp $b->{name} } @updates;
|
127
|
+
|
128
|
+
return @updates;
|
129
|
+
}
|
130
|
+
|
131
|
+
sub applyLDIFUpdate {
|
132
|
+
my ($upd, $conn, $inf) = @_;
|
133
|
+
my @errs;
|
134
|
+
my $path = ref($upd) ? $upd->{path} : $upd;
|
135
|
+
|
136
|
+
my $mapper;
|
137
|
+
my @infary;
|
138
|
+
# caller can set mapper to use and additional inf to use
|
139
|
+
if (ref($upd)) {
|
140
|
+
if ($upd->{mapper}) {
|
141
|
+
$mapper = new Inf($upd->{mapper});
|
142
|
+
}
|
143
|
+
if ($upd->{infary}) {
|
144
|
+
@infary = @{$upd->{infary}};
|
145
|
+
}
|
146
|
+
}
|
147
|
+
if (!$mapper) {
|
148
|
+
$mapper = new Inf("$inf->{General}->{prefix}/usr/share/dirsrv/inf/dsupdate.map");
|
149
|
+
}
|
150
|
+
my $dsinf = new Inf("$inf->{General}->{prefix}/usr/share/dirsrv/inf/slapd.inf");
|
151
|
+
|
152
|
+
$mapper = process_maptbl($mapper, \@errs, $inf, $dsinf, @infary);
|
153
|
+
if (!$mapper or @errs) {
|
154
|
+
return @errs;
|
155
|
+
}
|
156
|
+
|
157
|
+
getMappedEntries($mapper, [$path], \@errs, \&check_and_add_entry,
|
158
|
+
[$conn]);
|
159
|
+
|
160
|
+
return @errs;
|
161
|
+
}
|
162
|
+
|
163
|
+
# process an update from an ldif file or executable
|
164
|
+
# LDIF files only apply to instance updates, so ignore
|
165
|
+
# LDIF files when not processing updates for instances
|
166
|
+
sub processUpdate {
|
167
|
+
my ($upd, $inf, $configdir, $stage, $inst, $dseldif, $conn) = @_;
|
168
|
+
my @errs;
|
169
|
+
# $upd is either a hashref or a simple path name
|
170
|
+
my $path = ref($upd) ? $upd->{path} : $upd;
|
171
|
+
if ($path =~ /\.ldif$/) {
|
172
|
+
# ldif files are only processed during the runinst stage
|
173
|
+
if ($stage eq $RUNINST_STAGE) {
|
174
|
+
@errs = applyLDIFUpdate($upd, $conn, $inf);
|
175
|
+
}
|
176
|
+
} elsif (-x $path) {
|
177
|
+
# setup environment
|
178
|
+
$ENV{DS_UPDATE_STAGE} = $stage;
|
179
|
+
$ENV{DS_UPDATE_DIR} = $configdir;
|
180
|
+
$ENV{DS_UPDATE_INST} = $inst; # empty if not instance specific
|
181
|
+
$ENV{DS_UPDATE_DSELDIF} = $dseldif; # empty if not instance specific
|
182
|
+
$? = 0; # clear error condition
|
183
|
+
my $output = `$path 2>&1`;
|
184
|
+
if ($?) {
|
185
|
+
@errs = ('error_executing_update', $path, $?, $output);
|
186
|
+
}
|
187
|
+
debug(1, $output);
|
188
|
+
} else {
|
189
|
+
@errs = ('error_unknown_update', $path);
|
190
|
+
}
|
191
|
+
|
192
|
+
return @errs;
|
193
|
+
}
|
194
|
+
|
195
|
+
#
|
196
|
+
sub updateDS {
|
197
|
+
# get base configdir, instances from setup
|
198
|
+
my $setup = shift;
|
199
|
+
# get other info from inf
|
200
|
+
my $inf = $setup->{inf};
|
201
|
+
# directories containing updates to apply
|
202
|
+
my $dirs = shift || [];
|
203
|
+
my $mapinfo = shift;
|
204
|
+
# the default directory server update path
|
205
|
+
if ($inf->{slapd}->{updatedir}) {
|
206
|
+
push @{$dirs}, $inf->{General}->{prefix} . $inf->{slapd}->{updatedir};
|
207
|
+
} else {
|
208
|
+
push @{$dirs}, $inf->{General}->{prefix} . $DS_UPDATE_PATH;
|
209
|
+
}
|
210
|
+
my @errs;
|
211
|
+
my $force = $setup->{force};
|
212
|
+
|
213
|
+
my @updates = loadUpdates(\@errs, $dirs, $mapinfo);
|
214
|
+
|
215
|
+
if (@errs and !$force) {
|
216
|
+
return @errs;
|
217
|
+
}
|
218
|
+
|
219
|
+
if (!@updates) {
|
220
|
+
# nothing to do?
|
221
|
+
debug(0, "No updates to apply in @{$dirs}\n");
|
222
|
+
return @errs;
|
223
|
+
}
|
224
|
+
|
225
|
+
# run pre-update hooks
|
226
|
+
for my $upd (@updates) {
|
227
|
+
my @localerrs;
|
228
|
+
if ($upd->{$PRE_STAGE}) {
|
229
|
+
debug(1, "Running updateDS stage $PRE_STAGE update ", $upd->{path}, "\n");
|
230
|
+
@localerrs = &{$upd->{$PRE_STAGE}}($inf, $setup->{configdir});
|
231
|
+
} elsif ($upd->{file}) {
|
232
|
+
debug(1, "Running updateDS stage $PRE_STAGE update ", $upd->{path}, "\n");
|
233
|
+
@localerrs = processUpdate($upd, $inf, $setup->{configdir}, $PRE_STAGE);
|
234
|
+
}
|
235
|
+
if (@localerrs) {
|
236
|
+
push @errs, @localerrs;
|
237
|
+
if (!$force) {
|
238
|
+
return @errs;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
|
243
|
+
# update each instance
|
244
|
+
my @instances = $setup->getDirServers();
|
245
|
+
my $inst_count = @instances;
|
246
|
+
my @failed_instances = ();
|
247
|
+
my $failed_count = 0;
|
248
|
+
for my $inst (@instances) {
|
249
|
+
debug(0, "Updating instance ($inst)...\n");
|
250
|
+
my @localerrs = updateDSInstance($inst, $inf, $setup->{configdir}, \@updates, $force);
|
251
|
+
if (@localerrs) {
|
252
|
+
# push array here because localerrs will likely be an array of
|
253
|
+
# array refs already
|
254
|
+
$failed_count++;
|
255
|
+
if (!$force || $inst_count == 1) {
|
256
|
+
push @errs, @localerrs;
|
257
|
+
return @errs;
|
258
|
+
}
|
259
|
+
push @failed_instances, $inst;
|
260
|
+
debug(0, "Failed to update instance ($inst):\n---> @localerrs\n");
|
261
|
+
} else {
|
262
|
+
debug(0, "Successfully updated instance ($inst).\n");
|
263
|
+
}
|
264
|
+
}
|
265
|
+
if($failed_count && $failed_count == $inst_count){
|
266
|
+
push @errs, ('error_update_all');
|
267
|
+
return @errs;
|
268
|
+
}
|
269
|
+
if (@failed_instances){
|
270
|
+
# list all the instances that were not updated
|
271
|
+
debug(0, "The following instances were not updated: (@failed_instances). ");
|
272
|
+
debug(0, "After fixing the problems you will need to rerun the setup script\n");
|
273
|
+
}
|
274
|
+
|
275
|
+
# run post-update hooks
|
276
|
+
for my $upd (@updates) {
|
277
|
+
my @localerrs;
|
278
|
+
if ($upd->{$POST_STAGE}) {
|
279
|
+
debug(1, "Running updateDS stage $POST_STAGE update ", $upd->{path}, "\n");
|
280
|
+
@localerrs = &{$upd->{$POST_STAGE}}($inf, $setup->{configdir});
|
281
|
+
} elsif ($upd->{file}) {
|
282
|
+
debug(1, "Running updateDS stage $POST_STAGE update ", $upd->{path}, "\n");
|
283
|
+
@localerrs = processUpdate($upd, $inf, $setup->{configdir}, $POST_STAGE);
|
284
|
+
}
|
285
|
+
if (@localerrs) {
|
286
|
+
push @errs, @localerrs;
|
287
|
+
if (!$force) {
|
288
|
+
return @errs;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
}
|
292
|
+
|
293
|
+
return @errs;
|
294
|
+
}
|
295
|
+
|
296
|
+
sub updateDSInstance {
|
297
|
+
my ($inst, $inf, $configdir, $updates, $force) = @_;
|
298
|
+
my @errs;
|
299
|
+
|
300
|
+
my $dseldif = "$configdir/$inst/dse.ldif";
|
301
|
+
|
302
|
+
# get the information we need from the instance
|
303
|
+
delete $inf->{slapd}; # delete old data, if any
|
304
|
+
if (@errs = initInfFromInst($inf, $dseldif, $configdir, $inst)) {
|
305
|
+
return @errs;
|
306
|
+
}
|
307
|
+
|
308
|
+
# create dirs if missing e.g. cross platform upgrade
|
309
|
+
if (@errs = makeDSDirs($inf)) {
|
310
|
+
return @errs;
|
311
|
+
}
|
312
|
+
|
313
|
+
# upgrade instance scripts
|
314
|
+
if (@errs = createInstanceScripts($inf, 0)) {
|
315
|
+
return @errs;
|
316
|
+
}
|
317
|
+
|
318
|
+
# add new or missing config files
|
319
|
+
if (@errs = makeOtherConfigFiles($inf, 1)) {
|
320
|
+
return @errs;
|
321
|
+
}
|
322
|
+
|
323
|
+
my $conn;
|
324
|
+
if ($inf->{General}->{UpdateMode} eq 'online') {
|
325
|
+
# open a connection to the directory server to upgrade
|
326
|
+
my $host = $inf->{General}->{FullMachineName};
|
327
|
+
my $port = $inf->{slapd}->{ServerPort};
|
328
|
+
# this says RootDN and password, but it can be any administrative DN
|
329
|
+
# such as the one used by the console
|
330
|
+
my $binddn = $inf->{$inst}->{RootDN} || $inf->{slapd}->{RootDN};
|
331
|
+
my $bindpw = $inf->{$inst}->{RootDNPwd};
|
332
|
+
my $certdir = $inf->{$inst}->{cert_dir} || $inf->{$inst}->{config_dir} || $inf->{slapd}->{cert_dir};
|
333
|
+
|
334
|
+
$conn = new Mozilla::LDAP::Conn({ host => $host, port => $port, bind => $binddn,
|
335
|
+
pswd => $bindpw, cert => $certdir, starttls => 1 });
|
336
|
+
if (!$conn) {
|
337
|
+
debug(1, "Could not open TLS connection to $host:$port - trying regular connection\n");
|
338
|
+
$conn = new Mozilla::LDAP::Conn({ host => $host, port => $port, bind => $binddn,
|
339
|
+
pswd => $bindpw });
|
340
|
+
}
|
341
|
+
|
342
|
+
if (!$conn) {
|
343
|
+
debug(0, "Could not open a connection to $host:$port\n");
|
344
|
+
return ('error_online_update', $host, $port, $binddn);
|
345
|
+
}
|
346
|
+
} else {
|
347
|
+
$conn = new FileConn($dseldif);
|
348
|
+
if (!$conn) {
|
349
|
+
debug(0, "Could not open a connection to $dseldif: $!\n");
|
350
|
+
return ('error_offline_update', $dseldif, $!);
|
351
|
+
}
|
352
|
+
}
|
353
|
+
|
354
|
+
# run pre-instance hooks first, then runinst hooks, then postinst hooks
|
355
|
+
# the DS_UPDATE_STAGE
|
356
|
+
for my $stage (@INSTSTAGES) {
|
357
|
+
# always process these first in the runinst stage - we don't really have any
|
358
|
+
# other good way to process conditional features during update
|
359
|
+
if ($stage eq $RUNINST_STAGE) {
|
360
|
+
my @ldiffiles;
|
361
|
+
if ("1") {
|
362
|
+
push @ldiffiles, $inf->{General}->{prefix} . $DS_UPDATE_PATH . "/dnaplugindepends.ldif";
|
363
|
+
}
|
364
|
+
push @ldiffiles, $inf->{General}->{prefix} . $DS_UPDATE_PATH . "/50updateconfig.ldif";
|
365
|
+
|
366
|
+
for my $ldiffile (@ldiffiles) {
|
367
|
+
my @localerrs = processUpdate($ldiffile, $inf, $configdir, $stage,
|
368
|
+
$inst, $dseldif, $conn);
|
369
|
+
if (@localerrs) {
|
370
|
+
push @errs, @localerrs;
|
371
|
+
if (!$force) {
|
372
|
+
$conn->close();
|
373
|
+
return @errs;
|
374
|
+
}
|
375
|
+
}
|
376
|
+
}
|
377
|
+
}
|
378
|
+
for my $upd (@{$updates}) {
|
379
|
+
my @localerrs;
|
380
|
+
if ($upd->{$stage}) {
|
381
|
+
debug(1, "Running updateDSInstance stage $stage update ", $upd->{path}, "\n");
|
382
|
+
@localerrs = &{$upd->{$stage}}($inf, $inst, $dseldif, $conn);
|
383
|
+
} elsif ($upd->{file}) {
|
384
|
+
debug(1, "Running updateDSInstance stage $stage update ", $upd->{path}, "\n");
|
385
|
+
@localerrs = processUpdate($upd, $inf, $configdir, $stage,
|
386
|
+
$inst, $dseldif, $conn);
|
387
|
+
}
|
388
|
+
if (@localerrs) {
|
389
|
+
push @errs, @localerrs;
|
390
|
+
if (!$force) {
|
391
|
+
$conn->close();
|
392
|
+
return @errs;
|
393
|
+
}
|
394
|
+
}
|
395
|
+
}
|
396
|
+
}
|
397
|
+
|
398
|
+
$conn->close();
|
399
|
+
|
400
|
+
updateSelinuxPolicy($inf);
|
401
|
+
|
402
|
+
push @errs, updateTmpfilesDotD($inf);
|
403
|
+
|
404
|
+
push @errs, updateSystemD(1, $inf);
|
405
|
+
|
406
|
+
return @errs;
|
407
|
+
}
|
408
|
+
|
409
|
+
# populate the fields in the inf we need to perform upgrade
|
410
|
+
# tasks from the information in the instance dse.ldif and
|
411
|
+
# other config
|
412
|
+
sub initInfFromInst {
|
413
|
+
my ($inf, $dseldif, $configdir, $inst) = @_;
|
414
|
+
my $conn = new FileConn($dseldif, 1);
|
415
|
+
if (!$conn) {
|
416
|
+
debug(1, "Error: Could not open config file $dseldif: Error $!\n");
|
417
|
+
return ('error_opening_dseldif', $dseldif, $!);
|
418
|
+
}
|
419
|
+
|
420
|
+
my $dn = "cn=config";
|
421
|
+
my $entry = $conn->search($dn, "base", "(cn=*)", 0);
|
422
|
+
if (!$entry) {
|
423
|
+
$conn->close();
|
424
|
+
debug(1, "Error: Search $dn in $dseldif failed: ".$conn->getErrorString()."\n");
|
425
|
+
return ('error_finding_config_entry', $dn, $dseldif, $conn->getErrorString());
|
426
|
+
}
|
427
|
+
|
428
|
+
my $servid = $inst;
|
429
|
+
$servid =~ s/slapd-//;
|
430
|
+
|
431
|
+
if (!$inf->{General}->{FullMachineName}) {
|
432
|
+
$inf->{General}->{FullMachineName} = $entry->getValue("nsslapd-localhost");
|
433
|
+
}
|
434
|
+
$inf->{General}->{SuiteSpotUserID} = $entry->getValue("nsslapd-localuser");
|
435
|
+
$inf->{slapd}->{ServerPort} = $entry->getValue("nsslapd-port");
|
436
|
+
$inf->{slapd}->{ldapifilepath} = $entry->getValue("nsslapd-ldapifilepath");
|
437
|
+
if (!$inf->{$inst}->{RootDN}) {
|
438
|
+
$inf->{$inst}->{RootDN} || $entry->getValue('nsslapd-rootdn');
|
439
|
+
}
|
440
|
+
# we don't use this password - we either use {$inst} password or
|
441
|
+
# none at all
|
442
|
+
$inf->{slapd}->{RootDNPwd} = '{SSHA}dummy';
|
443
|
+
if (!$inf->{$inst}->{cert_dir}) {
|
444
|
+
$inf->{$inst}->{cert_dir} = $entry->getValue('nsslapd-certdir');
|
445
|
+
}
|
446
|
+
$inf->{slapd}->{cert_dir} = $inf->{$inst}->{cert_dir};
|
447
|
+
if (!$inf->{slapd}->{ldif_dir}) {
|
448
|
+
$inf->{slapd}->{ldif_dir} = $entry->getValue('nsslapd-ldifdir');
|
449
|
+
}
|
450
|
+
if (!$inf->{slapd}->{ServerIdentifier}) {
|
451
|
+
$inf->{slapd}->{ServerIdentifier} = $servid;
|
452
|
+
}
|
453
|
+
if (!$inf->{slapd}->{bak_dir}) {
|
454
|
+
$inf->{slapd}->{bak_dir} = $entry->getValue('nsslapd-bakdir');
|
455
|
+
}
|
456
|
+
if (!$inf->{slapd}->{config_dir}) {
|
457
|
+
$inf->{slapd}->{config_dir} = $configdir."/".$inst;
|
458
|
+
}
|
459
|
+
if (!$inf->{slapd}->{inst_dir}) {
|
460
|
+
$inf->{slapd}->{inst_dir} = $entry->getValue('nsslapd-instancedir');
|
461
|
+
}
|
462
|
+
if (!$inf->{slapd}->{run_dir}) {
|
463
|
+
$inf->{slapd}->{run_dir} = $entry->getValue('nsslapd-rundir');
|
464
|
+
}
|
465
|
+
if (!$inf->{slapd}->{schema_dir}) {
|
466
|
+
$inf->{slapd}->{schema_dir} = $entry->getValue('nsslapd-schemadir');
|
467
|
+
}
|
468
|
+
if (!$inf->{slapd}->{lock_dir}) {
|
469
|
+
$inf->{slapd}->{lock_dir} = $entry->getValue('nsslapd-lockdir');
|
470
|
+
}
|
471
|
+
if (!$inf->{slapd}->{log_dir}) {
|
472
|
+
# use the errorlog dir
|
473
|
+
my $logfile = $entry->getValue('nsslapd-errorlog');
|
474
|
+
if ($logfile) {
|
475
|
+
$inf->{slapd}->{log_dir} = dirname($logfile);
|
476
|
+
}
|
477
|
+
}
|
478
|
+
if (!$inf->{slapd}->{sasl_path}) {
|
479
|
+
$inf->{slapd}->{sasl_path} = $entry->getValue('nsslapd-saslpath');
|
480
|
+
}
|
481
|
+
|
482
|
+
|
483
|
+
# dn: cn=config,cn=ldbm database,cn=plugins,cn=config
|
484
|
+
$dn = "cn=config,cn=ldbm database,cn=plugins,cn=config";
|
485
|
+
$entry = $conn->search($dn, "base", "(cn=*)", 0);
|
486
|
+
if (!$entry) {
|
487
|
+
$conn->close();
|
488
|
+
debug(1, "Error: Search $dn in $dseldif failed: ".$conn->getErrorString()."\n");
|
489
|
+
return ('error_finding_config_entry', $dn, $dseldif, $conn->getErrorString());
|
490
|
+
}
|
491
|
+
|
492
|
+
if (!$inf->{slapd}->{db_dir}) {
|
493
|
+
$inf->{slapd}->{db_dir} = $entry->getValue('nsslapd-directory');
|
494
|
+
}
|
495
|
+
|
496
|
+
$conn->close(); # don't need this anymore
|
497
|
+
|
498
|
+
# set defaults for things we don't know how to find, after setting the values
|
499
|
+
# we do know how to find
|
500
|
+
return setDefaults($inf);
|
501
|
+
}
|
502
|
+
|
503
|
+
# check to see if the user has chosen offline mode and the server is really offline
|
504
|
+
sub isOffline {
|
505
|
+
my ($inf, $inst, $conn) = @_;
|
506
|
+
|
507
|
+
if ($inf->{General}->{UpdateMode} !~ /offline/i) {
|
508
|
+
debug(3, "UpdateMode " . $inf->{General}->{UpdateMode} . " is not offline\n");
|
509
|
+
return 0;
|
510
|
+
}
|
511
|
+
|
512
|
+
# mode is offline - see if server is really offline
|
513
|
+
my $config = $conn->search("cn=config", "base", "(objectclass=*)");
|
514
|
+
if (!$config) {
|
515
|
+
return 0, ['error_finding_config_entry', 'cn=config',
|
516
|
+
$conn->getErrorString()];
|
517
|
+
}
|
518
|
+
my $rundir = $config->getValues('nsslapd-rundir');
|
519
|
+
|
520
|
+
if (serverIsRunning($rundir, $inst)) {
|
521
|
+
return 0, ['error_update_not_offline', $inst];
|
522
|
+
}
|
523
|
+
|
524
|
+
return 1; # server is offline
|
525
|
+
}
|
526
|
+
|
527
|
+
1;
|
528
|
+
|
529
|
+
# emacs settings
|
530
|
+
# Local Variables:
|
531
|
+
# mode:perl
|
532
|
+
# indent-tabs-mode: nil
|
533
|
+
# tab-width: 4
|
534
|
+
# End:
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# BEGIN COPYRIGHT BLOCK
|
2
|
+
# Copyright (C) 2009 Red Hat, Inc.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# License: GPL (version 3 or any later version).
|
6
|
+
# See LICENSE for details.
|
7
|
+
# END COPYRIGHT BLOCK
|
8
|
+
#
|
9
|
+
|
10
|
+
package DSUpdateDialogs;
|
11
|
+
|
12
|
+
use strict;
|
13
|
+
|
14
|
+
use DialogManager;
|
15
|
+
use Setup;
|
16
|
+
use Dialog;
|
17
|
+
use DSUtil;
|
18
|
+
use FileConn;
|
19
|
+
|
20
|
+
my @updateadmindialogs;
|
21
|
+
|
22
|
+
my $updatewelcome = new DialogYesNo (
|
23
|
+
$EXPRESS,
|
24
|
+
['update_dialog_first', 'brand', 'brand'],
|
25
|
+
1,
|
26
|
+
sub {
|
27
|
+
my $self = shift;
|
28
|
+
my $ans = shift;
|
29
|
+
my $res = $self->handleResponse($ans);
|
30
|
+
if ($res == $DialogManager::NEXT) {
|
31
|
+
$res = $DialogManager::ERR if (!$self->isYes());
|
32
|
+
}
|
33
|
+
return $res;
|
34
|
+
},
|
35
|
+
['update_dialog_first_prompt'],
|
36
|
+
);
|
37
|
+
|
38
|
+
my $updatemode = new Dialog (
|
39
|
+
$EXPRESS,
|
40
|
+
'update_dialog_mode',
|
41
|
+
sub {
|
42
|
+
my $self = shift;
|
43
|
+
return $self->{manager}->{inf}->{General}->{UpdateMode} ||
|
44
|
+
'quit';
|
45
|
+
},
|
46
|
+
sub {
|
47
|
+
my $self = shift;
|
48
|
+
my $ans = shift;
|
49
|
+
my $res = $DialogManager::ERR;
|
50
|
+
|
51
|
+
if ($ans =~ /^off/i) {
|
52
|
+
$self->{manager}->{inf}->{General}->{UpdateMode} = 'offline';
|
53
|
+
$res = $DialogManager::NEXT;
|
54
|
+
for (@updateadmindialogs) {
|
55
|
+
$_->disable(); # don't need admins and passwords
|
56
|
+
}
|
57
|
+
} elsif ($ans =~ /^on/i) {
|
58
|
+
$self->{manager}->{inf}->{General}->{UpdateMode} = 'online';
|
59
|
+
$res = $DialogManager::NEXT;
|
60
|
+
if (!@updateadmindialogs) {
|
61
|
+
@updateadmindialogs = makeInstanceDialogs($self->{manager});
|
62
|
+
$self->{manager}->addDialog(@updateadmindialogs);
|
63
|
+
}
|
64
|
+
for (@updateadmindialogs) {
|
65
|
+
$_->enable(); # need admins and passwords
|
66
|
+
}
|
67
|
+
}
|
68
|
+
return $res;
|
69
|
+
},
|
70
|
+
['update_dialog_mode_prompt']
|
71
|
+
);
|
72
|
+
|
73
|
+
sub makeInstanceDialogs {
|
74
|
+
my $manager = shift;
|
75
|
+
# for each directory server instance, create a dialog that prompts
|
76
|
+
# for the admin user and password for that instance
|
77
|
+
# the default admin user for each instance is the rootdn for that
|
78
|
+
# instance
|
79
|
+
for my $inst ($manager->{setup}->getDirServers()) {
|
80
|
+
my $innerinst = $inst;
|
81
|
+
if (!$manager->{inf}->{$inst}->{RootDN}) {
|
82
|
+
# if we don't already have an admin DN set for this
|
83
|
+
# instance, look in the dse.ldif for the nsslapd-rootdn
|
84
|
+
my $dseldif = $manager->{setup}->{configdir} . "/" . $inst . "/dse.ldif";
|
85
|
+
my $conn = new FileConn($dseldif, 1);
|
86
|
+
my $rootdn;
|
87
|
+
if ($conn) {
|
88
|
+
my $ent = $conn->search("cn=config", "base", '(objectclass=*)');
|
89
|
+
if ($ent) {
|
90
|
+
$rootdn = $ent->getValue('nsslapd-rootdn');
|
91
|
+
} else {
|
92
|
+
$manager->alert('error_finding_config_entry',
|
93
|
+
"cn=config", $dseldif, $conn->getErrorString());
|
94
|
+
}
|
95
|
+
$conn->close();
|
96
|
+
} else {
|
97
|
+
$manager->alert('error_opening_dseldif', $dseldif, $!);
|
98
|
+
}
|
99
|
+
if ($rootdn) {
|
100
|
+
$manager->{inf}->{$inst}->{RootDN} = $rootdn;
|
101
|
+
} else {
|
102
|
+
$manager->{inf}->{$inst}->{RootDN} = "cn=Directory Manager";
|
103
|
+
}
|
104
|
+
}
|
105
|
+
my $dlg = new Dialog (
|
106
|
+
$EXPRESS,
|
107
|
+
['update_admin_dialog', $innerinst],
|
108
|
+
sub {
|
109
|
+
my $self = shift;
|
110
|
+
my $index = shift;
|
111
|
+
my $id;
|
112
|
+
if ($index == 0) { # return undef for password defaults
|
113
|
+
$id = $self->{manager}->{inf}->{$innerinst}->{RootDN};
|
114
|
+
}
|
115
|
+
return $id;
|
116
|
+
},
|
117
|
+
sub {
|
118
|
+
my $self = shift;
|
119
|
+
my $ans = shift;
|
120
|
+
my $index = shift;
|
121
|
+
|
122
|
+
my $res = $DialogManager::SAME;
|
123
|
+
if ($index == 0) {
|
124
|
+
if (!isValidDN($ans)) {
|
125
|
+
$self->{manager}->alert("dialog_dsrootdn_error", $ans);
|
126
|
+
} else {
|
127
|
+
$self->{manager}->{inf}->{$innerinst}->{RootDN} = $ans;
|
128
|
+
$res = $DialogManager::NEXT;
|
129
|
+
}
|
130
|
+
} else {
|
131
|
+
if (!$ans or !length($ans)) {
|
132
|
+
$self->{manager}->alert("dialog_dsrootpw_invalid");
|
133
|
+
} else {
|
134
|
+
$self->{manager}->{inf}->{$innerinst}->{RootDNPwd} = $ans;
|
135
|
+
$res = $DialogManager::NEXT;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
return $res;
|
139
|
+
},
|
140
|
+
['update_admin_id_prompt'], ['update_admin_pwd_prompt', 1]
|
141
|
+
);
|
142
|
+
push @updateadmindialogs, $dlg;
|
143
|
+
}
|
144
|
+
|
145
|
+
return @updateadmindialogs;
|
146
|
+
}
|
147
|
+
|
148
|
+
sub getDialogs {
|
149
|
+
return ($updatewelcome, $updatemode);
|
150
|
+
}
|
151
|
+
|
152
|
+
1;
|