much tidying up
This commit is contained in:
@ -1,5 +1,23 @@
|
||||
def specialServers = [
|
||||
'none',
|
||||
'octoprint',
|
||||
'kodi',
|
||||
'timelapse',
|
||||
'pxe_server',
|
||||
'jenkins_vpn',
|
||||
'net_bridge',
|
||||
'carputer',
|
||||
'ssd_check',
|
||||
'gpo_site',
|
||||
'minitemp_api',
|
||||
'cosmostat',
|
||||
'mc_virt'
|
||||
]
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
|
||||
// Define parameters
|
||||
parameters {
|
||||
string(name: 'host_ip', description: 'Target System Address')
|
||||
@ -11,7 +29,7 @@ pipeline {
|
||||
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')
|
||||
// this now needs to have the case sensitive name of the role to run
|
||||
choice(name: 'special_server', choices: ['none', 'octoprint', 'kodi', 'timelapse', 'pxe_server', 'jenkins_vpn', 'net_bridge', 'carputer', 'video_capture', 'vcr_client', 'vcr_server', 'ssd_health', 'gpo_site'], description: 'Choose special server install if desired')
|
||||
choice(name: 'special_server', choices: specialServers, description: 'Choose special server install if desired')
|
||||
booleanParam(name: 'refresh_special', defaultValue: false, description: 'When checked only the special server step is run')
|
||||
booleanParam(name: 'no_vpn', defaultValue: false, description: 'Check this option to remove default cosmos VPN')
|
||||
booleanParam(name: 'public_deploy', defaultValue: true, description: 'Uncheck this option to deploy private SSH key')
|
||||
@ -39,6 +57,7 @@ pipeline {
|
||||
cosmos_root_password = credentials('cosmos_root_password')
|
||||
jenkins_public_key = credentials('jenkins_public_key')
|
||||
tesla_api_key = credentials('tesla_api_key')
|
||||
cosmostat_api_key = credentials("cosmostat_api_key")
|
||||
}
|
||||
|
||||
options {
|
||||
@ -109,12 +128,15 @@ 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/cosmos-server.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}
|
||||
|
||||
|
||||
"""
|
||||
@ -123,30 +145,48 @@ pipeline {
|
||||
|
||||
stage('Ansible Playbook') {
|
||||
steps {
|
||||
//Run the cosmos-base ansible playbook
|
||||
// /workspace/ansible/playbooks/cosmos-base.yaml
|
||||
//Run the cosmos-server ansible playbook
|
||||
// /workspace/ansible/playbooks/cosmos-server.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/cosmos-server.yaml"
|
||||
extra_vars=\$(echo " \
|
||||
new_hostname=${params.new_hostname} \
|
||||
saturn_behemoth=${SATURN_BEHEMOTH} \
|
||||
CIFS_USERNAME=${env.CIFS_CREDENTIALS_USR} \
|
||||
CIFS_PASSWORD=${env.CIFS_CREDENTIALS_PSW} \
|
||||
ITMFG_USERNAME=${env.ITMFG_CREDENTIALS_USR} \
|
||||
ITMFG_PASSWORD=${env.ITMFG_CREDENTIALS_PSW} \
|
||||
docker_full=false \
|
||||
rename_host=${params.rename_endpoint} \
|
||||
onboard_pi=${params.onboard_pi} \
|
||||
linux_ldap_pwd=${LINUX_LDAP_PWD} \
|
||||
install_docker=${params.install_docker} \
|
||||
install_LDAP=${params.install_LDAP} \
|
||||
special_server='${params.special_server}' \
|
||||
refresh_special=${params.refresh_special} \
|
||||
pxe_proxy_password=${pxe_proxy_password} \
|
||||
PXE_API_KEY=${PXE_API_KEY} \
|
||||
no_vpn=${params.no_vpn} add_domain=${params.add_domain} \
|
||||
matt_public_key='${env.matt_public_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} \
|
||||
intall_cockpit=${params.intall_cockpit} \
|
||||
REAL_API_KEY=${env.cosmostat_api_key} \
|
||||
" | tr -s " ")
|
||||
set -x
|
||||
|
||||
cd /var/jenkins_home/ansible
|
||||
|
||||
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cosmos-server.yaml \
|
||||
ansible-playbook -i \$inventory_file \$playbook_file \
|
||||
--ssh-common-args='-o StrictHostKeyChecking=no' \
|
||||
--extra-vars "new_hostname=${params.new_hostname} saturn_behemoth=${SATURN_BEHEMOTH} \
|
||||
CIFS_USERNAME=${env.CIFS_CREDENTIALS_USR} CIFS_PASSWORD=${env.CIFS_CREDENTIALS_PSW} \
|
||||
ITMFG_USERNAME=${env.ITMFG_CREDENTIALS_USR} ITMFG_PASSWORD=${env.ITMFG_CREDENTIALS_PSW} \
|
||||
docker_full=false rename_host=${params.rename_endpoint} onboard_pi=${params.onboard_pi} \
|
||||
linux_ldap_pwd=${LINUX_LDAP_PWD} install_docker=${params.install_docker} \
|
||||
install_LDAP=${params.install_LDAP} special_server='${params.special_server}' \
|
||||
refresh_special=${params.refresh_special} pxe_proxy_password=${pxe_proxy_password} \
|
||||
PXE_API_KEY=${PXE_API_KEY} no_vpn=${params.no_vpn} add_domain=${params.add_domain} \
|
||||
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} \
|
||||
intall_cockpit=${params.intall_cockpit}"
|
||||
--extra-vars "\$extra_vars matt_private_key='${env.matt_private_key}'"
|
||||
|
||||
"""
|
||||
}
|
||||
@ -157,8 +197,10 @@ 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