much tidying up

This commit is contained in:
2026-03-29 21:46:33 -07:00
parent a201c7919a
commit e95dd3efd5
30 changed files with 944 additions and 186 deletions

View File

@ -30,12 +30,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/rip-cd.yaml"
cd /var/jenkins_home/ansible
chmod +x /var/jenkins_home/ansible/inventory/inventory.sh
/var/jenkins_home/ansible/inventory/inventory.sh -s -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 -s -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip}
"""
}
@ -43,22 +47,33 @@ pipeline {
stage('Ansible Playbook') {
steps {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.yaml
// Rip a CD with the cursed playbook I wrote
// /workspace/ansible/playbooks/rip-cd.yaml
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/rip-cd.yaml"
extra_vars=\$(echo " \
CIFS_USERNAME=${env.CIFS_CREDENTIALS_USR} \
CIFS_PASSWORD=${env.CIFS_CREDENTIALS_PSW} \
CIFS_CREDENTIALS=${env.CIFS_CREDENTIALS} \
CIFS_CHOICE=${params.cifs_choice} \
disk_drive=${params.disk_drive} \
extra_verbose=${params.extra_verbose} \
nogap_enable=${params.nogap_enable} \
server_path=${params.server_path} \
eject_drive=${params.eject_drive} \
remove_local_cache=${params.remove_local_cache} \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/rip-cd.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "CIFS_USERNAME=${env.CIFS_CREDENTIALS_USR} CIFS_PASSWORD=${env.CIFS_CREDENTIALS_PSW} \
CIFS_CREDENTIALS=${env.CIFS_CREDENTIALS} CIFS_CHOICE=${params.cifs_choice} \
disk_drive=${params.disk_drive} extra_verbose=${params.extra_verbose} \
nogap_enable=${params.nogap_enable} server_path=${params.server_path} \
eject_drive=${params.eject_drive} remove_local_cache=${params.remove_local_cache}"
--extra-vars "\$extra_vars"
"""
}
@ -69,8 +84,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
"""