fix bugs jenkinsjob
This commit is contained in:
parent
8fe1bebb4b
commit
b6f55f1186
35
ansible/Jenkinsfile
vendored
35
ansible/Jenkinsfile
vendored
@ -7,10 +7,12 @@ pipeline {
|
||||
}
|
||||
|
||||
parameters {
|
||||
choice(name: 'SITE_OPTION', choices: ['SiteA', 'SiteB', 'SiteA&B'], description: 'Select which site to deploy')
|
||||
string(name: 'ADDITIONAL_CONTENT', defaultValue: 'Новое сообщение', description: 'Additional content to be included in the site')
|
||||
string(name: 'ADDITIONAL_CONTENT_SITEA_H2', defaultValue: 'Новое сообщение для SiteA', description: 'Additional <h2> content for SiteA')
|
||||
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 {
|
||||
stage('Decrypt SSH Key') {
|
||||
steps {
|
||||
@ -36,32 +38,25 @@ pipeline {
|
||||
stage('Deploy Site') {
|
||||
steps {
|
||||
script {
|
||||
def sanitized_content = params.ADDITIONAL_CONTENT.replaceAll("'", "\\'").replaceAll('"', '\\"')
|
||||
|
||||
def siteOption = params.SITE_OPTION
|
||||
def targetGroups = ''
|
||||
if (siteOption == 'SiteA') {
|
||||
targetGroups = 'SiteA,proxy'
|
||||
} else if (siteOption == 'SiteB') {
|
||||
targetGroups = 'SiteB,proxy'
|
||||
} else if (siteOption == 'SiteA&B') {
|
||||
targetGroups = 'SiteA,SiteB,proxy'
|
||||
}
|
||||
def extraVars = [
|
||||
siteA_h2: params.ADDITIONAL_CONTENT_SITEA_H2,
|
||||
siteA_p: params.ADDITIONAL_CONTENT_SITEA_P,
|
||||
siteB_h2: params.ADDITIONAL_CONTENT_SITEB_H2,
|
||||
siteB_p: params.ADDITIONAL_CONTENT_SITEB_P,
|
||||
ansible_ssh_private_key_file: env.DECYPTED_KEY_FILE
|
||||
]
|
||||
|
||||
ansiblePlaybook(
|
||||
playbook: 'ansible/playbook.yml',
|
||||
inventory: "ansible/inventory.yml",
|
||||
extraVars: [
|
||||
additional_content: sanitized_content,
|
||||
ansible_ssh_private_key_file: env.DECYPTED_KEY_FILE
|
||||
],
|
||||
limit: targetGroups
|
||||
extraVars: extraVars,
|
||||
limit: 'SiteA,SiteB,proxy'
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
|
@ -1,16 +1,16 @@
|
||||
siteA:
|
||||
site_title: "SiteA - Добро пожаловать"
|
||||
site_h1: "Добро пожаловать на SiteA"
|
||||
site_h2: "Секция SiteA"
|
||||
site_p: "Это дополнительный параграф для SiteA."
|
||||
site_h2: "{{ siteA_h2 }}"
|
||||
site_p: "{{ siteA_p }}"
|
||||
site_domain: "siteA.example.com"
|
||||
site_ip: "192.168.0.61"
|
||||
|
||||
siteB:
|
||||
site_title: "SiteB - Добро пожаловать"
|
||||
site_h1: "Добро пожаловать на SiteB"
|
||||
site_h2: "Секция SiteB"
|
||||
site_p: "Это дополнительный параграф для SiteB."
|
||||
site_h2: "{{ siteB_h2 }}"
|
||||
site_p: "{{ siteB_p }}"
|
||||
site_domain: "siteB.example.com"
|
||||
site_ip: "192.168.0.62"
|
||||
|
||||
|
@ -17,10 +17,13 @@ server {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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 {
|
||||
return 200 'Proxy is up';
|
||||
add_header Content-Type text/plain;
|
||||
proxy_pass http://backend/health;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user