2024-06-23 01:05:03 +03:00
|
|
|
pipeline {
|
|
|
|
|
agent any
|
2024-09-29 01:48:21 +03:00
|
|
|
options {
|
|
|
|
|
buildDiscarder logRotator (
|
|
|
|
|
numToKeepStr: '5',
|
|
|
|
|
daysToKeepStr: '7',
|
|
|
|
|
artifactNumToKeepStr: '10',
|
|
|
|
|
artifactDaysToKeepStr: '7'
|
|
|
|
|
)
|
2025-06-08 01:38:44 +03:00
|
|
|
ansiColor('xterm')
|
|
|
|
|
timestamps()
|
2024-09-29 01:48:21 +03:00
|
|
|
}
|
2024-06-23 01:05:03 +03:00
|
|
|
parameters {
|
|
|
|
|
string(name: "target_host", defaultValue: "", trim: true, description: "Target host")
|
2024-06-30 18:30:49 +03:00
|
|
|
booleanParam(name: "rproxy_install", defaultValue: true, description: "Install Rproxy")
|
2025-10-09 23:26:06 +03:00
|
|
|
string(name: "images_repo_url", defaultValue: "", trim: true, description: "Repository host with podman images (ex. rproxy.olsson.ul:5000)\n(for 'rproxy_install' job only)")
|
2024-06-30 18:30:49 +03:00
|
|
|
booleanParam(name: "config_add", defaultValue: true, description: "Add config")
|
2024-09-27 23:26:27 +03:00
|
|
|
string(name: "rproxy_service_name", defaultValue: "", trim: true, description: "Service name (for 'Add config' job only)")
|
|
|
|
|
string(name: "rproxy_service_port", defaultValue: "", trim: true, description: "Service port (for 'Add config' job only)")
|
|
|
|
|
string(name: "rproxy_service_address", defaultValue: "", trim: true, description: "Service address (for 'Add config' job only)")
|
2025-07-20 18:04:47 +03:00
|
|
|
booleanParam(name: 'update_job', defaultValue: false, description: 'Update job, free run, no changes')
|
2024-06-23 01:05:03 +03:00
|
|
|
}
|
|
|
|
|
stages {
|
2025-07-20 18:04:47 +03:00
|
|
|
stage('Update Job') {
|
|
|
|
|
when {
|
|
|
|
|
expression {
|
|
|
|
|
return params.update_job
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
script {
|
|
|
|
|
currentBuild.getRawBuild().getExecutor().interrupt(Result.SUCCESS)
|
|
|
|
|
sleep(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-08 01:38:44 +03:00
|
|
|
stage('Prepare inventory') {
|
|
|
|
|
steps {
|
|
|
|
|
script {
|
|
|
|
|
def hostsFile = new File("${WORKSPACE}/hosts.ini")
|
|
|
|
|
hostsFile.append('[all]')
|
|
|
|
|
hostsFile.append('\n' + params.target_host)
|
|
|
|
|
println hostsFile.getText('UTF-8')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-30 18:30:49 +03:00
|
|
|
stage('Install Rproxy') {
|
|
|
|
|
when {
|
|
|
|
|
expression {
|
|
|
|
|
return params.rproxy_install
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
script {
|
2024-09-29 01:48:21 +03:00
|
|
|
withCredentials([
|
|
|
|
|
sshUserPrivateKey(credentialsId: 'JENKINS_DEPLOYER_KEY', keyFileVariable: 'SSH_KEY'),
|
|
|
|
|
usernamePassword(credentialsId:'JENKINS_DEPLOYER_PASS', usernameVariable: 'username', passwordVariable: 'password')
|
|
|
|
|
]) {
|
|
|
|
|
wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[password: env.password]]]) {
|
2025-06-08 01:38:44 +03:00
|
|
|
wrap([$class: 'AnsiColorBuildWrapper', colorMapName: "xterm"]) {
|
|
|
|
|
ansiblePlaybook(
|
|
|
|
|
playbook: 'rproxy.yml',
|
|
|
|
|
inventory: 'hosts.ini',
|
|
|
|
|
tags: 'install',
|
|
|
|
|
colorized: true,
|
2025-10-09 23:26:06 +03:00
|
|
|
extras: '''--private-key ${SSH_KEY}
|
|
|
|
|
-e "ansible_user=${username}
|
|
|
|
|
ansible_password=${password}
|
|
|
|
|
rproxy_service_name=${rproxy_service_name}
|
|
|
|
|
rproxy_service_port=${rproxy_service_port}
|
|
|
|
|
rproxy_service_address=${rproxy_service_address}
|
|
|
|
|
image_repo=${images_repo_url}"'''
|
2025-06-08 01:38:44 +03:00
|
|
|
)
|
|
|
|
|
}
|
2024-09-29 01:48:21 +03:00
|
|
|
}
|
2024-06-30 18:30:49 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
stage('Add config') {
|
|
|
|
|
when {
|
|
|
|
|
expression {
|
|
|
|
|
return params.config_add
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-23 01:05:03 +03:00
|
|
|
steps {
|
2024-06-30 16:39:34 +03:00
|
|
|
script {
|
2024-09-29 01:48:21 +03:00
|
|
|
withCredentials([
|
|
|
|
|
sshUserPrivateKey(credentialsId: 'JENKINS_DEPLOYER_KEY', keyFileVariable: 'SSH_KEY'),
|
|
|
|
|
usernamePassword(credentialsId:'JENKINS_DEPLOYER_PASS', usernameVariable: 'username', passwordVariable: 'password')
|
|
|
|
|
]) {
|
|
|
|
|
wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[password: env.password]]]) {
|
2025-06-08 01:38:44 +03:00
|
|
|
wrap([$class: 'AnsiColorBuildWrapper', colorMapName: "xterm"]) {
|
|
|
|
|
ansiblePlaybook(
|
|
|
|
|
playbook: 'rproxy.yml',
|
|
|
|
|
inventory: 'hosts.ini',
|
|
|
|
|
tags: 'add_config',
|
|
|
|
|
colorized: true,
|
2025-10-09 23:26:06 +03:00
|
|
|
extras: '''--private-key ${SSH_KEY}
|
|
|
|
|
-e "ansible_user=${username}
|
|
|
|
|
ansible_password=${password}
|
|
|
|
|
rproxy_service_name=${rproxy_service_name}
|
|
|
|
|
rproxy_service_port=${rproxy_service_port}
|
|
|
|
|
rproxy_service_address=${rproxy_service_address}"'''
|
2025-06-08 01:38:44 +03:00
|
|
|
)
|
|
|
|
|
}
|
2024-09-29 01:48:21 +03:00
|
|
|
}
|
2024-06-30 16:39:34 +03:00
|
|
|
}
|
|
|
|
|
}
|
2024-06-23 01:05:03 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-08 01:38:44 +03:00
|
|
|
post {
|
|
|
|
|
always {
|
|
|
|
|
cleanWs(patterns: [
|
|
|
|
|
[pattern: 'hosts.ini', type: 'INCLUDE']
|
|
|
|
|
])
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-23 01:05:03 +03:00
|
|
|
}
|