forked from quattor/template-library-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_templates.sh
executable file
·430 lines (330 loc) · 13.1 KB
/
test_templates.sh
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
#!/bin/bash
#
# Create one big profile including all pan templates and try to compile it
# (optional) arguments:
# clean: runs git clean (and will remove changes), to be used on jenkins only
#
rm -Rf ./build_temp
if [ "$1" == "clean" ]; then
git clean -fxd
fi
mkdir build_temp
tplfiles=`find . -type f -regex '.*\.tpl' |wc -l`
if [ $tplfiles -ne 0 ]; then
echo "[ERROR] found .tpl files, should be .pan only: $tplfiles"
exit 1
fi
# panc-annotations can have issues with multiple threads creating dirs
echo "Testing pan annotations"
find . -type d ! -regex '.*build_temp.*' | xargs -I '{}' mkdir -p 'build_temp/{}'
nrpanfiles=`find . -type f -regex '.*\.pan' | grep -v yumng | wc -l`
panfiles=`find . -type f -regex '.*\.pan' | grep -v yumng`
panc-annotations --output-dir build_temp $panfiles
nrannofiles=`find build_temp -type f -regex '.*annotation\.xml'|wc -l`
if [ $nrpanfiles != $nrannofiles ]; then
echo "[ERROR]: number of annotation files is not the same as numnber of pan files."
exit 1
else
echo "pan annotations ok"
fi
cat > build_temp/test.pan <<EOF
object template test;
# for quattor/aii/config
'/system/network/domainname' = 'local.domain';
'/system/network/hostname' = 'test';
# for quattor/aii/ks/config
variable AII_OSINSTALL_SRV = 'aii.local.domain';
variable AII_OSINSTALL_PROTOCOL = 'http';
variable AII_OSINSTALL_ROOT = '/base';
variable NODE_OS_VERSION_DEFAULT = "sl6x-x86_64";
variable AII_OSINSTALL_OS_VERSION = NODE_OS_VERSION_DEFAULT;
variable AII_OSINSTALL_ROOTPW = 'DUMMY';
"/hardware/harddisks/sda" = dict("capacity", 123, "interface", "sas");
variable AII_USE_CCM = false; # don't ever set this in real templates
"/system/aii/osinstall/ks/xwindows/defaultdesktop" = "GNOME";
# for quattor/aii/pxe/config
"/hardware/cards/nic/em1" = dict(
"boot", true,
"pxe", true,
"hwaddr", "aa:bb:cc:dd:ee:ff",
);
"/system/network/interfaces/em1/ip" = "1.2.3.4";
"/system/filesystems" = list();
"/system/blockdevices" = dict();
"/system/monitoring" = dict();
"/system/kernel" = dict();
"/system/rootmail" = "[email protected]";
# for quattor/client/config
variable QUATTOR_PROFILE_URL = "https://server.local.domain/profiles";
variable FULL_HOSTNAME = 'test.local.domain';
# template metaconfig/ganesha/config_v1 has it set to undef (which is ok)
variable GANESHA_FSAL = 'gpfs';
# can't be undef
"/software/repositories" = append(dict(
));
variable OS_VERSION_PARAMS = dict(
"majorversion", '6',
"major", "sl6",
"minor", "x",
"version", "sl6x",
"arch", "x86_64"
);
# fix for multiversion metaconfig
final variable METACONFIG_LOGSTASH_VERSION = '5.0';
final variable METACONFIG_ELASTICSEARCH_VERSION = '5.0';
# required metaconfig data
prefix "/software/components/metaconfig/services";
"{/etc/cgrules.conf}/contents/rules" = list();
"{/etc/ctdb/nodes}/contents/nodelist" = list();
"{/etc/ctdb/public_addresses}/contents/addresses" = list();
"{/etc/sysconfig/ctdb}/contents/service/ctdb_recovery_lock" = "a";
"{/etc/udev/rules.d/09-network.rules}/contents/interfaces" = dict();
"{/etc/aii/opennebula.conf}/contents" = dict();
"{/etc/bacula/bacula-fd.conf}/contents" = dict();
"{/etc/bacula/bacula-sd.conf}/contents" = dict();
"{/etc/bwctld/bwctld.conf}/contents" = dict("nuttcp_port", 123);
"{/var/lib/bwctl/.bwctlrc}/contents" = dict();
"{/etc/bwctld/bwctld.limits}/contents" = dict("assign", list(), "limit", dict());
"{/var/lib/perfsonar/.bwctlrc}/contents" = dict();
"{/etc/cachefilesd.conf}/contents/dir" = "a";
"{/etc/carbon-relay-ng.ini}/contents/init" = list();
"{/etc/cgconfig.d/quattor.conf}/contents" = dict();
"{/etc/elasticsearch/elasticsearch.yml}/contents" = dict();
"{/etc/filebeat/filebeat.yml}/contents/filebeat/prospectors" = list();
"{/etc/filebeat/filebeat.yml}/contents/output/console" = dict();
"{/etc/ganesha/ganesha.conf}/contents/exports" = list();
"{/etc/gpfsbeat/gpfsbeat.yml}/contents/gpfsbeat" = dict("devices", list(), "period", "123");
"{/etc/gpfsbeat/gpfsbeat.yml}/contents/output/console" = dict();
"{/etc/haproxy/haproxy.cfg}/contents/global" = dict("logs", dict(), "config", dict(), "stats", dict());
"{/etc/haproxy/haproxy.cfg}/contents/defaults" = dict("config", dict(), "timeouts", dict());
"{/etc/httpd/conf/httpd.conf}/contents/ifmodules" = list();
"{/etc/idmapd.conf}/contents/General/Domain" = "somedomain";
"{/etc/keepalived/keepalived.conf}/contents/global_defs/router_id" = "a";
"{/etc/keepalived/keepalived.conf}/contents/vrrp_scripts" = list();
"{/etc/keepalived/keepalived.conf}/contents/vrrp_instances" = list();
"{/etc/kibana/kibana.yml}/contents" = dict();
"{/etc/krb5.conf}/contents" = dict("logging", dict(), "realms", dict(), "domain_realms", dict());
"{/etc/krb5.conf}/contents/libdefaults/default_realm" = "a@b";
"{/etc/libvirt/libvirtd.conf}/contents" = dict();
"{/etc/libvirt/qemu.conf}/contents" = dict();
"{/etc/libvirt/qemu/vm.xml}/contents/name" = "a.bb";
"{/etc/lmodrc.lua}/contents/prop" = dict();
"{/etc/logstash-forwarder.conf}/contents/network/servers" = list();
"{/etc/logstash-forwarder.conf}/contents/files" = list();
"{/etc/logstash/conf.d/logstash.conf}/contents" = dict("input", dict(), "output", dict());
"{/etc/multipath.conf}/contents" = dict();
"{/etc/nagios/nrpe.cfg}/contents" = dict("allowed_hosts", list(), "command", dict());
"{/etc/named.conf}/contents/options/allow-query" = list();
"{/etc/ncm-ncd.conf}/contents" = dict();
"{/etc/nginx/nginx.conf}/contents/http/0/server" = list();
"{/etc/openvpn/client.conf}/contents" = dict("remote", list(), "ca", "/a",
"cert", "/b", "dev", "tun", "key", "/c", "proto", "tcp", "tls-auth", "hubba");
"{/etc/openvpn/server.conf}/contents" = dict("ca", "/a",
"cert", "/b", "dev", "tun", "key", "/c", "proto", "tcp", "tls-auth", "hubba");
"{/etc/pakiti/pakiti2-client.conf}/contents/server_name" = "a.bb";
"{/etc/ptpd2.conf}/contents/ptpengine/interface" = "em1";
"{/etc/rsyncd.conf}/contents/sections" = dict();
"{/etc/sasl2/libvirt.conf}/contents" = dict();
"{/etc/security/limits.d/91-quattor.conf}/contents/entries" = list();
"{/etc/singularity/singularity.conf}/contents" = dict();
"{/etc/snmp/snmp.conf}/contents" = dict();
"{/etc/snmp/snmpd.conf}/contents" = dict();
"{/etc/snmp/snmptrapd.conf}/contents" = dict();
"{/etc/snoopy.ini}/contents" = dict();
"{/etc/ssh/ssh_config}/contents" = dict();
"{/etc/sysconfig/ceph}/contents" = dict();
"{/etc/sysconfig/libvirtd}/contents" = dict();
"{/etc/topbeat/topbeat.yml}/contents/input" = dict();
"{/etc/topbeat/topbeat.yml}/contents/output/console" = dict();
"{/etc/updatedb.conf}/contents" = dict();
"{/etc/zkrs/default.conf}/contents" = dict("servers", list(), "source", true, "rsyncpath", "/a/b/c");
"{/etc/zookeeper/conf/zoo.cfg}/contents/main/dataDir" = "/a/b";
"{/etc/zookeeper/conf/zoo.cfg}/contents/servers" = list();
"{/opt/graphite/webapp/graphite/local_settings.py}/contents/config" = dict();
"{/opt/moab/etc/moab.cfg}/contents/main" = dict();
"{/opt/perfsonar_ps/lookup_service/etc/daemon.conf}/contents/port" = list();
"{/opt/perfsonar_ps/ls_registration_daemon/etc/ls_registration_daemon.conf}/contents" = dict("site", list(), "ls_instance", "http://some.thing");
"{/opt/perfsonar_ps/perfsonarbuoy_ma/etc/daemon.conf}/contents/ports" = list();
final variable OWDEFS = dict(
"data_dir", "/var/lib/perfsonar/perfsonarbuoy_ma/bwctl",
"central_host", "a.bb:8570",
"timeout", 3600,
"archive_dir", "/var/lib/perfsonar/perfsonarbuoy_ma/bwctl/archive",
"db", "bwctl",
);
"{/opt/perfsonar_ps/perfsonarbuoy_ma/etc/owmesh.conf}/contents" = dict(
"testspecs", dict(),
"nodes", dict(),
"localnodes", list(),
"hosts", dict(),
"groups", dict(),
"measurementsets", dict(),
"addrtype", list(),
"bwctl", OWDEFS,
"owamp", OWDEFS,
);
final variable ICDB = dict(
"dsn", dict(
"protocol", "pgsql",
"hostname", "a.bb",
"username", "user",
"password", "secret",
"port", 123,
"database_name", "ic",
),
"caching", dict("enabled", true, "use_query_cache", true),
"manager_attributes", dict(),
"load_models", "models",
"models_directory", "/a/b",
"class", "AppKitDoctrineDatabase",
);
"{/usr/share/icinga-web/app/config/databases.xml}/contents" = dict("icinga_db", ICDB, "icinga_web_db", ICDB);
"{/var/kerberos/krb5kdc/kadm5.acl}/contents/acls" = list();
"{/var/kerberos/krb5kdc/kdc.conf}/contents" = dict(
"defaults", dict(),
"realms", dict(),
);
# components
prefix "/software/components";
"afsclt" = dict("enabled", "yes", "thiscell", "cell");
"amandaserver" = dict("backups", dict(), "amandahosts", list());
"autofs/maps" = dict();
"chkconfig/service" = dict();
"dcache/config/jythonjavahome" = "some";
"dcache/config/node_config/node_type" = "type";
"dcache/config/dCacheSetup/serviceLocatorHost" = "a.bb";
"etcservices/entries" = list();
"freeipa" = dict("primary", "a.bb", "realm", "AB");
"gip2" = dict("user", "user", "basedir", "/a/b");
"glitestartup/services" = dict();
"globuscfg/globus_flavor_name" = "abc";
"gmetad" = dict("file", "/a/b", "data_source", list());
"gmond" = dict(
"globals", dict(),
"udp_send_channel", list(),
"udp_recv_channel", list(),
"tcp_accept_channel", list(),
"collection_group", list(),
"file", "/a/b",
);
"gpfs" = dict(
"base", dict("rpms", list(), "baseurl", "abc"),
"cfg", dict("url", "abc", "subnet", "abc"),
);
"gridmapdir" = dict("gridmapdir", "abc", "poolaccounts", dict());
"grub" = dict();
"hostsfile/entries" = dict();
"icinga" = dict(
"hosts", dict(),
"hosts_generic", dict(),
"hostgroups", dict(),
"hostdependencies", dict(),
"services", dict(),
"servicegroups", dict(),
"general", dict(),
"cgi", dict(),
"timeperiods", dict(),
"contacts", dict(),
"contactgroups", dict(),
"commands", dict("process-host-perfdata", "a", "process-service-perfdata", "b"),
"ido2db", dict(),
);
"interactivelimits/values" = list();
"ipmi" = dict("net_interface", "a", "users", list());
"lcas/dbpath" = "abc";
"lcgbdii/port" = 123;
"lcgmonjob" = dict("EDG_LOCATION", "abc", "LCG_LOCATION", "abc");
"lcmaps/config" = list();
"mkgridmap/entries" = dict();
"modprobe/modules/0/name" = "abc";
"mysql/servers" = dict();
"nagios" = dict(
"hosts", dict(),
"services", dict(),
"general", dict(),
"timeperiods", dict(),
"contacts", dict(),
"contactgroups", dict(),
"commands", dict("process-host-perfdata", "a", "process-service-perfdata", "b"),
);
"nrpe/options" = dict("allowed_hosts", list(), "command", dict());
"nss/databases" = dict();
"ofed/openib/hardware/mlx4" = true;
"openldap" = dict(
"include_schema", list(),
"database", "abc",
"suffix", "abc",
"rootdn", "abc",
"rootpw", "abc",
"directory", "abc",
);
"pbsclient/masters" = list();
"pnp4nagios" = dict(
"npcd", dict(),
"php", dict(),
"perfdata", dict(),
"nagios", dict(),
);
"postfix" = dict("master", list(), "main", dict());
"resolver/servers" = list();
"syslog/config" = list();
"syslogng" = dict(
"options", dict("use_dns", "yes"),
"sources", dict(),
"destinations", dict(),
"log_rules", list(),
);
"useraccess/users" = dict();
"wlconfig/networkServer/iiHost" = "a.bb";
"xrootd/hosts" = dict();
"xrootd/options" = dict(
"authzLibraries", list(),
"daemonUser", "abc",
"daemonGroup", "abc",
);
EOF
# for quattor/client/rpms
mkdir -p build_temp/rpms
cat > build_temp/rpms/package_default_versions.pan <<EOF
unique template rpms/package_default_versions;
#variable OS_VERSION_PARAMS already set
EOF
# for quattor/server/rpms
cat > build_temp/rpms/web_server.pan <<EOF
unique template rpms/web_server;
EOF
# make one big test.pan
find pan -type f ! -regex '^./build_temp/.*' -name *.pan | grep -v yumng | xargs sed -n "s/^declaration[ ]\+template[ ]\+\(.*\);/include '\1';/p" | sort >> build_temp/test.pan
find . -type f ! -regex '^./pan/.*' ! -regex '^./build_temp/.*' -name *.pan | grep -v yumng | xargs sed -n "s/^declaration[ ]\+template[ ]\+\(.*\);/include '\1';/p" | sort >> build_temp/test.pan
find . -type f ! -regex '^./build_temp/.*' -name *.pan | grep -v yumng | xargs sed -n "s/^\(unique[ ]\+\)\?template[ ]\+\(.*\);/include '\2';/p" |sort >> build_temp/test.pan
# fix for multiversion metaconfig
sed -i '/.*metaconfig\/\(elasticsearch\|logstash\)\/.*_[0-9].*/d' build_temp/test.pan
# none-versioned ganesha templates are v1
sed -i "/.*metaconfig\/ganesha\/\(config\(_v1\)\?\|schema\)'/d" build_temp/test.pan
sed -i "/.*metaconfig\/ganesha\/fsal.*/d" build_temp/test.pan
# only spma yum
sed -i "/.*components\/spma\/\(apt\|ips\).*/d" build_temp/test.pan
# try to compile it
output=`panc --output-dir build_temp --include-path .:build_temp build_temp/test.pan 2>&1`
# use "$output" to preserve newlines in echo
# if it fails, it's sort of ok when due to bind problems because there's no actual data
ec=$?
if [ $ec -eq 0 ]; then
echo "$output"
echo "[OK] Pan compilation success."
else
echo "$output" | grep 'element does not exist' >& /dev/null
if [ $? -eq 0 ]; then
echo "$output" | grep 'bound to type' >& /dev/null
if [ $? -eq 0 ]; then
echo "$output"
echo "[OK] expected panc failure due to missing data."
ec=0
fi
fi
fi
if [ $ec -ne 0 ]; then
echo "$output"
echo "[ERROR] Pan compilation failed"
fi
exit $ec