From 61acb185e53a89fc9510a4f0d119ddaf5bbdaae6 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 1 Nov 2025 12:13:55 -0700 Subject: [PATCH] add jenkinsfile for ssd_health --- Jenkinsfile.cosmos-nvidia | 9 ++++- Jenkinsfile.cosmos-server | 5 +-- Jenkinsfile.ssd_health | 76 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 Jenkinsfile.ssd_health diff --git a/Jenkinsfile.cosmos-nvidia b/Jenkinsfile.cosmos-nvidia index 34c7821..4d760ca 100644 --- a/Jenkinsfile.cosmos-nvidia +++ b/Jenkinsfile.cosmos-nvidia @@ -7,6 +7,10 @@ pipeline { } environment { + matt_public_key = credentials('matt_public_key') + matt_private_key = credentials('matt_private_key') + cosmos_password = credentials('cosmos_password') + cosmos_root_password = credentials('cosmos_root_password') ANSIBLE_FORCE_COLOR = '1' } @@ -45,7 +49,10 @@ pipeline { cd /var/jenkins_home/ansible ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cosmos-nvidia.yaml \ - --ssh-common-args='-o StrictHostKeyChecking=no' + --ssh-common-args='-o StrictHostKeyChecking=no' \ + --extra-vars "matt_public_key='${env.matt_public_key}' cosmos_password='${env.cosmos_password}' \ + cosmos_root_password='${env.cosmos_root_password}' matt_private_key='${env.matt_private_key}' \ + cosmos_password='${env.cosmos_password}' cosmos_root_password='${env.cosmos_root_password}' " """ } diff --git a/Jenkinsfile.cosmos-server b/Jenkinsfile.cosmos-server index 33341ad..9ae77ad 100644 --- a/Jenkinsfile.cosmos-server +++ b/Jenkinsfile.cosmos-server @@ -6,7 +6,7 @@ pipeline { string(name: 'new_hostname', description: 'Update Hostname') booleanParam(name: 'rename_endpoint', defaultValue: true, description: 'Uncheck to skip renaming of endpoint') booleanParam(name: 'add_domain', defaultValue: true, description: 'When checked hostname will have home.cosmos appended') - // reference for later + booleanParam(name: 'intall_cockpit', defaultValue: false, description: 'Install Cockpit Dashboard') // choice(name: 'DEPLOY_ENV', choices: ['dev', 'staging', 'prod'], description: 'Environment to deploy to') booleanParam(name: 'install_docker', defaultValue: true, description: 'When checked docker packages are installed and portainer started on 9100') booleanParam(name: 'install_LDAP', defaultValue: false, description: 'When checked LDAP integration is installed with NSLCD') @@ -143,7 +143,8 @@ pipeline { 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}' \ tesla_api_key='${tesla_api_key}' public_deploy=${params.public_deploy} \ - install_python=${params.install_python} skip_nvidia=${params.skip_nvidia} " + install_python=${params.install_python} skip_nvidia=${params.skip_nvidia} \ + intall_cockpit=${params.intall_cockpit}" """ } diff --git a/Jenkinsfile.ssd_health b/Jenkinsfile.ssd_health new file mode 100644 index 0000000..3163e88 --- /dev/null +++ b/Jenkinsfile.ssd_health @@ -0,0 +1,76 @@ +pipeline { + agent any + + // Define parameters + parameters { + string(name: 'host_ip', description: 'Target System Address') + // string(name: 'new_hostname', description: 'Update Hostname') + // reference for later + // choice(name: 'DEPLOY_ENV', choices: ['dev', 'staging', 'prod'], description: 'Environment to deploy to') + // booleanParam(name: 'rename_host', defaultValue: true, description: 'When checked hostname will be renamed') + // booleanParam(name: 'config_matt', defaultValue: true, description: 'config matt profile') + } + + environment { + ANSIBLE_FORCE_COLOR = '1' + AUTHORIZED_KEY = credentials('AUTH_SSH_KEY') + matt_public_key = credentials('matt_public_key') + matt_private_key = credentials('matt_private_key') + autologin_password = credentials('cosmos_password') + } + + options { + ansiColor('xterm') + } + + stages { + + stage('Generate Inventory File') { + steps { + + // Generate the dynamic inventory file + sh """ + + 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}) + cd /var/jenkins_home/ansible + chmod +x /var/jenkins_home/ansible/inventory/inventory.sh + /var/jenkins_home/ansible/inventory/inventory.sh -v -s -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} + + """ + } + } + + stage('Ansible Playbook') { + steps { + sh """ + 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" + + cd /var/jenkins_home/ansible + + ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/ssd_health.yaml \ + --ssh-common-args='-o StrictHostKeyChecking=no'\ + --extra-vars "AUTHORIZED_KEY=${AUTHORIZED_KEY} host_ip=${params.host_ip} \ + matt_public_key='${env.matt_public_key}' matt_private_key='${env.matt_private_key}' \ + autologin_password=${env.autologin_password} }" + """ + } + } + } + + post { + always { + // Remove dynamic Inventory file + sh """ + hash=\$(echo -n "${params.host_ip}" | md5sum | cut -c 1-8) + inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml" + rm \$inventory_file + + """ + } + } + +}