add jenkinsfile for ssd_health

This commit is contained in:
2025-11-01 12:13:55 -07:00
parent 21db3c8f07
commit 61acb185e5
3 changed files with 87 additions and 3 deletions

View File

@ -7,6 +7,10 @@ pipeline {
} }
environment { 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' ANSIBLE_FORCE_COLOR = '1'
} }
@ -45,7 +49,10 @@ pipeline {
cd /var/jenkins_home/ansible cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cosmos-nvidia.yaml \ 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}' "
""" """
} }

View File

@ -6,7 +6,7 @@ pipeline {
string(name: 'new_hostname', description: 'Update Hostname') string(name: 'new_hostname', description: 'Update Hostname')
booleanParam(name: 'rename_endpoint', defaultValue: true, description: 'Uncheck to skip renaming of endpoint') 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') 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') // 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_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') 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}' \ 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}' \ cosmos_password='${env.cosmos_password}' cosmos_root_password='${env.cosmos_root_password}' \
tesla_api_key='${tesla_api_key}' public_deploy=${params.public_deploy} \ 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}"
""" """
} }

76
Jenkinsfile.ssd_health Normal file
View File

@ -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
"""
}
}
}