ci: lib: Skip remount if empty limit pattern

Some playbooks apply only to hosts that do not have read-only root
filesystems.  For these, the `rw_limit` pattern will be empty.  The
*Remount R/W* and *Remount R/O* stages should be skipped when this is
the case.
jenkins-master
Dustin 2021-10-16 10:17:34 -05:00
parent cbcc0318f6
commit 347b5578c3
1 changed files with 27 additions and 16 deletions

View File

@ -1,4 +1,5 @@
import groovy.transform.Field
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
@Field
def DOCKER_ARGS = '''\
@ -52,7 +53,9 @@ def stageKinit() {
def stageRemountRW(limit) {
stage('Remount R/W') {
def STAGE_NAME = 'Remount R/W'
stage(STAGE_NAME) {
if (limit) {
ansiblePlaybook \
playbook: 'remount.yml',
limit: limit,
@ -61,6 +64,9 @@ def stageRemountRW(limit) {
extraVars: [
remount_state: 'rw',
]
} else {
Utils.markStageSkippedForConditional(STAGE_NAME)
}
}
}
@ -80,13 +86,18 @@ def generateStages(stages) {
}
def stageRemountRO(limit) {
stage('Remount R/O') {
def STAGE_NAME = 'Remount R/W'
stage(STAGE_NAME) {
if (limit) {
ansiblePlaybook \
playbook: 'remount.yml',
limit: limit + ':!rw-root',
become: true,
vaultCredentialsId: 'ansible-vault',
extras: '--diff'
} else {
Utils.markStageSkippedForConditional(STAGE_NAME)
}
}
}