Added uninstall feature
This commit is contained in:
11
Jenkinsfile
vendored
11
Jenkinsfile
vendored
@@ -7,6 +7,11 @@ pipeline {
|
||||
defaultValue: '',
|
||||
description: 'Limit to specific hosts or groups (e.g., "vms", "lxcs", "zabbix_targets", or hostname) no .lan required'
|
||||
)
|
||||
booleanParam(
|
||||
name: 'UNINSTALL',
|
||||
defaultValue: false,
|
||||
description: 'Remove Zabbix agent2 and purge configuration from target hosts'
|
||||
)
|
||||
booleanParam(
|
||||
name: 'DRY_RUN',
|
||||
defaultValue: false,
|
||||
@@ -43,6 +48,7 @@ pipeline {
|
||||
script {
|
||||
def limitFlag = params.LIMIT ? "--limit '${params.LIMIT}'" : ''
|
||||
def checkFlag = params.DRY_RUN ? '--check --diff' : ''
|
||||
def stateVar = params.UNINSTALL ? '-e "zabbix_state=absent"' : ''
|
||||
|
||||
sh """
|
||||
ansible-playbook \
|
||||
@@ -50,6 +56,7 @@ pipeline {
|
||||
playbooks/install_zabbix.yml \
|
||||
${limitFlag} \
|
||||
${checkFlag} \
|
||||
${stateVar} \
|
||||
-v
|
||||
"""
|
||||
}
|
||||
@@ -59,10 +66,10 @@ pipeline {
|
||||
|
||||
post {
|
||||
success {
|
||||
echo "Zabbix agent installation completed successfully"
|
||||
echo "Zabbix agent ${params.UNINSTALL ? 'removal' : 'installation'} completed successfully"
|
||||
}
|
||||
failure {
|
||||
echo "Zabbix agent installation failed"
|
||||
echo "Zabbix agent ${params.UNINSTALL ? 'removal' : 'installation'} failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user