Add krb5 stacks generation
This commit is contained in:
115
deploy_krb5.groovy
Normal file
115
deploy_krb5.groovy
Normal file
@ -0,0 +1,115 @@
|
||||
def baseName = 'deploy'
|
||||
def stacks = ['dev-krb5-volatile-iv']
|
||||
def infraRepo = 'gitea@gitea.basealt.ru:saratov/infra.git'
|
||||
def infraBranch = 'master'
|
||||
|
||||
stacks.each { s ->
|
||||
def jobName = "${s}"
|
||||
job(jobName) {
|
||||
label('node-new')
|
||||
logRotator(-1, 10, -1, 10)
|
||||
parameters {
|
||||
stringParam('ENV', 'test', 'infra environment name')
|
||||
stringParam('STACK', "${s}", 'infra stack name')
|
||||
stringParam('TASKS', '', 'comma separated tasks list to add as additional repos')
|
||||
choiceParam('DEPLOY_BRANCH', ['p10', 'sisyphus'], '')
|
||||
choiceParam('DEPLOY_MODE', ['deploy', 'redeploy', 'destroy'], '')
|
||||
}
|
||||
multiscm {
|
||||
git {
|
||||
remote {
|
||||
name('origin')
|
||||
url(infraRepo)
|
||||
credentials('gitea_key')
|
||||
}
|
||||
branch(infraBranch)
|
||||
extensions {
|
||||
submoduleOptions {
|
||||
disable(false)
|
||||
tracking(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
wrappers {
|
||||
colorizeOutput()
|
||||
timestamps()
|
||||
credentialsBinding {
|
||||
string('VAULT_KEY', 'vault-test-key')
|
||||
}
|
||||
sshAgent('robot_key', 'gitea_key')
|
||||
}
|
||||
steps {
|
||||
shell('''#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set -x
|
||||
mkdir -p .tmp/
|
||||
echo ${VAULT_KEY} > .tmp/.pass-${ENV}
|
||||
chmod 600 .tmp/.pass-${ENV}
|
||||
|
||||
if [[ -n "${TASKS+x}" ]]; then
|
||||
sed -ie "s/apt_sources_from_tasks:.*/apt_sources_from_tasks: [$TASKS]/" \
|
||||
vars/conf/stacks/$STACK/apps.yml
|
||||
fi
|
||||
|
||||
if [[ -n "${DEPLOY_BRANCH+x}" ]]; then
|
||||
sed -ie "s/\\(\\s*platform:\\s*\\).*/\\1'$DEPLOY_BRANCH'/g" \
|
||||
vars/conf/stacks/$STACK/stack.yml
|
||||
fi
|
||||
'''.stripIndent())
|
||||
|
||||
shell('''#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set -x
|
||||
rm -f .script
|
||||
cat <<'EOF' >.script
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set -x
|
||||
|
||||
export ANSIBLE_FORCE_COLOR=1
|
||||
export PYTHONUNBUFFERED=1
|
||||
|
||||
params=""
|
||||
|
||||
if [[ "${DEPLOY_MODE}" == "redeploy" ]]; then
|
||||
params="$params -e redeploy_all=yes"
|
||||
elif [[ "${DEPLOY_MODE}" == "destroy" ]]; then
|
||||
params="$params -e destroy_all=yes"
|
||||
fi
|
||||
|
||||
ansible-playbook \
|
||||
-e env_name=$ENV \
|
||||
-e stack_name=$STACK \
|
||||
--vault-id $ENV@.tmp/.pass-$ENV \
|
||||
$params provision.yml
|
||||
|
||||
if [[ "${DEPLOY_MODE}" != "destroy" ]]; then
|
||||
ansible-playbook -i .tmp/ansible_hosts \
|
||||
-e env_name=$ENV \
|
||||
-e stack_name=$STACK \
|
||||
--vault-id $ENV@.tmp/.pass-$ENV \
|
||||
$ENV-$STACK-apps.yml
|
||||
fi
|
||||
EOF
|
||||
chmod +x .script
|
||||
'''.stripIndent())
|
||||
|
||||
shell('''#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set -x
|
||||
rm -rf .tmp/*
|
||||
./.script
|
||||
'''.stripIndent())
|
||||
}
|
||||
|
||||
publishers {
|
||||
archiveArtifacts {
|
||||
pattern('.tmp/ssh_config')
|
||||
pattern('.tmp/domain_config')
|
||||
pattern("vars/conf/stacks/${s}/**")
|
||||
onlyIfSuccessful(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user