blob: 294f1ed1530dbe9c52a941034cdc7ec32e4a64cc [file] [log] [blame]
Jiri Broulik2c00f4c2017-10-26 13:23:11 +02001/**
2 *
3 * Add Ceph node to existing cluster
4 *
5 * Requred parameters:
6 * SALT_MASTER_URL URL of Salt master
7 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
8 * HOST Host (minion id) to be added
9 * HOST_TYPE Type of Ceph node to be added. Valid values are mon/osd/rgw
10 *
11 */
12
13common = new com.mirantis.mk.Common()
14salt = new com.mirantis.mk.Salt()
15orchestrate = new com.mirantis.mk.Orchestrate()
16def python = new com.mirantis.mk.Python()
17
18def pepperEnv = "pepperEnv"
Jakub Josefa63f9862018-01-11 17:58:38 +010019timeout(time: 12, unit: 'HOURS') {
20 node("python") {
Jiri Broulik2c00f4c2017-10-26 13:23:11 +020021
Jakub Josefa63f9862018-01-11 17:58:38 +010022 // create connection to salt master
23 python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Jiri Broulik2c00f4c2017-10-26 13:23:11 +020024
Jakub Josefa63f9862018-01-11 17:58:38 +010025 matches = ["osd", "mon", "rgw"]
26 def found = false
27 for (s in matches) {
28 if (HOST_TYPE.toLowerCase() == s) {
29 found = true
Jiri Broulik2c00f4c2017-10-26 13:23:11 +020030 }
31 }
Jakub Josefa63f9862018-01-11 17:58:38 +010032
33 if (!found) {
34 common.errorMsg("No such HOST_TYPE was found. Please insert one of the following types: mon/osd/rgw")
35 throw new InterruptedException()
36 }
37
Mateusz Los13d05202020-05-11 09:51:13 +020038 def checknode = salt.runSaltProcessStep(pepperEnv, HOST, 'test.ping')
39 if (checknode['return'][0].values().isEmpty()) {
40 common.errorMsg("Host not found")
41 throw new InterruptedException()
42 }
43
Jakub Josefa63f9862018-01-11 17:58:38 +010044 if (HOST_TYPE.toLowerCase() != 'osd') {
45
46 // launch VMs
47 stage('Launch VMs') {
48 salt.enforceState(pepperEnv, 'I@salt:control', 'salt.control', true)
49
50 // wait till the HOST appears in salt-key on salt-master
51 salt.minionPresent(pepperEnv, 'I@salt:master', HOST)
52 }
53 }
54
55 // run basic states
56 stage('Install infra') {
57 orchestrate.installFoundationInfraOnTarget(pepperEnv, HOST)
58 }
59
60 if (HOST_TYPE.toLowerCase() == 'osd') {
61
62 // Install Ceph osd
63 stage('Install Ceph OSD') {
64 orchestrate.installCephOsd(pepperEnv, HOST)
65 }
66 } else if (HOST_TYPE.toLowerCase() == 'mon') {
67 // Install Ceph mon
68 stage('Install Ceph MON') {
69 salt.enforceState(pepperEnv, 'I@ceph:common', 'ceph.common', true)
70 // install Ceph Mons
71 salt.enforceState(pepperEnv, 'I@ceph:mon', 'ceph.mon', true)
72 if (salt.testTarget(pepperEnv, 'I@ceph:mgr')) {
73 salt.enforceState(pepperEnv, 'I@ceph:mgr', 'ceph.mgr', true)
74 }
75 }
76 } else if (HOST_TYPE.toLowerCase() == 'rgw') {
77 // Install Ceph rgw
78 stage('Install Ceph RGW') {
79 salt.enforceState(pepperEnv, 'I@ceph:radosgw', ['keepalived', 'haproxy', 'ceph.radosgw'], true)
80 }
Jiri Broulik2c00f4c2017-10-26 13:23:11 +020081 }
Michal Kobusd8874842018-03-13 12:42:07 +010082
Ildar Svetlov9e9aa952018-04-13 23:13:07 +040083 stage("Update/Install monitoring") {
Ivan Berezovskiy19c685a2019-11-05 17:42:57 +040084 def prometheusNodes = salt.getMinions(pepperEnv, 'I@prometheus:server')
85 if (!prometheusNodes.isEmpty()) {
86 //Collect Grains
87 salt.enforceState(pepperEnv, HOST, 'salt.minion.grains')
88 salt.runSaltProcessStep(pepperEnv, HOST, 'saltutil.refresh_modules')
89 salt.runSaltProcessStep(pepperEnv, HOST, 'mine.update')
90 sleep(5)
91 salt.enforceState(pepperEnv, HOST, 'prometheus')
92 salt.enforceState(pepperEnv, 'I@prometheus:server', 'prometheus')
93 } else {
94 common.infoMsg('No Prometheus nodes in cluster. Nothing to do')
95 }
Ildar Svetlov9e9aa952018-04-13 23:13:07 +040096 }
Jiri Broulik2c00f4c2017-10-26 13:23:11 +020097 }
98}