Ales Komarek | 585bd46 | 2017-08-24 09:33:32 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Update formulas on salt master |
| 3 | * |
| 4 | * Expected parameters: |
| 5 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API. |
| 6 | * SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000]. |
| 7 | * TARGET_SERVERS Server to update |
| 8 | * |
| 9 | **/ |
| 10 | |
| 11 | def common = new com.mirantis.mk.Common() |
| 12 | def salt = new com.mirantis.mk.Salt() |
| 13 | |
| 14 | def saltMaster |
| 15 | def target = ['expression': TARGET_SERVERS, 'type': 'compound'] |
| 16 | def result |
| 17 | |
| 18 | node("python") { |
| 19 | try { |
| 20 | |
| 21 | stage('Connect to Salt master') { |
| 22 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 23 | } |
| 24 | |
| 25 | stage('Update Salt formulas') { |
| 26 | result = salt.runSaltCommand(saltMaster, 'local', target, 'state.apply', null, 'salt.master.env') |
| 27 | salt.checkResult(result) |
| 28 | } |
| 29 | |
| 30 | } catch (Throwable e) { |
| 31 | currentBuild.result = 'FAILURE' |
| 32 | throw e |
| 33 | } |
| 34 | } |