first commit
This commit is contained in:
82
Jenkinsfile
vendored
Normal file
82
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
parameters {
|
||||
string(
|
||||
name: 'TARGET_HOST',
|
||||
defaultValue: '',
|
||||
description: 'Hostname or IP address of the target machine (e.g. 192.168.0.50 or myserver.lan)'
|
||||
)
|
||||
booleanParam(
|
||||
name: 'INSTALL_DOCKER',
|
||||
defaultValue: false,
|
||||
description: 'Install Docker and Docker Compose'
|
||||
)
|
||||
booleanParam(
|
||||
name: 'INSTALL_NFS_FOLDER',
|
||||
defaultValue: false,
|
||||
description: 'Install NFS and mount the NFSFolder share (/var/NFSFolder)'
|
||||
)
|
||||
booleanParam(
|
||||
name: 'INSTALL_NFS_VAULT',
|
||||
defaultValue: false,
|
||||
description: 'Install NFS and mount the Vault share (/var/vault)'
|
||||
)
|
||||
}
|
||||
|
||||
environment {
|
||||
ANSIBLE_CONFIG = "${WORKSPACE}/ansible.cfg"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Validate') {
|
||||
steps {
|
||||
script {
|
||||
if (!params.TARGET_HOST?.trim()) {
|
||||
error 'TARGET_HOST is required — enter the hostname or IP of the target machine.'
|
||||
}
|
||||
if (!params.INSTALL_DOCKER && !params.INSTALL_NFS_FOLDER && !params.INSTALL_NFS_VAULT) {
|
||||
error 'Select at least one installation option.'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Install Docker') {
|
||||
when {
|
||||
expression { return params.INSTALL_DOCKER }
|
||||
}
|
||||
steps {
|
||||
sh """
|
||||
ansible-playbook \
|
||||
-i "${params.TARGET_HOST}," \
|
||||
playbooks/docker.yml
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Install NFS') {
|
||||
when {
|
||||
expression { return params.INSTALL_NFS_FOLDER || params.INSTALL_NFS_VAULT }
|
||||
}
|
||||
steps {
|
||||
sh """
|
||||
ansible-playbook \
|
||||
-i "${params.TARGET_HOST}," \
|
||||
-e "install_nfs_folder=${params.INSTALL_NFS_FOLDER}" \
|
||||
-e "install_nfs_vault=${params.INSTALL_NFS_VAULT}" \
|
||||
playbooks/nfs.yml
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
echo "Provisioning complete on ${params.TARGET_HOST}."
|
||||
}
|
||||
failure {
|
||||
echo "Provisioning failed on ${params.TARGET_HOST}. Check the stage logs above."
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user