Richard Felkl | 0eb0f60 | 2017-10-11 08:37:54 +0200 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Update Salt environment pipeline |
| 4 | * |
| 5 | * Expected parameters: |
| 6 | * SALT_MASTER_URL Salt API server location |
| 7 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 8 | * UPDATE_FORMULAS Boolean switch for enforcing updating formulas |
| 9 | */ |
| 10 | |
| 11 | // Load shared libs |
| 12 | def salt = new com.mirantis.mk.Salt() |
| 13 | def common = new com.mirantis.mk.Common() |
| 14 | def python = new com.mirantis.mk.Python() |
| 15 | def venvPepper = "venvPepper" |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 16 | timeout(time: 12, unit: 'HOURS') { |
| 17 | node() { |
| 18 | try { |
| 19 | python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
Richard Felkl | 0eb0f60 | 2017-10-11 08:37:54 +0200 | [diff] [blame] | 20 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 21 | stage("Update formulas"){ |
| 22 | if(UPDATE_FORMULAS.toBoolean()){ |
| 23 | common.infoMsg("Updating salt formulas") |
| 24 | salt.cmdRun( |
| 25 | venvPepper, |
| 26 | "I@salt:master", |
| 27 | 'apt-get update && apt-get install -y salt-formula-*' |
| 28 | ) |
| 29 | common.infoMsg("Running salt sync-all") |
Denis Egorenko | e983d45 | 2019-08-23 14:29:34 +0400 | [diff] [blame] | 30 | salt.runSaltProcessStep(venvPepper, '*', 'saltutil.sync_all', [], null, true) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 31 | } |
| 32 | } |
| 33 | stage("Update Reclass") { |
| 34 | common.infoMsg("Updating reclass model") |
Richard Felkl | 0eb0f60 | 2017-10-11 08:37:54 +0200 | [diff] [blame] | 35 | salt.cmdRun( |
| 36 | venvPepper, |
| 37 | "I@salt:master", |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 38 | 'cd /srv/salt/reclass && git pull -r && git submodule update', |
| 39 | false |
Richard Felkl | 0eb0f60 | 2017-10-11 08:37:54 +0200 | [diff] [blame] | 40 | ) |
Richard Felkl | 0eb0f60 | 2017-10-11 08:37:54 +0200 | [diff] [blame] | 41 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 42 | salt.enforceState( |
| 43 | venvPepper, |
| 44 | "I@salt:master", |
| 45 | 'reclass', |
| 46 | true |
| 47 | ) |
| 48 | } |
| 49 | } catch (Throwable e) { |
| 50 | // If there was an error or exception thrown, the build failed |
| 51 | currentBuild.result = "FAILURE" |
| 52 | throw e |
Richard Felkl | 0eb0f60 | 2017-10-11 08:37:54 +0200 | [diff] [blame] | 53 | } |
Richard Felkl | 0eb0f60 | 2017-10-11 08:37:54 +0200 | [diff] [blame] | 54 | } |
| 55 | } |