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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: Copyright (c) 2017 Enea AB and others.
:
: All rights reserved. This program and the accompanying materials
: are made available under the terms of the Apache License, Version 2.0
: which accompanies this distribution, and is available at
: http://www.apache.org/licenses/LICENSE-2.0
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Date: Tue, 21 Mar 2017 18:01:31 +0100
Subject: [PATCH 2/2] Revert "Remove cobbler and use dhcpd named and tftp"
This reverts commit 0b5ab4ff80414adad996012b9152de0719888274.
---
deployment/puppet/fuel/examples/cobbler.pp | 79 ++++++++++++-
deployment/puppet/fuel/examples/deploy.sh | 2 +-
deployment/puppet/fuel/examples/dhcp-ranges.pp | 26 +++--
deployment/puppet/fuel/examples/hiera.pp | 9 --
deployment/puppet/fuel/examples/host.pp | 2 +-
deployment/puppet/fuel/examples/provision.pp | 99 ----------------
.../parser/functions/create_dnsmasq_dhcp_ranges.rb | 47 ++++++++
.../lib/puppet/parser/functions/get_dhcp_ranges.rb | 46 --------
.../get_merged_network_metadata_from_yamls.rb | 20 ----
deployment/puppet/fuel/manifests/cobbler.pp | 130 +++++++++++++++++++++
.../puppet/fuel/manifests/dnsmasq/dhcp_range.pp | 29 +++++
deployment/puppet/fuel/manifests/iptables.pp | 3 +-
.../functions/create_dnsmasq_dhcp_ranges_spec.rb | 70 +++++++++++
deployment/puppet/fuel/templates/dhclient.conf.erb | 2 +-
deployment/puppet/fuel/templates/dhcpd_ranges.erb | 21 ----
.../puppet/fuel/templates/dnsmasq.dhcp-range.erb | 7 ++
deployment/puppet/fuel/templates/provision.yaml | 8 --
deployment/puppet/fuel/templates/resolv.conf.erb | 4 +-
.../manifests/provision/build_image.pp | 22 ++--
.../lib/puppet/parser/functions/tftp_files.rb | 22 ----
deployment/puppet/provision/manifests/dhcpd.pp | 54 ---------
deployment/puppet/provision/manifests/iptables.pp | 28 -----
deployment/puppet/provision/manifests/named.pp | 51 --------
deployment/puppet/provision/manifests/params.pp | 36 ------
deployment/puppet/provision/manifests/tftp.pp | 95 ---------------
.../puppet/provision/templates/dhcpd.conf.erb | 69 -----------
.../puppet/provision/templates/named.conf.erb | 32 -----
.../puppet/provision/templates/tftp.chain32.erb | 8 --
.../puppet/provision/templates/tftp.default.erb | 19 ---
.../puppet/provision/templates/tftp.xinetd.erb | 13 ---
.../puppet/provision/templates/xinetd.conf.erb | 17 ---
deployment/puppet/provision/templates/zone.erb | 11 --
graphs/provision/tasks.yaml | 43 ++++---
tests/noop/spec/hosts/master/cobbler_spec.rb | 79 +++++++++++++
tests/noop/spec/hosts/master/dhcp-ranges_spec.rb | 17 +++
tests/noop/spec/hosts/master/host_spec.rb | 2 +
36 files changed, 527 insertions(+), 695 deletions(-)
mode change 120000 => 100644 deployment/puppet/fuel/examples/cobbler.pp
delete mode 100644 deployment/puppet/fuel/examples/provision.pp
create mode 100644 deployment/puppet/fuel/lib/puppet/parser/functions/create_dnsmasq_dhcp_ranges.rb
delete mode 100644 deployment/puppet/fuel/lib/puppet/parser/functions/get_dhcp_ranges.rb
delete mode 100644 deployment/puppet/fuel/lib/puppet/parser/functions/get_merged_network_metadata_from_yamls.rb
create mode 100644 deployment/puppet/fuel/manifests/cobbler.pp
create mode 100644 deployment/puppet/fuel/manifests/dnsmasq/dhcp_range.pp
create mode 100644 deployment/puppet/fuel/spec/functions/create_dnsmasq_dhcp_ranges_spec.rb
delete mode 100644 deployment/puppet/fuel/templates/dhcpd_ranges.erb
create mode 100644 deployment/puppet/fuel/templates/dnsmasq.dhcp-range.erb
delete mode 100644 deployment/puppet/fuel/templates/provision.yaml
delete mode 100644 deployment/puppet/provision/lib/puppet/parser/functions/tftp_files.rb
delete mode 100644 deployment/puppet/provision/manifests/dhcpd.pp
delete mode 100644 deployment/puppet/provision/manifests/iptables.pp
delete mode 100644 deployment/puppet/provision/manifests/named.pp
delete mode 100644 deployment/puppet/provision/manifests/params.pp
delete mode 100644 deployment/puppet/provision/manifests/tftp.pp
delete mode 100644 deployment/puppet/provision/templates/dhcpd.conf.erb
delete mode 100644 deployment/puppet/provision/templates/named.conf.erb
delete mode 100644 deployment/puppet/provision/templates/tftp.chain32.erb
delete mode 100644 deployment/puppet/provision/templates/tftp.default.erb
delete mode 100644 deployment/puppet/provision/templates/tftp.xinetd.erb
delete mode 100644 deployment/puppet/provision/templates/xinetd.conf.erb
delete mode 100644 deployment/puppet/provision/templates/zone.erb
create mode 100644 tests/noop/spec/hosts/master/cobbler_spec.rb
create mode 100644 tests/noop/spec/hosts/master/dhcp-ranges_spec.rb
diff --git a/deployment/puppet/fuel/examples/cobbler.pp b/deployment/puppet/fuel/examples/cobbler.pp
deleted file mode 120000
index c48bab0..0000000
--- a/deployment/puppet/fuel/examples/cobbler.pp
+++ /dev/null
@@ -1 +0,0 @@
-provision.pp
\ No newline at end of file
diff --git a/deployment/puppet/fuel/examples/cobbler.pp b/deployment/puppet/fuel/examples/cobbler.pp
new file mode 100644
index 0000000..d409689
--- /dev/null
+++ b/deployment/puppet/fuel/examples/cobbler.pp
@@ -0,0 +1,78 @@
+notice('MODULAR: cobbler.pp')
+
+Exec {path => '/usr/bin:/bin:/usr/sbin:/sbin'}
+
+$fuel_settings = parseyaml($astute_settings_yaml)
+$admin_network = $::fuel_settings['ADMIN_NETWORK']
+$nailgun_api_url = "http://${::fuel_settings['ADMIN_NETWORK']['ipaddress']}:8000/api"
+$bootstrap_settings = pick($::fuel_settings['BOOTSTRAP'], {})
+$bootstrap_path = pick($bootstrap_settings['path'], '/var/www/nailgun/bootstraps/active_bootstrap')
+$bootstrap_ethdevice_timeout = pick($bootstrap_settings['ethdevice_timeout'], '120')
+$dhcp_gw = $::fuel_settings['ADMIN_NETWORK']['dhcp_gateway']
+$dns_domain = $::fuel_settings['DNS_DOMAIN']
+$dns_search = $::fuel_settings['DNS_SEARCH']
+$dns_upstream = split($::fuel_settings['DNS_UPSTREAM'], ',')
+$cobbler_host = $::fuel_settings['ADMIN_NETWORK']['ipaddress']
+
+# TODO(mmalchuk): the right way with updated loadyaml function
+# $bootstrap_meta = loadyaml("${bootstrap_path}/metadata.yaml", {})
+# and remove if else block
+$metadata_yaml = file("${bootstrap_path}/metadata.yaml", '/dev/null')
+if empty($metadata_yaml) {
+ $bootstrap_meta = {}
+} else {
+ $bootstrap_meta = parseyaml($metadata_yaml)
+}
+
+if $dhcp_gw {
+ $dhcp_gateway = $dhcp_gw
+}
+else {
+ $dhcp_gateway = $cobbler_host
+}
+
+class { '::fuel::cobbler':
+ cobbler_user => $::fuel_settings['cobbler']['user'],
+ cobbler_password => $::fuel_settings['cobbler']['password'],
+ bootstrap_path => $bootstrap_path,
+ bootstrap_meta => $bootstrap_meta,
+ server => $::fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ name_server => $::fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ next_server => $::fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ mco_user => $::fuel_settings['mcollective']['user'],
+ mco_pass => $::fuel_settings['mcollective']['password'],
+ dns_upstream => $dns_upstream,
+ dns_domain => $dns_domain,
+ dns_search => $dns_search,
+ dhcp_ipaddress => $::fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ nailgun_api_url => $nailgun_api_url,
+ bootstrap_ethdevice_timeout => $bootstrap_ethdevice_timeout,
+} ->
+
+file { '/etc/resolv.conf':
+ content => template('fuel/resolv.conf.erb'),
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+}
+
+Fuel::Systemd {
+ start => true,
+ template_path => 'fuel/systemd/restart_template.erb',
+ config_name => 'restart.conf',
+ service_manage => false,
+}
+
+fuel::systemd { ['httpd', 'cobblerd', 'xinetd'] :}
+
+fuel::systemd { 'dnsmasq': template_path => 'fuel/systemd/dnsmasq_template.erb' }
+
+fuel::dnsmasq::dhcp_range {'default':
+ dhcp_start_address => $admin_network['dhcp_pool_start'],
+ dhcp_end_address => $admin_network['dhcp_pool_end'],
+ dhcp_netmask => $admin_network['netmask'],
+ dhcp_gateway => $admin_network['dhcp_gateway'],
+ next_server => $admin_network['ipaddress'],
+ listen_address => $admin_network['ipaddress'],
+ notify => Service['dnsmasq'],
+}
diff --git a/deployment/puppet/fuel/examples/deploy.sh b/deployment/puppet/fuel/examples/deploy.sh
index c1b7494..afff4af 100755
--- a/deployment/puppet/fuel/examples/deploy.sh
+++ b/deployment/puppet/fuel/examples/deploy.sh
@@ -17,7 +17,7 @@
TASKS="
hiera
host
-provision
+cobbler
postgresql
rabbitmq
mcollective
diff --git a/deployment/puppet/fuel/examples/dhcp-ranges.pp b/deployment/puppet/fuel/examples/dhcp-ranges.pp
index 1209207..7420e1b 100644
--- a/deployment/puppet/fuel/examples/dhcp-ranges.pp
+++ b/deployment/puppet/fuel/examples/dhcp-ranges.pp
@@ -1,12 +1,20 @@
notice('MODULAR: dhcp-ranges.pp')
-$admin_network = hiera('ADMIN_NETWORK')
-$next_server = $admin_network['ipaddress']
-$domain_name = hiera('DNS_DOMAIN')
-$dns_address = $admin_network['ipaddress']
-$dhcp_ranges = get_dhcp_ranges(hiera('admin_networks', [{}]))
-
-file { $::provision::params::dhcpd_conf_extra :
- ensure => present,
- content => template('fuel/dhcpd_ranges.erb'),
+$admin_networks = hiera('admin_networks', [{}])
+$admin_network = hiera('ADMIN_NETWORK')
+
+Fuel::Dnsmasq::Dhcp_range <||> {
+ next_server => $admin_network['ipaddress'],
+}
+
+# Ensure dir with purge and recurse to remove configs for
+# non-existing (removed) nodegroups and ip ranges
+file { '/etc/dnsmasq.d':
+ ensure => 'directory',
+ recurse => true,
+ purge => true,
}
+
+# Create admin networks dhcp-range files except for 'default' nodegroup
+# by creating Fuel::Dnsmasq::Dhcp_range puppet resources
+create_dnsmasq_dhcp_ranges($admin_networks)
diff --git a/deployment/puppet/fuel/examples/hiera.pp b/deployment/puppet/fuel/examples/hiera.pp
index 58bae50..ca228ae 100644
--- a/deployment/puppet/fuel/examples/hiera.pp
+++ b/deployment/puppet/fuel/examples/hiera.pp
@@ -6,15 +6,12 @@ $data = [
'nodes',
'networks',
'astute',
- 'known_hosts',
- 'provision',
'common',
]
$astute_data_file = '/etc/fuel/astute.yaml'
$hiera_main_config = '/etc/hiera.yaml'
$hiera_puppet_config = '/etc/puppet/hiera.yaml'
$hiera_data_file = "${data_dir}/astute.yaml"
-$hiera_data_provision = "${data_dir}/provision.yaml"
File {
owner => 'root',
@@ -43,12 +40,6 @@ file { 'hiera_data_astute' :
target => $astute_data_file,
}
-file { 'hiera_data_provision' :
- ensure => present,
- path => $hiera_data_provision,
- content => template('fuel/provision.yaml'),
-}
-
file { 'hiera_puppet_config' :
ensure => 'symlink',
path => $hiera_puppet_config,
diff --git a/deployment/puppet/fuel/examples/host.pp b/deployment/puppet/fuel/examples/host.pp
index f94d642..f5cfac4 100644
--- a/deployment/puppet/fuel/examples/host.pp
+++ b/deployment/puppet/fuel/examples/host.pp
@@ -9,7 +9,7 @@ $ntp_servers = delete(delete_undef_values([$::fuel_settings['NTP1'],
$::fuel_settings['NTP2'], $::fuel_settings['NTP3']]), '')
# Vars for File['/etc/dhcp/dhclient.conf']
-$dns_address = $::fuel_settings['ADMIN_NETWORK']['ipaddress']
+$cobbler_host = $::fuel_settings['ADMIN_NETWORK']['ipaddress']
# Vars for File['/etc/fuel-utils/config']
$admin_ip = $::fuel_settings['ADMIN_NETWORK']['ipaddress']
diff --git a/deployment/puppet/fuel/examples/provision.pp b/deployment/puppet/fuel/examples/provision.pp
deleted file mode 100644
index 9b2aa26..0000000
--- a/deployment/puppet/fuel/examples/provision.pp
+++ /dev/null
@@ -1,99 +0,0 @@
-notice('MODULAR: provision.pp')
-
-Exec {path => '/usr/bin:/bin:/usr/sbin:/sbin'}
-
-$fuel_settings = parseyaml($astute_settings_yaml)
-
-$mco_user = $::fuel_settings['mcollective']['user']
-$mco_pass = $::fuel_settings['mcollective']['password']
-$dns_address = $::fuel_settings['ADMIN_NETWORK']['ipaddress']
-$domain_name = $::fuel_settings['DNS_DOMAIN']
-$dns_search = $::fuel_settings['DNS_SEARCH']
-$forwarders = split($::fuel_settings['DNS_UPSTREAM'], ',')
-$start_address = $::fuel_settings['ADMIN_NETWORK']['dhcp_pool_start']
-$end_address = $::fuel_settings['ADMIN_NETWORK']['dhcp_pool_end']
-$network_mask = $::fuel_settings['ADMIN_NETWORK']['netmask']
-$network_address = ipcalc_network_by_address_netmask($start_address, $network_mask)
-$dhcp_gateway = $::fuel_settings['ADMIN_NETWORK']['dhcp_gateway']
-if $dhcp_gateway {
- $router = $dhcp_gateway
-}
-else {
- $router = $::fuel_settings['ADMIN_NETWORK']['ipaddress']
-}
-
-$next_server = $::fuel_settings['ADMIN_NETWORK']['ipaddress']
-
-$nailgun_api_url = "http://${::fuel_settings['ADMIN_NETWORK']['ipaddress']}:8000/api"
-$ethdevice_timeout = hiera('ethdevice_timeout', '120')
-
-$ddns_key = hiera('ddns_key', 'VyCWe0kutrawqQ2WEFKkAw=')
-$ddns_key_algorithm = hiera('ddns_key_algorithm', 'HMAC-MD5')
-$ddns_key_name = hiera('ddns_key_name', 'DHCP_UPDATE')
-
-$bootstrap_menu_label = hiera('bootstrap_menu_label', 'bootstrap')
-$bootstrap_kernel_path = hiera('bootstrap_kernel_path', '/images/vmlinuz')
-$bootstrap_initrd_path = hiera('bootstrap_initrd_path', '/images/initrd.img')
-
-$bootstrap_settings = pick($::fuel_settings['BOOTSTRAP'], {})
-$bootstrap_path = pick($bootstrap_settings['path'], '/var/www/nailgun/bootstraps/active_bootstrap')
-$metadata_yaml = file("${bootstrap_path}/metadata.yaml", '/dev/null')
-if empty($metadata_yaml) {
- $bootstrap_meta = {}
-} else {
- $bootstrap_meta = parseyaml($metadata_yaml)
-}
-
-$bootstrap_kernel_params = extend_kopts($bootstrap_meta['extend_kopts'], "console=ttyS0,9600 console=tty0 panic=60 ethdevice-timeout=${ethdevice_timeout} boot=live toram components fetch=http://${next_server}:8080/bootstraps/active_bootstrap/root.squashfs biosdevname=0 url=${nailgun_api_url} mco_user=${mco_user} mco_pass=${mco_pass} ip=frommedia")
-
-
-$known_hosts = get_merged_network_metadata_from_yamls()
-$chain32_files = tftp_files("/var/lib/tftpboot/pxelinux.cfg", $known_hosts)
-
-class { "::provision::dhcpd" :
- network_address => ipcalc_network_by_address_netmask($start_address, $network_mask),
- network_mask => $network_mask,
- broadcast_address => $broadcast_address,
- start_address => $start_address,
- end_address => $end_address,
- router => $router,
- next_server => $next_server,
- dns_address => $dns_address,
- domain_name => $domain_name,
- ddns_key => $ddns_key,
- ddns_key_algorithm => $ddns_key_algorithm,
- ddns_key_name => $ddns_key_name,
- known_hosts => $known_hosts,
-}
-
-class { "::provision::tftp" :
- bootstrap_menu_label => $bootstrap_menu_label,
- bootstrap_kernel_path => $bootstrap_kernel_path,
- bootstrap_initrd_path => $bootstrap_initrd_path,
- bootstrap_kernel_params => $bootstrap_kernel_params,
- chain32_files => $chain32_files,
-} ->
-
-file { "/var/lib/tftpboot${bootstrap_kernel_path}" :
- source => "${bootstrap_path}/vmlinuz",
-} ->
-
-file { "/var/lib/tftpboot${bootstrap_initrd_path}" :
- source => "${bootstrap_path}/initrd.img"
-}
-
-class { "::provision::named" :
- domain_name => $domain_name,
- dns_address => $dns_address,
- forwarders => $forwarders,
- ddns_key => $ddns_key,
- ddns_key_algorithm => $ddns_key_algorithm,
- ddns_key_name => $ddns_key_name,
-} ->
-
-file { '/etc/resolv.conf':
- content => template('fuel/resolv.conf.erb'),
- owner => 'root',
- group => 'root',
- mode => '0644',
-}
diff --git a/deployment/puppet/fuel/lib/puppet/parser/functions/create_dnsmasq_dhcp_ranges.rb b/deployment/puppet/fuel/lib/puppet/parser/functions/create_dnsmasq_dhcp_ranges.rb
new file mode 100644
index 0000000..a43ba51
--- /dev/null
+++ b/deployment/puppet/fuel/lib/puppet/parser/functions/create_dnsmasq_dhcp_ranges.rb
@@ -0,0 +1,47 @@
+require 'ipaddr'
+require 'zlib'
+
+module Puppet::Parser::Functions
+ newfunction(:create_dnsmasq_dhcp_ranges, :doc => <<-EOS
+Creates fuel::dnsmasq::dhcp_range puppet resources from list of admin networks.
+ EOS
+) do |args|
+ admin_nets = args[0]
+ unless admin_nets.is_a?(Array) and admin_nets[0].is_a?(Hash)
+ raise(Puppet::ParseError, 'Should pass list of hashes as a parameter')
+ end
+ admin_nets.each do |net|
+ next unless net['ip_ranges'].is_a? Array
+ net['ip_ranges'].each do |ip_range|
+ # loop through local facts to pull which interface has an IP in the
+ # dhcp range so we can properly listen on the interface for dhcp
+ # messages
+ cidr = IPAddr.new(net['cidr'])
+ listen_address = []
+ interfaces = lookupvar('interfaces')
+ if ! interfaces.nil?
+ interfaces.split(',').each do |interface|
+ local_address = lookupvar("ipaddress_#{interface}")
+ listen_address.push(local_address) if cidr.include?(local_address)
+ end
+ end
+ netmask = IPAddr.new('255.255.255.255').mask(net['cidr'].split('/')[1]).to_s
+ print_range = ip_range.join('_')
+ resource_name = sprintf("range_%08x", Zlib::crc32("#{print_range}_#{net['cidr']}").to_i)
+ range_comment = "# Environment: #{net['cluster_name']}\n# Nodegroup: #{net['node_group_name']}\n# IP range: #{ip_range}"
+ dhcp_range_resource = {
+ resource_name => {
+ 'file_header' => "# Generated automatically by puppet\n#{range_comment}",
+ 'listen_address' => listen_address.join(','),
+ 'dhcp_start_address' => ip_range[0],
+ 'dhcp_end_address' => ip_range[1],
+ 'dhcp_netmask' => netmask,
+ 'dhcp_gateway' => net['gateway'],
+ }
+ }
+ debug("Trying to create fuel::dnsmasq::dhcp_range resource: #{dhcp_range_resource.inspect}")
+ function_create_resources(['fuel::dnsmasq::dhcp_range', dhcp_range_resource])
+ end
+ end
+ end
+end
diff --git a/deployment/puppet/fuel/lib/puppet/parser/functions/get_dhcp_ranges.rb b/deployment/puppet/fuel/lib/puppet/parser/functions/get_dhcp_ranges.rb
deleted file mode 100644
index 574ae78..0000000
--- a/deployment/puppet/fuel/lib/puppet/parser/functions/get_dhcp_ranges.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-require 'ipaddr'
-
-module Puppet::Parser::Functions
- newfunction(:get_dhcp_ranges, :doc => <<-EOS
-Returns a list of dhcp ranges from a list of admin networks.
- EOS
-) do |args|
- admin_nets = args[0]
- unless admin_nets.is_a?(Array) and admin_nets[0].is_a?(Hash)
- raise(Puppet::ParseError, 'Should pass list of hashes as a parameter')
- end
- dhcp_ranges = []
- admin_nets.each do |net|
- next unless net['ip_ranges'].is_a? Array
- net['ip_ranges'].each do |ip_range|
- # loop through local facts to pull which interface has an IP in the
- # dhcp range so we can properly listen on the interface for dhcp
- # messages
- cidr = IPAddr.new(net['cidr'])
- listen_address = []
- interfaces = lookupvar('interfaces')
- if ! interfaces.nil?
- interfaces.split(',').each do |interface|
- local_address = lookupvar("ipaddress_#{interface}")
- listen_address.push(local_address) if cidr.include?(local_address)
- end
- end
- netmask = IPAddr.new('255.255.255.255').mask(net['cidr'].split('/')[1]).to_s
- range_comment = "# Environment: #{net['cluster_name']}\n# Nodegroup: #{net['node_group_name']}\n# IP range: #{ip_range}"
- dhcp_range = {
- 'comment' => range_comment,
- 'listen_address' => listen_address.join(','),
- 'start_address' => ip_range[0],
- 'end_address' => ip_range[1],
- 'netaddr' => cidr.to_s,
- 'netmask' => netmask,
- 'broadcast' => cidr.to_range.to_a[-1].to_s,
- 'gateway' => net['gateway'],
- }
- debug("Appending dhcp range to the list of ranges: #{dhcp_range.inspect}")
- dhcp_ranges << dhcp_range
- end
- end
- dhcp_ranges
- end
-end
diff --git a/deployment/puppet/fuel/lib/puppet/parser/functions/get_merged_network_metadata_from_yamls.rb b/deployment/puppet/fuel/lib/puppet/parser/functions/get_merged_network_metadata_from_yamls.rb
deleted file mode 100644
index 91028c6..0000000
--- a/deployment/puppet/fuel/lib/puppet/parser/functions/get_merged_network_metadata_from_yamls.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-module Puppet::Parser::Functions
- newfunction(:get_merged_network_metadata_from_yamls, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
-Load a provision data from a set of YAML files for a set of cluster
-located in /var/lib/fuel/configs/{CLUSTER_ID}/provision.yaml
-
- ENDHEREDOC
- require 'yaml'
- merged_data = {}
- Dir["/var/lib/fuel/configs/*/provision.yaml"].each do |f|
- begin
- data = YAML::load_file(f) || {}
- rescue Exception => e
- warning("Found file #{f} but could not parse it")
- data = {}
- end
- merged_data.merge!(data['network_metadata']['nodes'])
- end
- merged_data
- end
-end
diff --git a/deployment/puppet/fuel/manifests/cobbler.pp b/deployment/puppet/fuel/manifests/cobbler.pp
new file mode 100644
index 0000000..ea312da
--- /dev/null
+++ b/deployment/puppet/fuel/manifests/cobbler.pp
@@ -0,0 +1,130 @@
+class fuel::cobbler(
+ $repo_root = $::fuel::params::repo_root,
+ $cobbler_user = $::fuel::params::cobbler_user,
+ $cobbler_password = $::fuel::params::cobbler_password,
+ $bootstrap_path,
+ $bootstrap_meta,
+ # network interface configuration timeout (in seconds)
+ $bootstrap_ethdevice_timeout = $::fuel::params::bootstrap_ethdevice_timeout,
+ $bootstrap_profile = $::fuel::params::bootstrap_profile,
+ $centos_repos = $::fuel::params::centos_repos,
+ $ks_system_timezone = $::fuel::params::ks_system_timezone,
+ $server = $::fuel::params::cobbler_host,
+ $name_server = $::fuel::params::cobbler_host,
+ $next_server = $::fuel::params::cobbler_host,
+ $dns_upstream = $::fuel::params::dns_upstream,
+ $dns_domain = $::fuel::params::dns_domain,
+ $dns_search = $::fuel::params::dns_search,
+ $mco_user = $::fuel::params::mco_user,
+ $mco_pass = $::fuel::params::mco_password,
+ $dhcp_ipaddress = $::fuel::params::dhcp_ipaddress,
+ $nailgun_api_url = "http://${::fuel::params::nailgun_host}:${::fuel::params::nailgun_port}/api",
+ # default password is 'r00tme'
+ $ks_encrypted_root_password = $::fuel::params::ks_encrypted_root_password,
+ ) inherits fuel::params {
+
+ anchor { 'nailgun-cobbler-begin': }
+ anchor { 'nailgun-cobbler-end': }
+
+ Anchor<| title == 'nailgun-cobbler-begin' |> ->
+ Class['::cobbler'] ->
+ Anchor<| title == 'nailgun-cobbler-end' |>
+
+ $real_server = $next_server
+
+ $fence_ssh_source = 'puppet:///modules/fuel/cobbler/fence_ssh.centos7.py'
+
+ class { '::cobbler':
+ server => $server,
+ domain_name => $domain_name,
+ dns_upstream => $dns_upstream,
+ dns_domain => $dns_domain,
+ dns_search => $dns_search,
+ name_server => $name_server,
+ next_server => $next_server,
+ dhcp_ipaddress => $dhcp_ipaddress,
+ cobbler_user => $cobbler_user,
+ cobbler_password => $cobbler_password,
+ pxetimeout => '50'
+ }
+
+ file { '/etc/cobbler/power/fence_ssh.template':
+ content => template('fuel/cobbler/fence_ssh.template.erb'),
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ require => Class['::cobbler::server'],
+ }
+
+ file { '/usr/sbin/fence_ssh':
+ source => $fence_ssh_source,
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ require => Class['::cobbler::server'],
+ }
+
+ cobbler_distro { 'ubuntu_bootstrap':
+ kernel => "${bootstrap_path}/vmlinuz",
+ initrd => "${bootstrap_path}/initrd.img",
+ arch => 'x86_64',
+ breed => 'ubuntu',
+ osversion => 'xenial',
+ ksmeta => '',
+ require => Class['::cobbler::server'],
+ }
+
+ cobbler_profile { 'ubuntu_bootstrap':
+ distro => 'ubuntu_bootstrap',
+ menu => true,
+ kickstart => '',
+ kopts => extend_kopts($bootstrap_meta['extend_kopts'], "console=ttyS0,9600 console=tty0 panic=60 ethdevice-timeout=${bootstrap_ethdevice_timeout} boot=live toram components fetch=http://${server}:8080/bootstraps/active_bootstrap/root.squashfs biosdevname=0 url=${nailgun_api_url} mco_user=${mco_user} mco_pass=${mco_pass} ip=frommedia"),
+ ksmeta => '',
+ server => $real_server,
+ require => Cobbler_distro['ubuntu_bootstrap'],
+ }
+
+ exec { 'cobbler_system_add_default':
+ command => "cobbler system add --name=default \
+ --profile=${bootstrap_profile} --netboot-enabled=True",
+ onlyif => 'test -z `cobbler system find --name=default`',
+ require => Cobbler_profile[$bootstrap_profile],
+ }
+
+ exec { 'cobbler_system_edit_default':
+ command => "cobbler system edit --name=default \
+ --profile=${bootstrap_profile} --netboot-enabled=True",
+ unless => "cobbler system report --name default 2>/dev/null | grep -q -E '^Profile\\s*:\\s*${bootstrap_profile}'",
+ require => Cobbler_profile[$bootstrap_profile],
+ }
+
+ exec { 'nailgun_cobbler_sync':
+ command => 'cobbler sync',
+ refreshonly => true,
+ }
+
+ Exec['cobbler_system_add_default'] ~> Exec['nailgun_cobbler_sync']
+ Exec['cobbler_system_edit_default'] ~> Exec['nailgun_cobbler_sync']
+ Cobbler_profile<| |> ~> Exec['nailgun_cobbler_sync']
+
+ #FIXME(mattymo): move pubkey to astute fact or download it
+ exec { 'cp /root/.ssh/id_rsa.pub /etc/cobbler/authorized_keys':
+ command => 'cp /root/.ssh/id_rsa.pub /etc/cobbler/authorized_keys',
+ creates => '/etc/cobbler/authorized_keys',
+ require => Class['::cobbler::server'],
+ }
+
+ file { '/etc/dnsmasq.conf':
+ ensure => link,
+ target => '/etc/cobbler.dnsmasq.conf',
+ }
+
+ file { ['/var/log/cobbler/anamon',
+ '/var/log/cobbler/kicklog',
+ '/var/log/cobbler/syslog',
+ '/var/log/cobbler/tasks'] :
+ ensure => directory,
+ require => Class['::cobbler::server'],
+ }
+
+}
diff --git a/deployment/puppet/fuel/manifests/dnsmasq/dhcp_range.pp b/deployment/puppet/fuel/manifests/dnsmasq/dhcp_range.pp
new file mode 100644
index 0000000..a60bac5
--- /dev/null
+++ b/deployment/puppet/fuel/manifests/dnsmasq/dhcp_range.pp
@@ -0,0 +1,29 @@
+#
+# fuel::dnsmasq::dhcp_range creates config files in /etc/dnsmasq.d/
+#
+# [next_server] IP address that will be used as PXE tftp server
+# [dhcp_start_address] First address of dhcp range
+# [dhcp_end_address] Last address of dhcp range
+# [dhcp_netmask] Netmask of the network
+# [dhcp_gateway] Gateway address for installed nodes
+# [lease_time] DHCP lease time
+# [file_header] File header for comments
+
+define fuel::dnsmasq::dhcp_range(
+ $dhcp_start_address = '10.0.0.201',
+ $dhcp_end_address = '10.0.0.254',
+ $dhcp_netmask = '255.255.255.0',
+ $dhcp_gateway = $::ipaddress,
+ $listen_address = $::ipaddress,
+ $file_header = undef,
+ $lease_time = '120m',
+ $next_server = $::ipaddress,
+){
+ $range_name = $name
+ file { "/etc/dnsmasq.d/${name}.conf":
+ content => template('fuel/dnsmasq.dhcp-range.erb'),
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ }
+}
diff --git a/deployment/puppet/fuel/manifests/iptables.pp b/deployment/puppet/fuel/manifests/iptables.pp
index b3ac965..fc0afb7 100644
--- a/deployment/puppet/fuel/manifests/iptables.pp
+++ b/deployment/puppet/fuel/manifests/iptables.pp
@@ -23,7 +23,8 @@ class fuel::iptables (
$chain = 'INPUT',
) inherits fuel::params {
- include ::provision::iptables
+ #Enable cobbler's iptables rules even if Cobbler not called
+ include ::cobbler::iptables
firewallchain { 'INPUT:filter:IPv4':
ensure => present,
diff --git a/deployment/puppet/fuel/spec/functions/create_dnsmasq_dhcp_ranges_spec.rb b/deployment/puppet/fuel/spec/functions/create_dnsmasq_dhcp_ranges_spec.rb
new file mode 100644
index 0000000..7158984
--- /dev/null
+++ b/deployment/puppet/fuel/spec/functions/create_dnsmasq_dhcp_ranges_spec.rb
@@ -0,0 +1,70 @@
+require 'spec_helper'
+
+describe 'create_dnsmasq_dhcp_ranges' do
+
+ let(:admin_networks) do
+ [
+ {"id" => 1,
+ "node_group_name" => nil,
+ "node_group_id" => nil,
+ "cluster_name" => nil,
+ "cluster_id" => nil,
+ "cidr" => "10.145.0.0/24",
+ "gateway" => "10.145.0.2",
+ "ip_ranges" => [["10.145.0.3", "10.145.0.250"]],
+ },
+ {"id" => 2,
+ "node_group_name" => "default2",
+ "node_group_id" => 22,
+ "cluster_name" => "default2",
+ "cluster_id" => 2,
+ "cidr" => "10.144.0.0/24",
+ "gateway" => "10.144.0.5",
+ "ip_ranges" => [["10.144.0.10", "10.144.0.254"]],
+ },
+ ]
+ end
+
+ let(:facts) do
+ {
+ :interfaces => 'docker0,enp0s3,enp0s4,enp0s5,lo',
+ :ipaddress_docker0 => '172.17.0.1',
+ :ipaddress_enp0s3 => '10.145.0.2',
+ :ipaddress_enp0s4 => '10.144.0.2',
+ }
+ end
+ let(:catalog) do
+ lambda { catalogue }
+ end
+
+ it 'refuses String' do
+ is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, /Should pass list of hashes as a parameter/)
+ end
+
+ it 'accepts empty data' do
+ is_expected.to run.with_params([{}])
+ end
+
+ it 'can create dnsmasq dhcp ranges' do
+ is_expected.to run.with_params(admin_networks)
+ parameters = {
+ :file_header=>"# Generated automatically by puppet\n# Environment: \n# Nodegroup: \n# IP range: [\"10.145.0.3\", \"10.145.0.250\"]",
+ :listen_address=>'10.145.0.2',
+ :dhcp_start_address=>"10.145.0.3",
+ :dhcp_end_address=>"10.145.0.250",
+ :dhcp_netmask=>"255.255.255.0",
+ :dhcp_gateway=>"10.145.0.2",
+ }
+ expect(catalog).to contain_fuel__dnsmasq__dhcp_range('range_6be3c888').with parameters
+ parameters = {
+ :file_header=>"# Generated automatically by puppet\n# Environment: default2\n# Nodegroup: default2\n# IP range: [\"10.144.0.10\", \"10.144.0.254\"]",
+ :listen_address=>'10.144.0.2',
+ :dhcp_start_address=>"10.144.0.10",
+ :dhcp_end_address=>"10.144.0.254",
+ :dhcp_netmask=>"255.255.255.0",
+ :dhcp_gateway=>"10.144.0.5",
+ }
+ expect(catalog).to contain_fuel__dnsmasq__dhcp_range('range_ff724fd0').with parameters
+ end
+
+end
diff --git a/deployment/puppet/fuel/templates/dhclient.conf.erb b/deployment/puppet/fuel/templates/dhclient.conf.erb
index 9b54550..d17616c 100644
--- a/deployment/puppet/fuel/templates/dhclient.conf.erb
+++ b/deployment/puppet/fuel/templates/dhclient.conf.erb
@@ -1 +1 @@
-prepend domain-name-servers <%= @dns_address %>;
+prepend domain-name-servers <%= @cobbler_host %>;
diff --git a/deployment/puppet/fuel/templates/dhcpd_ranges.erb b/deployment/puppet/fuel/templates/dhcpd_ranges.erb
deleted file mode 100644
index d455a95..0000000
--- a/deployment/puppet/fuel/templates/dhcpd_ranges.erb
+++ /dev/null
@@ -1,21 +0,0 @@
-<% @dhcp_ranges.each do |range| -%>
-
-# <%= range['comment'] %>
-subnet <%= range['netaddr'] %> netmask <%= range['netmask'] %> {
- range <%= range['start_address'] %> <%= range['end_address'] %>;
- option routers <%= range['gateway'] %>;
- option subnet-mask <%= range['netmask'] %>;
- option broadcast-address <%= range['broadcast'] %>;
- option domain-name-servers <%= @dns_address %>;
- option domain-name "<%= @domain_name %>";
- next-server <%= @next_server %>;
- default-lease-time 7200;
- max-lease-time 7200;
- ddns-hostname = concat("dhcp-",binary-to-ascii(10,8,"-", leased-address));
- class "pxeclients" {
- match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
- filename "pxelinux.0";
- }
-}
-
-<% end -%>
\ No newline at end of file
diff --git a/deployment/puppet/fuel/templates/dnsmasq.dhcp-range.erb b/deployment/puppet/fuel/templates/dnsmasq.dhcp-range.erb
new file mode 100644
index 0000000..aa41d20
--- /dev/null
+++ b/deployment/puppet/fuel/templates/dnsmasq.dhcp-range.erb
@@ -0,0 +1,7 @@
+<% if @file_header %><%= @file_header %><% end %>
+<% if @listen_address && !@listen_address.empty? %>listen-address=<%= @listen_address %><% end %>
+dhcp-range=<%= @range_name %>,<%= @dhcp_start_address %>,<%= @dhcp_end_address %>,<%= @dhcp_netmask %>,<%= @lease_time %>
+dhcp-option=net:<%= @range_name %>,option:router,<%= @dhcp_gateway %>
+dhcp-boot=net:<%= @range_name %>,pxelinux.0,boothost,<%= @next_server %>
+dhcp-match=set:ipxe,175
+dhcp-option-force=tag:ipxe,210,http://<%= @next_server %>/cobbler/boot/
diff --git a/deployment/puppet/fuel/templates/provision.yaml b/deployment/puppet/fuel/templates/provision.yaml
deleted file mode 100644
index 3d5d3c7..0000000
--- a/deployment/puppet/fuel/templates/provision.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-ddns_key: VyCWe0kutrawqQ2WEFKkAw==
-ddns_key_algorithm: HMAC-MD5
-ddns_key_name: DHCP_UPDATE
-bootstrap_menu_label: bootstrap
-bootstrap_kernel_path: /images/vmlinuz
-bootstrap_initrd_path: /images/initrd.img
-ethdevice_timeout: 120
diff --git a/deployment/puppet/fuel/templates/resolv.conf.erb b/deployment/puppet/fuel/templates/resolv.conf.erb
index ceb69d8..4e9541f 100644
--- a/deployment/puppet/fuel/templates/resolv.conf.erb
+++ b/deployment/puppet/fuel/templates/resolv.conf.erb
@@ -1,3 +1,3 @@
search <%= @dns_search %>
-domain <%= @domain_name %>
-nameserver <%= @dns_address %>
+domain <%= @dns_domain %>
+nameserver <%= @cobbler_host %>
diff --git a/deployment/puppet/osnailyfacter/manifests/provision/build_image.pp b/deployment/puppet/osnailyfacter/manifests/provision/build_image.pp
index 02fa0f0..3f90aec 100644
--- a/deployment/puppet/osnailyfacter/manifests/provision/build_image.pp
+++ b/deployment/puppet/osnailyfacter/manifests/provision/build_image.pp
@@ -1,7 +1,13 @@
-class osnailyfacter::provision::build_image {
+class osnailyfacter::provision::build_image(
+ $data_file = '/tmp/provision.yaml',
+){
- $data_file = "/var/lib/fuel/configs/${::cluster_id}/provision.yaml"
- $data = loadyaml($data_file)
+ if $data_file == undef {
+ $data = loadyaml('/tmp/provision.yaml')
+ } else {
+ $data = loadyaml($data_file)
+ }
+ $cluster_id = $data['cluster']['id']
if $data['ironic']['enabled'] == 'true' {
$ironic_packages = [
@@ -23,10 +29,10 @@ class osnailyfacter::provision::build_image {
]
$package_list = join(prefix($ironic_packages, '--package '), ' ')
- $ssh_auth_file = "/var/lib/fuel/keys/${::cluster_id}/ironic/ironic.pub"
+ $ssh_auth_file = "/var/lib/fuel/keys/${cluster_id}/ironic/ironic.pub"
$ssh_params = "--root-ssh-authorized-file ${ssh_auth_file}"
- $out_dir = "/var/www/nailgun/bootstrap/ironic/${::cluster_id}/"
+ $out_dir = "/var/www/nailgun/bootstrap/ironic/${cluster_id}/"
$out_params = "--output-dir ${out_dir}"
$extra_params = "--extra-dir /usr/share/ironic-fa-bootstrap-configs/ --no-compress --no-default-extra-dirs --no-default-packages"
@@ -35,19 +41,19 @@ class osnailyfacter::provision::build_image {
exec { 'generate_image_with_ironic':
command => "fuel-bootstrap build ${package_list} ${ssh_params} ${out_params} ${extra_params} ${log_params}",
path => ['/bin', '/usr/bin'],
- unless => "test -e /var/www/nailgun/bootstrap/ironic/${::cluster_id}/vmlinuz",
+ unless => "test -e /var/www/nailgun/bootstrap/ironic/${cluster_id}/vmlinuz",
}
} else {
$build_dir = '--image_build_dir /var/lib/fuel/ibp'
- $log_params = "--log-file /var/log/fuel-agent-env-${::cluster_id}.log"
+ $log_params = "--log-file /var/log/fuel-agent-env-${cluster_id}.log"
$extra_params = '--data_driver nailgun_build_image'
exec { 'generate_image_with_fuel':
command => "fa_build_image ${build_dir} ${log_params} ${extra_params} --input_data_file ${data_file}",
path => ['/bin', '/usr/bin'],
timeout => 1800,
- unless => "test -e /var/www/nailgun/bootstrap/ironic/${::cluster_id}/vmlinuz",
+ unless => "test -e /var/www/nailgun/bootstrap/ironic/${cluster_id}/vmlinuz",
}
}
}
diff --git a/deployment/puppet/provision/lib/puppet/parser/functions/tftp_files.rb b/deployment/puppet/provision/lib/puppet/parser/functions/tftp_files.rb
deleted file mode 100644
index e05a48b..0000000
--- a/deployment/puppet/provision/lib/puppet/parser/functions/tftp_files.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module Puppet::Parser::Functions
- newfunction(:tftp_files, :type => :rvalue) do |args|
- # args[0] is a path prefix, e.g. /var/lib/tftpboot/pxelinux.cfg
- # args[1] is a dict of hosts
- # node-1:
- # dhcp_binding_params:
- # name: node-1
- # mac:
- # - aa:bb:cc:dd:ee:ff
- # - 00:11:22:33:44:55
- # ip_address: 10.20.0.10
- # result is a list of file names
- # - /var/lib/tftpboot/pxelinux.cfg/01-aa-bb-cc-dd-ee-ff
- # - /var/lib/tftpboot/pxelinux.cfg/01-00-11-22-33-44-55
- files = []
- args[1].each {|host_name, host_data|
- mac = host_data["dhcp_binding_params"]["mac"]
- files << (args[0] + "/01-" + mac.gsub(":", "-"))
- }
- files
- end
-end
diff --git a/deployment/puppet/provision/manifests/dhcpd.pp b/deployment/puppet/provision/manifests/dhcpd.pp
deleted file mode 100644
index 6837532..0000000
--- a/deployment/puppet/provision/manifests/dhcpd.pp
+++ /dev/null
@@ -1,54 +0,0 @@
-class provision::dhcpd (
- $network_address = $::provision::params::network_address,
- $network_mask = $::provision::params::network_mask,
- $broadcast_address = $::provision::params::broadcast_address,
- $start_address = $::provision::params::start_address,
- $end_address = $::provision::params::end_address,
- $router = $::provision::params::router,
- $next_server = $::provision::params::next_server,
- $dns_address = $::provision::params::dns_address,
- $domain_name = $::provision::params::domain_name,
- $ddns_key = $::provision::params::ddns_key,
- $ddns_key_algorithm = $::provision::params::ddns_key_algorithm,
- $ddns_key_name = $::provision::params::ddns_key_name,
- $known_hosts = [],
-) inherits provision::params {
-
- package { "dhcpd" :
- name => $::provision::params::dhcpd_package,
- }
-
- file { $::provision::params::dhcpd_conf :
- ensure => present,
- content => template('provision/dhcpd.conf.erb'),
- owner => 'dhcpd',
- group => 'dhcpd',
- mode => '0640',
- require => Package["dhcpd"],
- notify => Service["dhcpd"],
- }
-
- file { $::provision::params::dhcpd_conf_d :
- ensure => directory,
- owner => 'root',
- group => 'root',
- mode => '0755',
- require => Package["dhcpd"],
- }
-
- # It is just a file that could be modified by other modules
- file { $::provision::params::dhcpd_conf_extra :
- ensure => present,
- require => File[$::provision::params::dhcpd_conf_d],
- }
-
- service { "dhcpd" :
- name => $::provision::params::dhcpd_service,
- ensure => running,
- enable => true,
- hasrestart => false,
- hasstatus => false,
- require => Package["dhcpd"],
- }
-
-}
diff --git a/deployment/puppet/provision/manifests/iptables.pp b/deployment/puppet/provision/manifests/iptables.pp
deleted file mode 100644
index f5aec5b..0000000
--- a/deployment/puppet/provision/manifests/iptables.pp
+++ /dev/null
@@ -1,28 +0,0 @@
-class provision::iptables {
-
- firewall { '101 dns_tcp':
- chain => INPUT,
- dport => '53',
- proto => 'tcp',
- action => 'accept',
- }
- firewall { '102 dns_udp':
- chain => INPUT,
- dport => '53',
- proto => 'udp',
- action => 'accept',
- }
- firewall { '103 dhcp':
- chain => INPUT,
- dport => ['67','68'],
- proto => 'udp',
- action => 'accept',
- }
- firewall { '104 tftp':
- chain => INPUT,
- dport => '69',
- proto => 'udp',
- action => 'accept',
- }
-
-}
diff --git a/deployment/puppet/provision/manifests/named.pp b/deployment/puppet/provision/manifests/named.pp
deleted file mode 100644
index ee940c9..0000000
--- a/deployment/puppet/provision/manifests/named.pp
+++ /dev/null
@@ -1,51 +0,0 @@
-class provision::named (
- $domain_name = $::provision::params::domain_name,
- $dns_address = $::provision::params::dns_address,
- $forwarders = $::provision::params::forwarders,
- $ddns_key = $::provision::params::ddns_key,
- $ddns_key_algorithm = $::provision::params::ddns_key_algorithm,
- $ddns_key_name = $::provision::params::ddns_key_name,
-) inherits provision::params {
-
- package { "named" :
- name => $::provision::params::named_package,
- }
-
- file { "/var/named" :
- ensure => directory,
- owner => 'named',
- group => 'named',
- mode => '0750',
- require => Package["named"],
- }
-
- file { $::provision::params::named_conf :
- ensure => present,
- content => template('provision/named.conf.erb'),
- owner => 'named',
- group => 'named',
- mode => '0640',
- require => Package["named"],
- notify => Service["named"],
- }
-
- file { "/var/named/${domain_name}" :
- ensure => present,
- content => template('provision/zone.erb'),
- owner => 'named',
- group => 'named',
- mode => '0644',
- require => Package["named"],
- notify => Service["named"],
- }
-
- service { "named" :
- name => $::provision::params::named_service,
- ensure => running,
- enable => true,
- hasrestart => false,
- hasstatus => false,
- require => Package["named"],
- }
-
-}
diff --git a/deployment/puppet/provision/manifests/params.pp b/deployment/puppet/provision/manifests/params.pp
deleted file mode 100644
index 2bcae12..0000000
--- a/deployment/puppet/provision/manifests/params.pp
+++ /dev/null
@@ -1,36 +0,0 @@
-class provision::params {
- case $::osfamily {
- 'RedHat': {
- $dhcpd_package = "dhcp"
- $dhcpd_service = "dhcpd"
- $dhcpd_conf = "/etc/dhcp/dhcpd.conf"
- $dhcpd_conf_d = "/etc/dhcp/dhcpd.d"
- $dhcpd_conf_extra = "/etc/dhcp/dhcpd.d/extra.conf"
- $named_package = "bind"
- $named_service = "named"
- $named_conf = "/etc/named.conf"
- }
- default: {
- fail("Unsupported osfamily ${::osfamily}")
- }
- }
- $network_address = "10.20.0.0"
- $network_mask = "255.255.255.0"
- $broadcast_address = "10.20.0.255"
- $start_address = "10.20.0.3"
- $end_address = "10.20.0.254"
- $router = "10.20.0.1"
- $next_server = "10.20.0.2"
- $dns_address = "10.20.0.2"
- $forwarders = ["8.8.8.8", "8.8.4.4"]
- $domain_name = "domain.tld"
- $ddns_key = "VyCWe0kutrawqQ2WEFKkAw=="
- $ddns_key_algorithm = "HMAC-MD5"
- $ddns_key_name = "DHCP_UPDATE"
-
- $bootstrap_kernel_path = "/images/ubuntu_bootstrap/vmlinuz"
- $bootstrap_initrd_path = "/images/ubuntu_bootstrap/initrd.img"
- $bootstrap_kernel_params = "ksdevice=bootif lang= console=ttyS0,9600 console=tty0 toram locale=en_US text boot=live biosdevname=0 components ip=frommedia ethdevice-timeout=120 net.ifnames=1 panic=60"
- $bootstrap_menu_label = "ubuntu_bootstrap"
-
-}
diff --git a/deployment/puppet/provision/manifests/tftp.pp b/deployment/puppet/provision/manifests/tftp.pp
deleted file mode 100644
index f05bd16..0000000
--- a/deployment/puppet/provision/manifests/tftp.pp
+++ /dev/null
@@ -1,95 +0,0 @@
-class provision::tftp (
- $bootstrap_kernel_params = $::provision::params::bootstrap_kernel_params,
- $bootstrap_kernel_path = $::provision::params::bootstrap_kernel_path,
- $bootstrap_initrd_path = $::provision::params::bootstrap_initrd_path,
- $bootstrap_menu_label = $::provision::params::bootstrap_menu_label,
- $chain32_files = [],
-) inherits provision::params {
-
- Exec {path => '/usr/bin:/bin:/usr/sbin:/sbin'}
-
- case $::osfamily {
- 'RedHat': {
- $tftp_packages = ['xinetd', 'tftp-server', 'syslinux']
-
- service { 'xinetd':
- ensure => running,
- enable => true,
- hasrestart => true,
- require => Package[$tftp_packages],
- }
-
- file { '/etc/xinetd.conf':
- content => template('provision/xinetd.conf.erb'),
- owner => 'root',
- group => 'root',
- mode => '0600',
- require => Package[$tftp_packages],
- notify => Service['xinetd'],
- }
-
- file { '/etc/xinetd.d/tftp' :
- content => template('provision/tftp.xinetd.erb'),
- owner => 'root',
- group => 'root',
- mode => '0644',
- require => Package[$tftp_packages],
- notify => Service['xinetd'],
- }
-
- }
- default : {
- fail("Unsupported osfamily ${::osfamily}")
- }
- }
-
- ensure_packages($tftp_packages)
-
- file { ["/var/lib/tftpboot/images", "/var/lib/tftpboot/pxelinux.cfg"] :
- ensure => directory,
- owner => 'root',
- group => 'root',
- mode => '0755',
- require => Package[$tftp_packages],
- }
-
- file { "/var/lib/tftpboot/pxelinux.cfg/default" :
- ensure => present,
- content => template("provision/tftp.default.erb"),
- owner => 'root',
- group => 'root',
- mode => '0644',
- require => File["/var/lib/tftpboot/pxelinux.cfg"],
- }
-
- file { '/var/lib/tftpboot/chain.c32':
- source => '/usr/share/syslinux/chain.c32',
- require => Package[$tftp_packages],
- }
-
- file { '/var/lib/tftpboot/pxelinux.0':
- source => '/usr/share/syslinux/pxelinux.0',
- require => Package[$tftp_packages],
- }
-
- file { '/var/lib/tftpboot/menu.c32':
- source => '/usr/share/syslinux/menu.c32',
- require => Package[$tftp_packages],
- }
-
- # TODO Create custom type that will remove all 01-* files that
- # are not in the $chain32_files list
- exec { 'remove /var/lib/tftpboot/pxelinux.cfg/01-* files' :
- command => "find /var/lib/tftpboot/pxelinux.cfg -type f -name '01-*' -delete",
- require => File["/var/lib/tftpboot/pxelinux.cfg"],
- } ->
-
- file { $chain32_files :
- ensure => present,
- content => template("provision/tftp.chain32.erb"),
- owner => 'root',
- group => 'root',
- mode => '0644',
- require => File["/var/lib/tftpboot/pxelinux.cfg"],
- }
-}
diff --git a/deployment/puppet/provision/templates/dhcpd.conf.erb b/deployment/puppet/provision/templates/dhcpd.conf.erb
deleted file mode 100644
index 8120dc1..0000000
--- a/deployment/puppet/provision/templates/dhcpd.conf.erb
+++ /dev/null
@@ -1,69 +0,0 @@
-ddns-updates on;
-update-static-leases on;
-ddns-domainname "<%= @domain_name %>";
-ddns-update-style interim;
-ignore client-updates;
-update-static-leases true;
-
-key <%= @ddns_key_name %> {
- algorithm <%= @ddns_key_algorithm %>;
- secret <%= @ddns_key %>;
-}
-
-local-address <%= @dns_address %>;
-zone <%= @domain_name %>. {
- primary <%= @dns_address %>;
- key <%= @ddns_key_name %>;
-}
-
-allow booting;
-allow bootp;
-set vendorclass = option vendor-class-identifier;
-option pxe-system-type code 93 = unsigned integer 16;
-default-lease-time 3600;
-max-lease-time 3600;
-log-facility local7;
-
-subnet <%= @network_address %> netmask <%= @network_mask %> {
- range <%= @start_address %> <%= @end_address %>;
- option domain-name-servers <%= @dns_address %>;
- option domain-name "<%= @domain_name %>";
- option subnet-mask <%= @network_mask %>;
- option routers <%= @router %>;
- option broadcast-address <%= @broadcast_address %>;
- next-server <%= @next_server %>;
- ddns-hostname = pick(option fqdn.hostname,option host-name, concat("dhcp-",binary-to-ascii(10,8,"-", leased-address)));
- class "pxeclients" {
- match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
- filename "pxelinux.0";
- }
-}
-
-<% if @known_hosts -%>
-group {
-
- option domain-name-servers <%= @dns_address %>;
- option domain-name "<%= @domain_name %>";
- option subnet-mask <%= @network_mask %>;
- option routers <%= @router %>;
- option broadcast-address <%= @broadcast_address %>;
- next-server <%= @next_server %>;
- class "pxeclients" {
- match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
- filename "pxelinux.0";
- }
-
- <% @known_hosts.each do |host_name, host_data| -%>
- host <%= host_data['dhcp_binding_params']['name'] %> {
- hardware ethernet <%= host_data['dhcp_binding_params']['mac'] %>;
- fixed-address <%= host_data['dhcp_binding_params']['ip_address'] %>;
- ddns-hostname "<%= host_data['dhcp_binding_params']['name'].split('.')[0] %>";
- ddns-domainname "<%= @domain_name%>";
- option host-name "<%= host_data['dhcp_binding_params']['name'].split('.')[0] %>";
- option domain-name "<%= @domain_name %>";
- }
- <% end -%>
-}
-<% end -%>
-
-include "<%= scope.lookupvar('::provision::params::dhcpd_conf_extra') %>";
diff --git a/deployment/puppet/provision/templates/named.conf.erb b/deployment/puppet/provision/templates/named.conf.erb
deleted file mode 100644
index f612204..0000000
--- a/deployment/puppet/provision/templates/named.conf.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-options {
- listen-on port 53 { <%= @dns_address %>; };
- directory "/var/named";
- dump-file "/var/named/data/cache_dump.db";
- statistics-file "/var/named/data/named_stats.txt";
- memstatistics-file "/var/named/data/named_mem_stats.txt";
- recursion yes;
- forward only;
- forwarders {
- <% @forwarders.each do |forwarder| -%>
- <%= forwarder %>;
- <% end -%>
- };
-};
-
-key <%= @ddns_key_name %> {
- algorithm <%= @ddns_key_algorithm %>;
- secret <%= @ddns_key %>;
-};
-
-logging {
- channel default_debug {
- file "data/named.run";
- severity dynamic;
- };
-};
-
-zone "<%= @domain_name %>." {
- type master;
- file "<%= @domain_name %>";
- allow-update { key <%= @ddns_key_name %>; };
-};
diff --git a/deployment/puppet/provision/templates/tftp.chain32.erb b/deployment/puppet/provision/templates/tftp.chain32.erb
deleted file mode 100644
index fae5e43..0000000
--- a/deployment/puppet/provision/templates/tftp.chain32.erb
+++ /dev/null
@@ -1,8 +0,0 @@
-DEFAULT local
-PROMPT 0
-TIMEOUT 0
-TOTALTIMEOUT 0
-ONTIMEOUT local
-
-LABEL local
- COM32 chain.c32
diff --git a/deployment/puppet/provision/templates/tftp.default.erb b/deployment/puppet/provision/templates/tftp.default.erb
deleted file mode 100644
index e1cee87..0000000
--- a/deployment/puppet/provision/templates/tftp.default.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-DEFAULT menu
-PROMPT 0
-MENU TITLE Boot menu
-TIMEOUT 50
-TOTALTIMEOUT 0
-ONTIMEOUT <%= @bootstrap_menu_label %>
-
-LABEL local
- MENU LABEL (local)
- MENU DEFAULT
- LOCALBOOT -1
-
-LABEL <%= @bootstrap_menu_label %>
- kernel <%= @bootstrap_kernel_path %>
- MENU LABEL <%= @bootstrap_menu_label %>
- append initrd=<%= @bootstrap_initrd_path %> <%= @bootstrap_kernel_params %>
- ipappend 2
-
-MENU end
diff --git a/deployment/puppet/provision/templates/tftp.xinetd.erb b/deployment/puppet/provision/templates/tftp.xinetd.erb
deleted file mode 100644
index bde8373..0000000
--- a/deployment/puppet/provision/templates/tftp.xinetd.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-service tftp
-{
- disable = no
- socket_type = dgram
- protocol = udp
- wait = yes
- user = root
- server = /usr/sbin/in.tftpd
- server_args = -B 1380 -v -s /var/lib/tftpboot
- per_source = 11
- cps = 100 2
- flags = IPv4
-}
diff --git a/deployment/puppet/provision/templates/xinetd.conf.erb b/deployment/puppet/provision/templates/xinetd.conf.erb
deleted file mode 100644
index 0a90f33..0000000
--- a/deployment/puppet/provision/templates/xinetd.conf.erb
+++ /dev/null
@@ -1,17 +0,0 @@
-defaults
-{
- log_type = SYSLOG daemon info
- log_on_failure = HOST
- log_on_success = PID HOST DURATION EXIT
-
- cps = 50 10
- instances = 50
- per_source = 10
-
- v6only = no
-
- groups = yes
- umask = 002
-}
-
-includedir /etc/xinetd.d
diff --git a/deployment/puppet/provision/templates/zone.erb b/deployment/puppet/provision/templates/zone.erb
deleted file mode 100644
index ea1b87a..0000000
--- a/deployment/puppet/provision/templates/zone.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-$TTL 300
-@ IN SOA ns.<%= @domain_name %>. nobody.<%= @domain_name %>. (
- 2017021302 ; Serial
- 600 ; Refresh
- 1800 ; Retry
- 604800 ; Expire
- 300 ; TTL
- )
-
- IN NS ns.<%= @domain_name %>.
-ns IN A <%= @dns_address %>
diff --git a/graphs/provision/tasks.yaml b/graphs/provision/tasks.yaml
index 3a21c87..68716ce 100644
--- a/graphs/provision/tasks.yaml
+++ b/graphs/provision/tasks.yaml
@@ -14,7 +14,7 @@
requires: [provision_start]
required_for: [build_deploy_image]
parameters:
- path: /var/lib/fuel/configs/{CLUSTER_ID}/provision.yaml
+ path: /tmp/provision.yaml
timeout: 180
data:
#TODO: Replace dict($.items) to $ when LP1666913 is fixed
@@ -40,27 +40,31 @@
requires: [upload_provision_info_master, generate_ironic_bootstrap_keys]
required_for: [provision_end]
parameters:
- command_prefix: FACTER_cluster_id={CLUSTER_ID}
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/provision/build_image.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
-- id: provision_master
- type: puppet
+- id: move_to_bootstrap
+ type: move_to_bootstrap
version: 2.1.0
- role: ['master']
- requires: [upload_provision_info_master]
- required_for: [build_deploy_image]
+ role: ['/.*/']
+ requires: [provision_start, build_deploy_image]
+ required_for: [upload_provision_info]
+ cross-depends:
+ - name: build_deploy_image
+ role: master
parameters:
- puppet_manifest: /etc/puppet/modules/fuel/examples/provision.pp
- puppet_modules: /etc/puppet/modules
- timeout: 3600
+ slave_name:
+ yaql_exp: '$.network_metadata.nodes.values().where($.uid = new($.uid)).name.first()'
+ provisioning_info:
+ yaql_exp: '$.provision'
+ timeout: 180
- id: upload_provision_info
type: upload_file
version: 2.1.0
role: ['/.*/']
- requires: [provision_master]
+ requires: [move_to_bootstrap]
required_for: [system_provision]
parameters:
path: /tmp/provision.json
@@ -72,8 +76,8 @@
type: shell
version: 2.1.0
role: ['/.*/']
- requires: [provision_master, upload_provision_info]
- required_for: [node_reboot]
+ requires: [move_to_bootstrap, upload_provision_info]
+ required_for: [cobbler_disable_netboot]
cross-depends:
- name: build_deploy_image
role: master
@@ -81,6 +85,19 @@
cmd: /usr/bin/provision
timeout: 3600
+- id: cobbler_disable_netboot
+ type: master_shell
+ version: 2.1.0
+ role: ['/.*/']
+ requires: [system_provision]
+ required_for: [node_reboot]
+ parameters:
+ strategy:
+ type: one_by_one
+ cmd:
+ yaql_exp: 'concat("sh /etc/puppet/modules/osnailyfacter/modular/provision/netboot disable ", $.provision.name)'
+ timeout: 180
+
- id: node_reboot
type: reboot
version: 2.1.0
diff --git a/tests/noop/spec/hosts/master/cobbler_spec.rb b/tests/noop/spec/hosts/master/cobbler_spec.rb
new file mode 100644
index 0000000..f7c36fb
--- /dev/null
+++ b/tests/noop/spec/hosts/master/cobbler_spec.rb
@@ -0,0 +1,79 @@
+require 'spec_helper'
+require 'shared-examples'
+require 'yaml'
+manifest = 'master/cobbler.pp'
+
+# HIERA: master
+# FACTS: master_centos7
+
+describe manifest do
+ shared_examples 'catalog' do
+ let(:fuel_settings) do
+ YAML.load facts[:astute_settings_yaml]
+ end
+
+ let(:bootstrap_settings) do
+ fuel_settings.fetch 'BOOTSTRAP', {}
+ end
+
+ it 'should contain class "fuel::cobbler" with correct parameters' do
+ parameters = {
+ :cobbler_user => fuel_settings['cobbler']['user'],
+ :cobbler_password => fuel_settings['cobbler']['password'],
+ :bootstrap_path => bootstrap_settings.fetch('path', '/var/www/nailgun/bootstraps/active_bootstrap'),
+ # :bootstrap_meta => nil,
+ :server => fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ :name_server => fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ :next_server => fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ :mco_user => fuel_settings['mcollective']['user'],
+ :mco_pass => fuel_settings['mcollective']['password'],
+ :dns_upstream => [fuel_settings['DNS_UPSTREAM']],
+ :dns_domain => fuel_settings['DNS_DOMAIN'],
+ :dns_search => fuel_settings['DNS_SEARCH'],
+ :dhcp_ipaddress => fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ :nailgun_api_url => "http://#{fuel_settings['ADMIN_NETWORK']['ipaddress']}:8000/api",
+ :bootstrap_ethdevice_timeout => bootstrap_settings.fetch('ethdevice_timeout', '120'),
+ }
+ is_expected.to contain_class('fuel::cobbler').with parameters
+ end
+
+ it { is_expected.to contain_file '/etc/resolv.conf' }
+
+ %w(httpd cobblerd xinetd).each do |service|
+ it "should containt '#{service}' fuel::systemd service with correct parameters" do
+ parameters = {
+ :start => true,
+ :template_path => 'fuel/systemd/restart_template.erb',
+ :config_name => 'restart.conf',
+ }
+ is_expected.to contain_fuel__systemd(service).with parameters
+ end
+ end
+
+ it "should containt dnsmasq fuel::systemd service with correct parameters" do
+ parameters = {
+ :start => true,
+ :template_path => 'fuel/systemd/dnsmasq_template.erb',
+ :config_name => 'restart.conf',
+ }
+ is_expected.to contain_fuel__systemd('dnsmasq').with parameters
+ end
+
+ it 'should declare the "fuel::dnsmasq::dhcp_range" with "default" title and correct parameters' do
+ parameters = {
+ :dhcp_start_address => fuel_settings['ADMIN_NETWORK']['dhcp_pool_start'],
+ :dhcp_end_address => fuel_settings['ADMIN_NETWORK']['dhcp_pool_end'],
+ :dhcp_netmask => fuel_settings['ADMIN_NETWORK']['netmask'],
+ :dhcp_gateway => fuel_settings['ADMIN_NETWORK']['dhcp_gateway'],
+ :next_server => fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ :listen_address => fuel_settings['ADMIN_NETWORK']['ipaddress'],
+ }
+ is_expected.to contain_fuel__dnsmasq__dhcp_range('default').with parameters
+ is_expected.to contain_fuel__dnsmasq__dhcp_range('default').that_notifies 'Service[dnsmasq]'
+ end
+
+ it { is_expected.to contain_cobbler_profile('ubuntu_bootstrap').with_kopts(/\bip=frommedia\b/) }
+
+ end
+ run_test manifest
+end
diff --git a/tests/noop/spec/hosts/master/dhcp-ranges_spec.rb b/tests/noop/spec/hosts/master/dhcp-ranges_spec.rb
new file mode 100644
index 0000000..b34675b
--- /dev/null
+++ b/tests/noop/spec/hosts/master/dhcp-ranges_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper'
+require 'shared-examples'
+manifest = 'master/dhcp-ranges.pp'
+
+# HIERA: master
+# FACTS: master_centos7
+
+describe manifest do
+ shared_examples 'catalog' do
+ context 'with empty admin_networks' do
+ it 'should not create any dhcp ranges' do
+ is_expected.to have_nailgun__dnsmasq__dhcp_range_resource_count 0
+ end
+ end
+ end
+ run_test manifest
+end
diff --git a/tests/noop/spec/hosts/master/host_spec.rb b/tests/noop/spec/hosts/master/host_spec.rb
index 9937ff3..66c3b4b 100644
--- a/tests/noop/spec/hosts/master/host_spec.rb
+++ b/tests/noop/spec/hosts/master/host_spec.rb
@@ -263,6 +263,8 @@ describe manifest do
should contain_firewall('102 dns_udp')
should contain_firewall('103 dhcp')
should contain_firewall('104 tftp')
+ should contain_firewall('105 squidproxy')
+ should contain_firewall('106 cobbler_web')
end
it 'should declare "openstack::clocksync" class with parameters' do
|