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

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

View File

@ -26,12 +26,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/cd-to-iso.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}
"""
@ -40,19 +43,27 @@ pipeline {
stage('Ansible Playbook') {
steps {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.yaml
// Build ISO file with Ansible
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/cd-to-iso.yaml"
extra_vars=\$(echo " \
disk_drive=${params.disk_drive} \
eject_drive=${params.eject_drive} \
destination_path=${params.destination_path} \
create_iso=${params.create_iso} \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cd-to-iso.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "disk_drive=${params.disk_drive} eject_drive=${params.eject_drive} \
destination_path=${params.destination_path} create_iso=${params.create_iso}"
--extra-vars "\$extra_vars"
"""
}
@ -63,8 +74,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
"""

View File

@ -27,12 +27,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/cifs-mount.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,17 +46,27 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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/cifs-mount.yaml"
extra_vars=\$(echo " \
CIFS_USERNAME=${env.CIFS_CREDENTIALS_USR} \
CIFS_PASSWORD=${env.CIFS_CREDENTIALS_PSW} \
server_path=${params.server_path} \
target_path=${params.target_path} \
validate_share=${params.validate_share} \
CIFS_CREDENTIALS=${env.CIFS_CREDENTIALS} \
CIFS_CHOICE=${params.cifs_choice} \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cifs-mount.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} \
server_path=${params.server_path} target_path=${params.target_path} validate_share=${params.validate_share} \
CIFS_CREDENTIALS=${env.CIFS_CREDENTIALS} CIFS_CHOICE=${params.cifs_choice}"
--extra-vars "\$extra_vars"
"""
}
@ -64,8 +77,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
"""

View File

@ -7,6 +7,7 @@ pipeline {
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: 'cosmos_refresh', defaultValue: false, description: 'This just runs the cosmos_init task')
booleanParam(name: 'rename_host', defaultValue: true, description: 'When checked hostname will be renamed')
booleanParam(name: 'config_matt', defaultValue: true, description: 'config matt profile')
booleanParam(name: 'install_LDAP', defaultValue: false, description: 'install LDAP')
@ -37,12 +38,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-base.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}
"""
@ -54,21 +58,36 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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-base.yaml"
extra_vars=\$(echo " \
kde_full=true \
docker_full=true \
rename_host=${params.rename_host} \
no_vpn=${params.remove_default_vpn} \
new_hostname=${params.new_hostname}.home.cosmos \
reboot_host=${params.reboot_host} \
config_matt=${params.config_matt} \
install_LDAP=${params.install_LDAP} \
apps_list=${env.APPS_LIST} \
linux_ldap_pwd=${env.LINUX_LDAP_PWD} \
MATT_PASSWORD=${env.MATT_PASSWORD} \
matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}' \
cosmos_refresh=${env.cosmos_refresh} \
saturn_behemoth=${env.SATURN_BEHEMOTH} \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cosmos-base.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "kde_full=true docker_full=true rename_host=${params.rename_host} no_vpn=${params.remove_default_vpn} \
new_hostname=${params.new_hostname}.home.cosmos saturn_behemoth=${env.SATURN_BEHEMOTH}
reboot_host=${params.reboot_host} config_matt=${params.config_matt} \
apps_list=${env.APPS_LIST} linux_ldap_pwd=${env.LINUX_LDAP_PWD} \
install_LDAP=${params.install_LDAP} MATT_PASSWORD=${env.MATT_PASSWORD} \
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}' "
--extra-vars "\$extra_vars matt_private_key='${env.matt_private_key}'"
"""
}
@ -79,8 +98,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
"""

View File

