much tidying up
This commit is contained in:
@ -93,12 +93,16 @@ pipeline {
|
||||
steps {
|
||||
// Generate the dynamic inventory file
|
||||
sh """
|
||||
set +x
|
||||
jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep -v \$SERVER_SUBNET_GROUP | grep Jenkins | head -n 1)
|
||||
jenkins_subnet_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep -e authenticated -e \$SERVER_SUBNET_GROUP | sort -rf | head -n 1)
|
||||
jenkins_user=\$(echo ${env.BUILD_USER})
|
||||
playbook_file="/var/jenkins_home/ansible/playbooks/VCR-capture.yaml"
|
||||
cd /var/jenkins_home/ansible
|
||||
chmod +x /var/jenkins_home/ansible/inventory/inventory.sh
|
||||
/var/jenkins_home/ansible/inventory/inventory.sh -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip}
|
||||
set -x
|
||||
|
||||
/var/jenkins_home/ansible/inventory/inventory.sh -p \$playbook_file -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip}
|
||||
|
||||
"""
|
||||
}
|
||||
@ -107,23 +111,38 @@ pipeline {
|
||||
stage('Ansible Playbook') {
|
||||
steps {
|
||||
sh """
|
||||
set +x
|
||||
echo ${params.host_ip}
|
||||
hash=\$(echo -n ${params.host_ip} | md5sum | cut -c 1-8)
|
||||
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
|
||||
playbook_file="/var/jenkins_home/ansible/playbooks/VCR-capture.yaml"
|
||||
extra_vars=\$(echo " \
|
||||
docker_full=false \
|
||||
no_vpn=true \
|
||||
add_domain=false \
|
||||
matt_public_key='${env.matt_public_key}' \
|
||||
cosmos_password='${env.cosmos_password}' \
|
||||
cosmos_root_password='${env.cosmos_root_password}' \
|
||||
new_hostname=${params.new_hostname} \
|
||||
refresh_special=${params.refresh_special} \
|
||||
rename_host=${params.rename_endpoint} \
|
||||
onboard_pi=${params.onboard_pi} \
|
||||
public_deploy=${params.public_deploy} \
|
||||
jellyfin_deploy=${params.jellyfin_deploy} \
|
||||
GUI_deploy=${params.GUI_deploy} \
|
||||
extra_storage=${params.extra_storage} \
|
||||
luna_offload=${params.luna_offload} \
|
||||
kiosk_refresh=${params.kiosk_refresh} \
|
||||
remote_deploy=${params.remote_deploy} \
|
||||
server_deploy=${params.server_deploy}
|
||||
" | tr -s " ")
|
||||
set -x
|
||||
|
||||
cd /var/jenkins_home/ansible
|
||||
|
||||
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/VCR-capture.yaml \
|
||||
ansible-playbook -i \$inventory_file \$playbook_file \
|
||||
--ssh-common-args='-o StrictHostKeyChecking=no' \
|
||||
--extra-vars "docker_full=false no_vpn=true add_domain=false \
|
||||
matt_public_key='${env.matt_public_key}' matt_private_key='${env.matt_private_key}' \
|
||||
cosmos_password='${env.cosmos_password}' cosmos_root_password='${env.cosmos_root_password}' \
|
||||
new_hostname=${params.new_hostname} refresh_special=${params.refresh_special} \
|
||||
rename_host=${params.rename_endpoint} onboard_pi=${params.onboard_pi} \
|
||||
public_deploy=${params.public_deploy} jellyfin_deploy=${params.jellyfin_deploy} \
|
||||
GUI_deploy=${params.GUI_deploy} extra_storage=${params.extra_storage} \
|
||||
luna_offload=${params.luna_offload} kiosk_refresh=${params.kiosk_refresh} \
|
||||
remote_deploy=${params.remote_deploy} server_deploy=${params.server_deploy}"
|
||||
--extra-vars "\$extra_vars matt_private_key='${env.matt_private_key}'"
|
||||
|
||||
"""
|
||||
}
|
||||
@ -134,8 +153,11 @@ pipeline {
|
||||
always {
|
||||
// Remove dynamic Inventory file
|
||||
sh """
|
||||
set +x
|
||||
hash=\$(echo -n "${params.host_ip}" | md5sum | cut -c 1-8)
|
||||
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
|
||||
set -x
|
||||
|
||||
rm \$inventory_file
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user