fix job run

This commit is contained in:
reqwizz 2024-11-17 19:10:08 +03:00
parent 2f21245787
commit 55ffb7055c
4 changed files with 34 additions and 27 deletions

36
ansible/Jenkinsfile vendored
View File

@ -49,39 +49,37 @@ pipeline {
steps {
script {
def selectedHosts
def extraVars = [
ansible_ssh_private_key_file: env.DECYPTED_KEY_FILE
]
switch(params.DEPLOY_TARGET) {
case 'SiteA':
selectedHosts = 'SiteA,proxy'
extraVars.siteA_h2 = params.ADDITIONAL_CONTENT_SITEA_H2
extraVars.siteA_p = params.ADDITIONAL_CONTENT_SITEA_P
extraVars.siteB_h2 = null
extraVars.siteB_p = null
break
case 'SiteB':
selectedHosts = 'SiteB,proxy'
extraVars.siteB_h2 = params.ADDITIONAL_CONTENT_SITEB_H2
extraVars.siteB_p = params.ADDITIONAL_CONTENT_SITEB_P
extraVars.siteA_h2 = null
extraVars.siteA_p = null
break
case 'All':
selectedHosts = 'SiteA,SiteB,proxy'
extraVars.siteA_h2 = params.ADDITIONAL_CONTENT_ALL_H2
extraVars.siteA_p = params.ADDITIONAL_CONTENT_ALL_P
extraVars.siteB_h2 = params.ADDITIONAL_CONTENT_ALL_H2
extraVars.siteB_p = params.ADDITIONAL_CONTENT_ALL_P
break
default:
error "Неизвестный DEPLOY_TARGET: ${params.DEPLOY_TARGET}"
}
def extraVars = [
ansible_ssh_private_key_file: env.DECYPTED_KEY_FILE
]
if (params.DEPLOY_TARGET == 'All') {
extraVars.siteA_h2 = params.ADDITIONAL_CONTENT_ALL_H2
extraVars.siteA_p = params.ADDITIONAL_CONTENT_ALL_P
extraVars.siteB_h2 = params.ADDITIONAL_CONTENT_ALL_H2
extraVars.siteB_p = params.ADDITIONAL_CONTENT_ALL_P
} else {
if (params.DEPLOY_TARGET == 'SiteA' || params.DEPLOY_TARGET == 'All') {
extraVars.siteA_h2 = params.ADDITIONAL_CONTENT_SITEA_H2
extraVars.siteA_p = params.ADDITIONAL_CONTENT_SITEA_P
}
if (params.DEPLOY_TARGET == 'SiteB' || params.DEPLOY_TARGET == 'All') {
extraVars.siteB_h2 = params.ADDITIONAL_CONTENT_SITEB_H2
extraVars.siteB_p = params.ADDITIONAL_CONTENT_SITEB_P
}
}
extraVars = extraVars.findAll { key, value -> value != null }
ansiblePlaybook(
playbook: 'ansible/playbook.yml',

View File

@ -1,3 +1,9 @@
siteA_h2: "Дефолтный заголовок H2 для SiteA"
siteA_p: "Дефолтный параграф для SiteA"
siteB_h2: "Дефолтный заголовок H2 для SiteB"
siteB_p: "Дефолтный параграф для SiteB"
siteA:
site_title: "SiteA - Добро пожаловать"
site_h1: "Добро пожаловать на SiteA"

View File

@ -1,7 +1,10 @@
upstream backend {
{% for server in upstream_servers %}
server {{ server }} max_fails=1 fail_timeout=10s;
{% endfor %}
{% if siteA.site_ip %}
server {{ siteA.site_ip }} max_fails=1 fail_timeout=10s;
{% endif %}
{% if siteB.site_ip %}
server {{ siteB.site_ip }} max_fails=1 fail_timeout=10s;
{% endif %}
}
server {