@ -35,11 +35,13 @@ 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})
cd /var/jenkins_home/ansible
chmod +x /var/jenkins_home/ansible/inventory/inventory.sh
set -x
/var/jenkins_home/ansible/inventory/inventory.sh -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip}
@ -52,9 +54,11 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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"
set -x
cd /var/jenkins_home/ansible
@ -77,8 +81,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
"""

View File

@ -95,21 +95,26 @@ pipeline {
// Generate the dynamic inventory file
// Also create the kiosk variable yaml with hash value
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-kiosk.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}
set +x
hash=\$(echo -n "${params.host_ip}" | md5sum | cut -c 1-8)
kiosk_yaml=/var/jenkins_home/ansible/roles/chrome_kiosk/files/kiosk-\$hash.yaml
echo --- > \$kiosk_yaml
echo kiosk_service_templates: >> \$kiosk_yaml
echo '${params.kiosk_variable}' >> \$kiosk_yaml
echo ... >> \$kiosk_yaml
set -x
ls -lah /var/jenkins_home/ansible/roles/chrome_kiosk/files/*.yaml
cat \$kiosk_yaml
@ -123,24 +128,37 @@ pipeline {
// /workspace/ansible/playbooks/cosmos-kiosk.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"
kiosk_yaml=/var/jenkins_home/ansible/roles/chrome_kiosk/files/kiosk-\$hash.yaml
playbook_file="/var/jenkins_home/ansible/playbooks/cosmos-kiosk.yaml"
extra_vars=\$(echo " \
docker_full=false \
no_vpn=true \
jenkins_kiosk=true \
public_deploy=true \
matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}' \
new_hostname=${params.new_hostname} \
force_x11=${params.force_x11} \
rename_host=${params.rename_endpoint} \
onboard_pi=${params.onboard_pi} \
add_domain=${params.add_domain} \
install_docker=${params.install_docker} \
install_python=${params.install_python} \
refresh_special=${params.refresh_special} \
kiosk_yaml='\$kiosk_yaml' \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cosmos-kiosk.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "docker_full=false no_vpn=true jenkins_kiosk=true public_deploy=true \
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} force_x11=${params.force_x11} \
rename_host=${params.rename_endpoint} onboard_pi=${params.onboard_pi} \
add_domain=${params.add_domain} install_docker=${params.install_docker} \
install_python=${params.install_python} refresh_special=${params.refresh_special} \
kiosk_yaml='\$kiosk_yaml'"
--extra-vars "\$extra_vars"
"""
}
@ -153,10 +171,12 @@ pipeline {
// Remove kiosk_yaml 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"
kiosk_yaml=/var/jenkins_home/ansible/roles/chrome_kiosk/files/kiosk-\$hash.yaml
set -x
rm \$inventory_file
rm \$kiosk_yaml

View File

@ -25,12 +25,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-nvidia.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}
"""
@ -42,17 +45,25 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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-nvidia.yaml"
extra_vars=\$(echo " \
public_deploy=true \
matt_public_key='${env.matt_public_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}'
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cosmos-nvidia.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--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}' "
--extra-vars "\$extra_vars"
"""
}
@ -63,8 +74,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
"""

View File

@ -31,12 +31,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-public.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}
"""
@ -45,21 +48,35 @@ pipeline {
stage('Ansible Playbook') {
steps {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.yaml
//Run the cosmos-public ansible playbook
// /workspace/ansible/playbooks/cosmos-public.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-public.yaml"
extra_vars=\$(echo " \
docker_full=true \
public_deploy=true \
kde_full=false \
new_hostname=${params.new_hostname} \
rename_host=${params.rename_host} \
reboot_host=${params.reboot_host} \
local_username=${params.local_username} \
reset_user=${params.reset_user} \
apps_list=${APPS_LIST} \
matt_public_key='${env.matt_public_key}'\
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}' \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cosmos-public.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "new_hostname=${params.new_hostname} rename_host=${params.rename_host} reboot_host=${params.reboot_host} \
local_username=${params.local_username} kde_full=false apps_list=${APPS_LIST} docker_full=true \
reset_user=${params.reset_user} public_deploy=true matt_public_key='${env.matt_public_key}'\
cosmos_password='${env.cosmos_password}' cosmos_root_password='${env.cosmos_root_password}' "
--extra-vars "\$extra_vars"
"""
}
@ -70,8 +87,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
"""

View File

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

113
Jenkinsfile.cosmostat Normal file
View File

@ -0,0 +1,113 @@
pipeline {
agent any
// Define parameters
parameters {
string(name: 'host_ip', description: 'Target System Address')
string(name: 'custom_port', defaultValue: "80", description: 'To use something other than 80 on the web dashboard')
string(name: 'custom_api_port', defaultValue: "5000", description: 'To use something other than 5000 on the flask API')
booleanParam(name: 'public_dashboard', defaultValue: true, description: 'Enable this option to bind the dashboard to 0.0.0.0')
booleanParam(name: 'quick_refresh', defaultValue: false, description: 'Enable this option to skip init')
booleanParam(name: 'log_output', defaultValue: false, description: 'Enable basic logging')
booleanParam(name: 'debug_output', defaultValue: false, description: 'Enable debug logging output')
booleanParam(name: 'noisy_test', defaultValue: false, description: 'Enable noisy debug logging')
booleanParam(name: 'secure_api', defaultValue: true, description: 'Enable secure API endpoints')
booleanParam(name: 'push_redis', defaultValue: true, description: 'Enable redis backend')
booleanParam(name: 'run_background', defaultValue: true, description: 'Enable flask background task')
booleanParam(name: 'cosmostat_server_reporter', defaultValue: false, description: 'Enable client reporting')
booleanParam(name: 'cosmostat_server', defaultValue: false, description: 'Enable cosmostat server')
}
environment {
ANSIBLE_FORCE_COLOR = '1'
SATURN_BEHEMOTH = credentials('SATURN_BEHEMOTH')
CIFS_CREDENTIALS = credentials("TERRA_BEHEMOTH_SMB")
cosmostat_api_key = credentials("cosmostat_api_key")
}
options {
ansiColor('xterm')
}
stages {
stage('Generate Inventory File') {
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/cosmostat.yaml"
cd /var/jenkins_home/ansible
chmod +x /var/jenkins_home/ansible/inventory/inventory.sh
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}
"""
}
}
stage('Ansible Playbook') {
steps {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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/cosmostat.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} \
quick_refresh=${params.quick_refresh} \
noisy_test=${params.noisy_test} \
debug_output=${params.debug_output} \
secure_api=${params.secure_api} \
push_redis=${params.push_redis} \
run_background=${params.run_background} \
log_output=${params.log_output} \
public_dashboard=${params.public_dashboard} \
custom_port=${params.custom_port} \
custom_api_port=${params.custom_api_port} \
cosmostat_server_reporter=${params.cosmostat_server_reporter} \
cosmostat_server=${params.cosmostat_server} \
REAL_API_KEY=${env.cosmostat_api_key} \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "\$extra_vars"
"""
}
}
}
post {
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
"""
}
}
}

View File

@ -91,12 +91,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/pi-init.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}
"""
}
@ -105,13 +108,16 @@ pipeline {
stage('Ansible Check') {
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/pi-init.yaml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/pi-init.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no'
"""
@ -125,8 +131,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
"""

View File

@ -0,0 +1,76 @@
pipeline {
agent any
// Define parameters
parameters {
string(name: 'host_ip', description: 'Target System Address')
}
environment {
ANSIBLE_FORCE_COLOR = '1'
SSH_CREDENTIALS_ID = 'jenkins-ssh-key'
SATURN_BEHEMOTH = credentials('SATURN_BEHEMOTH')
}
options {
ansiColor('xterm')
}
stages {
stage('Generate Inventory File') {
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/guac-capture.yaml"
cd /var/jenkins_home/ansible
chmod +x /var/jenkins_home/ansible/inventory/inventory.sh
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}
"""
}
}
stage('Ansible Pipeline') {
steps {
//Run the cosmos-base ansible playbook
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/guac-capture.yaml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "saturn_behemoth=${SATURN_BEHEMOTH} "
"""
}
}
}
post {
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
"""
}
}
}

View File

@ -27,15 +27,20 @@ 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/jenkins_vpn.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}
set +x
echo 'echo Hello World' > /var/jenkins_home/ansible/.inv/vpn_check.sh
chmod +x /var/jenkins_home/ansible/.inv/vpn_check.sh
set -x
"""
}
}
@ -45,17 +50,25 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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/jenkins_vpn.yaml"
extra_vars=\$(echo " \
new_hostname=${params.new_hostname}.home.cosmos \
vpn_endpoint='${params.vpn_endpoint}' \
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}' \
matt_public_key='${env.matt_public_key}' \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/jenkins_vpn.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "new_hostname=${params.new_hostname}.home.cosmos vpn_endpoint='${params.vpn_endpoint}' \
cosmos_password='${env.cosmos_password}' cosmos_root_password='${env.cosmos_root_password}' \
matt_public_key='${env.matt_public_key}' matt_private_key='${env.matt_private_key}' "
--extra-vars "\$extra_vars"
"""
}
@ -63,7 +76,6 @@ pipeline {
stage('Ping new VPN host') {
steps {
// Generate the dynamic inventory file
sh """
/var/jenkins_home/ansible/.inv/vpn_check.sh
@ -80,6 +92,7 @@ pipeline {
hash=\$(echo -n "${params.host_ip}" | md5sum | cut -c 1-8)
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
rm \$inventory_file
set -x
rm /var/jenkins_home/ansible/.inv/vpn_check.sh
"""

View File

@ -30,12 +30,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/lldp-scan.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}
"""
}
@ -46,19 +49,31 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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/lldp-scan.yaml"
extra_vars=\$(echo " \
public_deploy=true \
no_vpn=true \
new_hostname=MC-LLDP \
rename_host=true \
fixed_size='--window-size=${params.chrome_resolution}' \
run_test=${params.run_test} \
refresh_only=${params.refresh_only} \
matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}'
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/lldp-scan.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "new_hostname=MC-LLDP fixed_size='--window-size=${params.chrome_resolution}' \
run_test=${params.run_test} rename_host=true refresh_only=${params.refresh_only} \
public_deploy=true no_vpn=true matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' cosmos_root_password='${env.cosmos_root_password}' "
--extra-vars "\$extra_vars"
"""
}
@ -69,8 +84,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
"""

View File

@ -22,12 +22,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/matt-capture.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}
"""
}
@ -37,14 +41,16 @@ pipeline {
steps {
//Run the cosmos-base ansible playbook
sh """
set +x
echo ${params.host_ip}
hash=\$(echo -n ${params.host_ip} | md5sum | cut -c 1-8)
playbook_file="/var/jenkins_home/ansible/playbooks/matt-capture.yaml"
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/matt-capture.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "saturn_behemoth=${SATURN_BEHEMOTH} "
@ -57,8 +63,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
"""

View File

@ -22,12 +22,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/mattgpt-capture.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}
"""
}
@ -37,14 +41,16 @@ pipeline {
steps {
//Run the cosmos-base ansible playbook
sh """
set +x
echo ${params.host_ip}
hash=\$(echo -n ${params.host_ip} | md5sum | cut -c 1-8)
playbook_file="/var/jenkins_home/ansible/playbooks/mattgpt-capture.yaml"
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/mattgpt-capture.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "saturn_behemoth=${SATURN_BEHEMOTH} "
@ -57,8 +63,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
"""

112
Jenkinsfile.mc-vizz Normal file
View File

@ -0,0 +1,112 @@
pipeline {
agent any
// Define parameters
parameters {
string(name: 'host_ip', description: 'Target System Address')
//booleanParam(name: 'cosmostat_server', defaultValue: false, description: 'Enable cosmostat server')
}
environment {
ANSIBLE_FORCE_COLOR = '1'
cosmos_password = credentials('cosmos_password')
cosmos_root_password = credentials('cosmos_root_password')
jenkins_public_key = credentials('jenkins_public_key')
cosmostat_api_key = credentials("cosmostat_api_key")
}
options {
ansiColor('xterm')
}
stages {
stage('Generate Inventory File') {
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
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}
"""
}
}
stage('Ansible Playbook') {
steps {
//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/mc_vizz.yaml"
extra_vars=\$(echo " \
new_hostname=MC-Vizz \
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 \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "\$extra_vars matt_private_key='${env.matt_private_key}'"
"""
}
}
}
post {
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
"""
}
}
}

View File

@ -6,7 +6,6 @@ pipeline {
string(name: 'host_ip', description: 'Target System Address')
choice(name: 'new_hostname', choices: ['MC-Friendly', 'MC-NanoPi2a', 'MC-NanoPi2b', 'MC-NanoPi2c', 'MC-ZeroPi2', 'MC-RickyPi' ], description: 'Select Hostname for VPN config')
// string(name: 'new_hostname', description: 'New Hostname, must match valid CN for VPN')
booleanParam(name: 'onboard_pi', defaultValue: true, description: 'Check this option to onboard a new FriendlyElec Device')
booleanParam(name: 'redirect_all', defaultValue: false, description: 'Redirect all traffic through VPN')
}
@ -72,15 +71,18 @@ pipeline {
steps {
// Generate the dynamic inventory files
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/puck_vpn.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}
vpn_ip=\$(cat /var/jenkins_home/ansible/roles/puck_vpn/vars/endpoints/${params.new_hostname}.yaml | grep remote_gateway | cut -d '"' -f 2)
/var/jenkins_home/ansible/inventory/inventory.sh -s -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i \$vpn_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}
/var/jenkins_home/ansible/inventory/inventory.sh -p \$playbook_file -s -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i \$vpn_ip
"""
}
@ -114,17 +116,26 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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/puck_vpn.yaml"
extra_vars=\$(echo " \
new_hostname=${params.new_hostname} \
matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}' \
redirect_all=${params.redirect_all} \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/puck_vpn.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "new_hostname=${params.new_hostname} matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' cosmos_root_password='${env.cosmos_root_password}' \
redirect_all=${params.redirect_all} "
--extra-vars "\$extra_vars"
"""
}
}
@ -156,14 +167,17 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.yaml
sh """
set +x
vpn_ip=\$(cat /var/jenkins_home/ansible/roles/puck_vpn/vars/endpoints/${params.new_hostname}.yaml | grep remote_gateway | cut -d '"' -f 2)
echo \$vpn_ip
hash=\$(echo -n \$vpn_ip | md5sum | cut -c 1-8)
playbook_file="/var/jenkins_home/ansible/playbooks/puck_routing.yaml"
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/puck_routing.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no'
"""
@ -175,13 +189,17 @@ pipeline {
always {
// Remove dynamic Inventory files
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
set +x
vpn_ip=\$(cat /var/jenkins_home/ansible/roles/puck_vpn/vars/endpoints/${params.new_hostname}.yaml | grep remote_gateway | cut -d '"' -f 2)
hash=\$(echo -n "\$vpn_ip" | md5sum | cut -c 1-8)
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
set -x
rm \$inventory_file || true
"""

View File

@ -110,12 +110,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/pi-top.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}
"""
}
@ -129,15 +132,22 @@ pipeline {
}
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/pi-top.yaml"
extra_vars=\$(echo " \
function=${params.function} \
admin_username='${params.admin_username}' \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/pi-top.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars " function=${params.function} admin_username='${params.admin_username}' "
--extra-vars "\$extra_vars"
"""
}
@ -150,8 +160,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
"""

View File

@ -59,12 +59,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/pi-init.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}
"""
}
@ -73,13 +77,16 @@ pipeline {
stage('Ansible Check') {
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/pi-init.yaml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/pi-init.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no'
"""
@ -93,8 +100,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
"""

View File

@ -22,12 +22,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/public-capture.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}
"""
}
@ -37,14 +41,16 @@ pipeline {
steps {
//Run the cosmos-base ansible playbook
sh """
set +x
echo ${params.host_ip}
hash=\$(echo -n ${params.host_ip} | md5sum | cut -c 1-8)
playbook_file="/var/jenkins_home/ansible/playbooks/public-capture.yaml"
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/public-capture.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "saturn_behemoth=${SATURN_BEHEMOTH} "
@ -57,8 +63,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
"""

View File

@ -21,8 +21,6 @@ pipeline {
ANSIBLE_FORCE_COLOR = '1'
SATURN_BEHEMOTH = credentials('SATURN_BEHEMOTH')
APPS_LIST = 'pxe-server'
pxe_proxy_password = credentials('pxe_proxy_password')
PXE_API_KEY = credentials('PXE_API_KEY')
LINUX_LDAP_PWD = credentials('LINUX_LDAP')
AUTHORIZED_KEY = credentials('AUTH_SSH_KEY')
matt_public_key = credentials('matt_public_key')
@ -42,12 +40,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/pxe-server.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}
"""
}
@ -58,25 +60,37 @@ pipeline {
//Run the pxe-server ansible playbook
// /workspace/ansible/playbooks/pxe-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/pxe-server.yaml"
extra_vars=\$(echo " \
new_hostname=debian-pxe.home.cosmos \
saturn_behemoth=${SATURN_BEHEMOTH} \
authorized_key=${AUTHORIZED_KEY} \
rename_host=true apps_list=${APPS_LIST} \
matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}'
listen_interface=${params.iface} \
internet_interface=${params.inet_iface} \
dhcp_subnet=${params.dhcp_subnet} \
dhcp_netmask=${params.dhcp_netmask} \
dhcp_start=${params.dhcp_start} \
dhcp_end=${params.dhcp_end} \
server_ip=${params.server_ip} \
router_ip=${params.router_ip} \
configure_routing=${params.configure_routing} \
refresh_only=${params.refresh_only} \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/pxe-server.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "new_hostname=debian-pxe.home.cosmos saturn_behemoth=${SATURN_BEHEMOTH} authorized_key=${AUTHORIZED_KEY} \
rename_host=true apps_list=${APPS_LIST} listen_interface=${params.iface} pxe_auth=${pxe_proxy_password} \
internet_interface=${params.inet_iface} dhcp_subnet=${params.dhcp_subnet} \
dhcp_netmask=${params.dhcp_netmask} dhcp_start=${params.dhcp_start} \
dhcp_end=${params.dhcp_end} server_ip=${params.server_ip} \
router_ip=${params.router_ip} configure_routing=${params.configure_routing} \
refresh_only=${params.refresh_only} \
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}' "
--extra-vars "\$extra_vars matt_private_key='${env.matt_private_key}' "
"""
}
@ -87,8 +101,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
"""

View File

@ -25,12 +25,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/rename-endpoint.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}
"""
}
@ -40,13 +44,16 @@ pipeline {
steps {
//Run the cosmos-base ansible playbook
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/rename-endpoint.yaml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/rename-endpoint.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "new_hostname=${params.new_hostname} add_domain=${params.add_domain}"
@ -59,8 +66,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
"""

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

View File

@ -35,13 +35,17 @@ pipeline {
// 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/ssd_health.yaml"
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}
set -x
/var/jenkins_home/ansible/inventory/inventory.sh -p \$playbook_file -v -s -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip}
"""
}
@ -50,20 +54,31 @@ 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/ssd_health.yaml"
extra_vars=\$(echo " \
public_deploy=true \
AUTHORIZED_KEY=${AUTHORIZED_KEY} \
matt_public_key='${env.matt_public_key}' \
autologin_password=${env.autologin_password} \
cosmos_root_password='${env.cosmos_root_password}' \
cosmos_password='${env.cosmos_password}' \
host_ip=${params.host_ip} \
install_kiosk=${params.install_kiosk} \
service_only=${params.service_only} \
quick_refresh=${params.quick_refresh} \
rename_endpoint=${params.rename_endpoint} \
" | tr -s " ")
set -x
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} cosmos_root_password='${env.cosmos_root_password}' \
cosmos_password='${env.cosmos_password}' install_kiosk=${params.install_kiosk} \
service_only=${params.service_only} quick_refresh=${params.quick_refresh} \
rename_endpoint=${params.rename_endpoint} "
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "\$extra_vars"
"""
}
}
@ -73,8 +88,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
"""

View File

@ -25,6 +25,7 @@ pipeline {
cosmos_password = credentials('cosmos_password')
cosmos_root_password = credentials('cosmos_root_password')
vm_party_username_password = credentials('cosmos_root_password')
cosmostat_api_key = credentials("cosmostat_api_key")
is_admin = '0'
}
@ -39,13 +40,17 @@ pipeline {
// 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})
cd /var/jenkins_home/ansible
playbook_file="/var/jenkins_home/ansible/playbooks/test.yaml"
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}
set -x
/var/jenkins_home/ansible/inventory/inventory.sh -p \$playbook_file -v -s -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip}
"""
}
@ -54,22 +59,35 @@ 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/test.yaml"
extra_vars=\$(echo " \
host_ip=${params.host_ip} \
saturn_behemoth=${SATURN_BEHEMOTH} \
linux_ldap_pwd=${LINUX_LDAP_PWD} \
pxe_proxy_password=${pxe_proxy_password} \
PXE_API_KEY=${PXE_API_KEY} \
AUTHORIZED_KEY=${AUTHORIZED_KEY} \
TERRA_BEHEMOTH_SMB=${TERRA_BEHEMOTH_SMB} \
CIFS_USERNAME=${env.TERRA_BEHEMOTH_SMB_USR} \
CIFS_PASSWORD=${env.TERRA_BEHEMOTH_SMB_PSW} \
MATT_PASSWORD=${env.MATT_PASSWORD} \
matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}' \
vm_party_username_password=${env.vm_party_username_password} \
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/test.yaml \
--ssh-common-args='-o StrictHostKeyChecking=no'\
--extra-vars "saturn_behemoth=${SATURN_BEHEMOTH} linux_ldap_pwd=${LINUX_LDAP_PWD} \
pxe_proxy_password=${pxe_proxy_password} PXE_API_KEY=${PXE_API_KEY} \
AUTHORIZED_KEY=${AUTHORIZED_KEY} TERRA_BEHEMOTH_SMB=${TERRA_BEHEMOTH_SMB} \
CIFS_USERNAME=${env.TERRA_BEHEMOTH_SMB_USR} CIFS_PASSWORD=${env.TERRA_BEHEMOTH_SMB_PSW} \
MATT_PASSWORD=${env.MATT_PASSWORD} host_ip=${params.host_ip} \
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}' \
vm_party_username_password=${env.vm_party_username_password} }"
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "\$extra_vars matt_private_key='${env.matt_private_key}'"
"""
}
}
@ -79,8 +97,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
"""

