Added uninstall feature

This commit is contained in:
2026-03-13 09:14:07 -04:00
parent 619cb1a3e7
commit 70fcdbf58f
3 changed files with 48 additions and 2 deletions

11
Jenkinsfile vendored
View File

@@ -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"
}
}
}