2024-06-23 01:05:03 +03:00
|
|
|
pipeline {
|
|
|
|
|
agent any
|
|
|
|
|
parameters {
|
|
|
|
|
string(name: "target_host", defaultValue: "", trim: true, description: "Target host")
|
|
|
|
|
string(name: "username", defaultValue: "", trim: true, description: "Ansible user")
|
|
|
|
|
password(name: "password", defaultValue: "", description: "Ansible password")
|
2024-06-30 18:30:49 +03:00
|
|
|
booleanParam(name: "rproxy_install", defaultValue: true, description: "Install Rproxy")
|
|
|
|
|
base64File(name: "rootca", description: "RootCA (only for 'Install Rproxy')")
|
|
|
|
|
base64File(name: "rootca_key", description: "RootCA key (only for 'Install Rproxy')")
|
|
|
|
|
booleanParam(name: "config_add", defaultValue: true, description: "Add config")
|
|
|
|
|
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)")
|
|
|
|
|
|
2024-06-23 01:05:03 +03:00
|
|
|
}
|
|
|
|
|
stages {
|
|
|
|
|
stage('Download') {
|
|
|
|
|
steps {
|
2024-06-30 16:40:05 +03:00
|
|
|
git branch: 'dev', url:'${git_url}/Ansible/rproxy.git', credentialsId: 'git'
|
2024-06-23 01:05:03 +03:00
|
|
|
}
|
|
|
|
|
}
|
2024-06-30 18:30:49 +03:00
|
|
|
stage('Save certs') {
|
|
|
|
|
when {
|
|
|
|
|
expression {
|
|
|
|
|
return params.rproxy_install
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
sh 'mkdir roles/rproxy/files/certs'
|
|
|
|
|
withFileParameter('rootca') {
|
|
|
|
|
sh 'mv ${rootca} roles/rproxy/files/certs/RootCA.crt'
|
|
|
|
|
}
|
|
|
|
|
withFileParameter('rootca_key') {
|
|
|
|
|
sh 'mv ${rootca_key} roles/rproxy/files/certs/RootCA.key'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
stage('Install Rproxy') {
|
|
|
|
|
when {
|
|
|
|
|
expression {
|
|
|
|
|
return params.rproxy_install
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
script {
|
|
|
|
|
wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[password: params.password]]]) {
|
|
|
|
|
sh 'ansible-playbook rproxy.yml -i ${target_host}, -t install -u ${username} -e "ansible_password=${password} rproxy_service_name=${rproxy_service_name} rproxy_service_port=${rproxy_service_port} rproxy_service_address=${rproxy_service_address}"'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
|
wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[password: params.password]]]) {
|
2024-06-30 18:30:49 +03:00
|
|
|
sh 'ansible-playbook rproxy.yml -i ${target_host}, -t add_config -u ${username} -e "ansible_password=${password} rproxy_service_name=${rproxy_service_name} rproxy_service_port=${rproxy_service_port} rproxy_service_address=${rproxy_service_address}"'
|
2024-06-30 16:39:34 +03:00
|
|
|
}
|
|
|
|
|
}
|
2024-06-23 01:05:03 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|