Pavel Cizinsky | 2051e98 | 2019-04-08 13:07:04 +0200 | [diff] [blame] | 1 | def common = new com.mirantis.mk.Common() |
| 2 | def salt = new com.mirantis.mk.Salt() |
| 3 | def python = new com.mirantis.mk.Python() |
Pavel Cizinsky | 32d8bc8 | 2019-04-24 10:24:30 +0200 | [diff] [blame] | 4 | def pepperEnv = "pepperEnv" |
Pavel Cizinsky | 2051e98 | 2019-04-08 13:07:04 +0200 | [diff] [blame] | 5 | |
| 6 | timeout(time: 12, unit: 'HOURS') { |
| 7 | node() { |
| 8 | stage('Setup virtualenv for Pepper') { |
| 9 | python.setupPepperVirtualenv(pepperEnv, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 10 | } |
| 11 | stage('Salt-Master restore') { |
| 12 | common.infoMsg('Verify pillar for salt-master backups') |
| 13 | try { |
| 14 | def masterPillar = salt.getPillar(pepperEnv, "I@salt:master", 'salt:minion:initial_data') |
| 15 | if(masterPillar['return'].isEmpty()) { |
| 16 | throw new Exception('Problem with salt-master pillar.') |
| 17 | } |
| 18 | def minionPillar = salt.getPillar(pepperEnv, "I@salt:master", 'salt:minion:initial_data') |
| 19 | if(minionPillar['return'].isEmpty()) { |
| 20 | throw new Exception('Problem with salt-minion pillar.') |
| 21 | } |
| 22 | } |
| 23 | catch (Exception e){ |
| 24 | common.errorMsg(e.getMessage()) |
| 25 | common.errorMsg('Please fix your pillar. For more information check docs: https://docs.mirantis.com/mcp/latest/mcp-operations-guide/backup-restore/salt-master/salt-master-restore.html') |
| 26 | return |
| 27 | } |
| 28 | common.infoMsg('Performing restore') |
| 29 | salt.enforceState(['saltId': pepperEnv, 'target': 'I@salt:master', 'state': 'salt.master.restore']) |
| 30 | salt.enforceState(['saltId': pepperEnv, 'target': 'I@salt:master', 'state': 'salt.minion.restore']) |
| 31 | salt.fullRefresh(pepperEnv, '*') |
| 32 | |
| 33 | common.infoMsg('Validating output') |
| 34 | common.infoMsg('Salt-Keys') |
| 35 | salt.cmdRun(pepperEnv, 'I@salt:master', "salt-key") |
| 36 | common.infoMsg('Salt-master CA') |
| 37 | salt.cmdRun(pepperEnv, 'I@salt:master', "ls -la /etc/pki/ca/salt_master_ca/") |
| 38 | } |
| 39 | stage('MAAS Restore') { |
| 40 | common.infoMsg('Verify pillar for MaaS backup') |
| 41 | try { |
| 42 | def maaSPillar = salt.getPillar(pepperEnv, "I@maas:server", 'maas:region:database:initial_data') |
| 43 | if(maaSPillar['return'].isEmpty()) { |
| 44 | throw new Exception('Problem with MaaS pillar.') |
| 45 | } |
| 46 | } |
| 47 | catch (Exception e){ |
| 48 | common.errorMsg(e.getMessage()) |
| 49 | common.errorMsg('Please fix your pillar. For more information check docs: https://docs.mirantis.com/mcp/latest/mcp-operations-guide/backup-restore/backupninja-postgresql/backupninja-postgresql-restore.html') |
| 50 | return |
| 51 | } |
| 52 | salt.enforceState(['saltId': pepperEnv, 'target': 'I@maas:region', 'state': 'maas.region']) |
| 53 | } |
| 54 | } |
| 55 | } |