first commit
This commit is contained in:
68
Jenkinsfile
vendored
Normal file
68
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
parameters {
|
||||
string(
|
||||
name: 'LIMIT',
|
||||
defaultValue: '',
|
||||
description: 'Limit to specific hosts or groups (e.g., "vms", "lxcs", "zabbix", or hostname) no .lan required'
|
||||
)
|
||||
booleanParam(
|
||||
name: 'DRY_RUN',
|
||||
defaultValue: false,
|
||||
description: 'Run in check mode — no changes will be applied to target hosts'
|
||||
)
|
||||
}
|
||||
|
||||
environment {
|
||||
PROXMOX_URL = 'https://192.168.0.166:8006'
|
||||
PROXMOX_USER = 'dynamic-inventory@pve'
|
||||
PROXMOX_TOKEN_ID = 'dynamic-inventory'
|
||||
PROXMOX_TOKEN_SECRET = credentials('PROXMOX_TOKEN_SECRET')
|
||||
ANSIBLE_HOST_KEY_CHECKING = 'False'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Verify Inventory') {
|
||||
steps {
|
||||
sh '''
|
||||
echo "Testing dynamic inventory connection..."
|
||||
ansible-inventory -i inventory/inventory.proxmox.yml --list | head -10
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Run Playbook') {
|
||||
steps {
|
||||
script {
|
||||
def limitFlag = params.LIMIT ? "--limit '${params.LIMIT}'" : ''
|
||||
def checkFlag = params.DRY_RUN ? '--check --diff' : ''
|
||||
|
||||
sh """
|
||||
ansible-playbook \
|
||||
-i inventory/inventory.proxmox.yml \
|
||||
playbooks/install_zabbix.yml \
|
||||
${limitFlag} \
|
||||
${checkFlag} \
|
||||
-v
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
echo "Zabbix agent installation completed successfully"
|
||||
}
|
||||
failure {
|
||||
echo "Zabbix agent installation failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user