fix bugs jenkinsjob

This commit is contained in:
reqwizz 2024-11-12 23:43:48 +03:00
parent 8fe1bebb4b
commit b6f55f1186
3 changed files with 24 additions and 26 deletions

31
ansible/Jenkinsfile vendored
View File

@ -7,8 +7,10 @@ pipeline {
} }
parameters { parameters {
choice(name: 'SITE_OPTION', choices: ['SiteA', 'SiteB', 'SiteA&B'], description: 'Select which site to deploy') string(name: 'ADDITIONAL_CONTENT_SITEA_H2', defaultValue: 'Новое сообщение для SiteA', description: 'Additional <h2> content for SiteA')
string(name: 'ADDITIONAL_CONTENT', defaultValue: 'Новое сообщение', description: 'Additional content to be included in the site') string(name: 'ADDITIONAL_CONTENT_SITEA_P', defaultValue: 'Дополнительный параграф для SiteA', description: 'Additional <p> content for SiteA')
string(name: 'ADDITIONAL_CONTENT_SITEB_H2', defaultValue: 'Новое сообщение для SiteB', description: 'Additional <h2> content for SiteB')
string(name: 'ADDITIONAL_CONTENT_SITEB_P', defaultValue: 'Дополнительный параграф для SiteB', description: 'Additional <p> content for SiteB')
} }
stages { stages {
@ -36,26 +38,19 @@ pipeline {
stage('Deploy Site') { stage('Deploy Site') {
steps { steps {
script { script {
def sanitized_content = params.ADDITIONAL_CONTENT.replaceAll("'", "\\'").replaceAll('"', '\\"') def extraVars = [
siteA_h2: params.ADDITIONAL_CONTENT_SITEA_H2,
def siteOption = params.SITE_OPTION siteA_p: params.ADDITIONAL_CONTENT_SITEA_P,
def targetGroups = '' siteB_h2: params.ADDITIONAL_CONTENT_SITEB_H2,
if (siteOption == 'SiteA') { siteB_p: params.ADDITIONAL_CONTENT_SITEB_P,
targetGroups = 'SiteA,proxy' ansible_ssh_private_key_file: env.DECYPTED_KEY_FILE
} else if (siteOption == 'SiteB') { ]
targetGroups = 'SiteB,proxy'
} else if (siteOption == 'SiteA&B') {
targetGroups = 'SiteA,SiteB,proxy'
}
ansiblePlaybook( ansiblePlaybook(
playbook: 'ansible/playbook.yml', playbook: 'ansible/playbook.yml',
inventory: "ansible/inventory.yml", inventory: "ansible/inventory.yml",
extraVars: [ extraVars: extraVars,
additional_content: sanitized_content, limit: 'SiteA,SiteB,proxy'
ansible_ssh_private_key_file: env.DECYPTED_KEY_FILE
],
limit: targetGroups
) )
} }
} }

View File

@ -1,16 +1,16 @@
siteA: siteA:
site_title: "SiteA - Добро пожаловать" site_title: "SiteA - Добро пожаловать"
site_h1: "Добро пожаловать на SiteA" site_h1: "Добро пожаловать на SiteA"
site_h2: "Секция SiteA" site_h2: "{{ siteA_h2 }}"
site_p: "Это дополнительный параграф для SiteA." site_p: "{{ siteA_p }}"
site_domain: "siteA.example.com" site_domain: "siteA.example.com"
site_ip: "192.168.0.61" site_ip: "192.168.0.61"
siteB: siteB:
site_title: "SiteB - Добро пожаловать" site_title: "SiteB - Добро пожаловать"
site_h1: "Добро пожаловать на SiteB" site_h1: "Добро пожаловать на SiteB"
site_h2: "Секция SiteB" site_h2: "{{ siteB_h2 }}"
site_p: "Это дополнительный параграф для SiteB." site_p: "{{ siteB_p }}"
site_domain: "siteB.example.com" site_domain: "siteB.example.com"
site_ip: "192.168.0.62" site_ip: "192.168.0.62"

View File

@ -17,10 +17,13 @@ server {
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
} }
location /health { location /health {
return 200 'Proxy is up'; proxy_pass http://backend/health;
add_header Content-Type text/plain; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} }
} }