View File

@ -22,12 +22,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/trixie_upgrade.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}
"""
}
@ -38,13 +42,16 @@ pipeline {
// Run the trixie_upgrade ansible playbook
// /workspace/ansible/playbooks/trixie_upgrade.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/trixie_upgrade.yaml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/trixie_upgrade.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no'
"""
@ -56,8 +63,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
"""

View File

@ -4,6 +4,7 @@ pipeline {
// Define parameters
parameters {
string(name: 'host_ip', description: 'Target System Address')
booleanParam(name: 'server_only', defaultValue: false, description: 'Check this to skip desktop packages')
}
environment {
@ -21,12 +22,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/update-endpoint.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}
"""
}
}
@ -36,14 +41,18 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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/update-endpoint.yaml"
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/update-endpoint.yaml \
--ssh-common-args='-o StrictHostKeyChecking=no'
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars " server_only=${params.server_only} "
"""
}
@ -54,8 +63,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
"""

View File

@ -44,12 +44,16 @@ pipeline {
}
// Generate the dynamic inventory files
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})
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}
playbook_file="/var/jenkins_home/ansible/playbooks/vm_party.yaml
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}
echo Stage Two Hash: ${env.STAGE_TWO_HASH}
"""
@ -64,19 +68,30 @@ pipeline {
//Run the cosmos-base ansible playbook
// /workspace/ansible/playbooks/cosmos-base.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/vm_party.yaml
extra_vars=\$(echo " \
run_stage_two=false \
new_hostname=${params.new_hostname} \
autologin=${params.autologin} \
service_only=${params.service_only} \
update_party=${params.update_party} \
matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}' \
STAGE_TWO_HASH=${env.STAGE_TWO_HASH} \
vm_party_username_password=${env.vm_party_username_password} \
" | tr -s " " )
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/vm_party.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "new_hostname=${params.new_hostname} matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' cosmos_root_password='${env.cosmos_root_password}' \
STAGE_TWO_HASH=${env.STAGE_TWO_HASH} update_party=${params.update_party} \
run_stage_two=false vm_party_username_password=${env.vm_party_username_password} \
autologin=${params.autologin} service_only=${params.service_only} "
--extra-vars "\$extra_vars"
"""
}
}
@ -111,22 +126,26 @@ pipeline {
sleep(waitInterval)
}
}
// check for forbidden subnet
// Run the stage two playbook
// using the hash
sh """
set +x
inventory_file="/var/jenkins_home/ansible/.inv/inventory-${env.STAGE_TWO_HASH}.yml"
playbook_file="/var/jenkins_home/ansible/playbooks/vm_party.yaml"
extra_vars="\$(echo " \
run_stage_two=true \
vm_party_username_password=${env.vm_party_username_password} \
service_only=${params.service_only} \
" | tr -s " " )
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/vm_party.yaml \
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "run_stage_two=true vm_party_username_password=${env.vm_party_username_password} \
service_only=${params.service_only} "
--extra-vars "\$extra_vars"
"""
}
@ -137,12 +156,14 @@ pipeline {
always {
// Remove dynamic Inventory files
sh """
set +x
hash=\$(echo -n "${params.host_ip}" | md5sum | cut -c 1-8)
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
rm \$inventory_file || true
inventory_file_1="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
inventory_file_2="/var/jenkins_home/ansible/.inv/inventory-${env.STAGE_TWO_HASH}.yml"
set -x
inventory_file="/var/jenkins_home/ansible/.inv/inventory-${env.STAGE_TWO_HASH}.yml"
rm \$inventory_file || true
rm \$inventory_file_1 || true
rm \$inventory_file_2 || true
"""
}

View File

@ -0,0 +1,55 @@
pipeline {
agent any
environment {
ANSIBLE_FORCE_COLOR = '1'
SATURN_BEHEMOTH = credentials('SATURN_BEHEMOTH')
LINUX_LDAP_PWD = credentials('LINUX_LDAP')
AUTHORIZED_KEY = credentials('AUTH_SSH_KEY')
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')
EMAIL_RECIPIENTS = "matt@theregion.beer"
}
options {
ansiColor('xterm')
}
stages {
stage('Ansible Playbook') {
steps {
//Run the pxe-server ansible playbook
// /workspace/ansible/playbooks/pxe-server.yaml
sh """
set +x
inventory_file="/var/jenkins_home/ansible/inventory/automation/pxe.yaml"
playbook_file="/var/jenkins_home/ansible/playbooks/pxe-server.yaml"
extra_vars=\$(echo " \
new_hostname=debian-pxe.home.cosmos \
saturn_behemoth=${SATURN_BEHEMOTH} \
authorized_key=${AUTHORIZED_KEY} \
rename_host=true \
matt_public_key='${env.matt_public_key}' \
cosmos_password='${env.cosmos_password}' \
cosmos_root_password='${env.cosmos_root_password}' \
quick_refresh='false' \
refresh_special='false' \
" | tr -s " ")
set -x
cd /var/jenkins_home/ansible
ansible-playbook -i \$inventory_file \$playbook_file \
--ssh-common-args='-o StrictHostKeyChecking=no' \
--extra-vars "\$extra_vars matt_private_key='${env.matt_private_key}'
"""
}
}
}
}