diff --git a/Jenkinsfile.VCR-capture b/Jenkinsfile.VCR-capture index 744ecd6..a15c2ef 100644 --- a/Jenkinsfile.VCR-capture +++ b/Jenkinsfile.VCR-capture @@ -10,6 +10,10 @@ pipeline { booleanParam(name: 'onboard_pi', defaultValue: false, description: 'Check this option to onboard a new FriendlyElec Device') booleanParam(name: 'GUI_deploy', defaultValue: false, description: 'Check this option to set up GUI if possible') booleanParam(name: 'jellyfin_deploy', defaultValue: false, description: 'Check this option to install Jellyfin') + booleanParam(name: 'luna_offload', defaultValue: false, description: 'Check this option to offload MediaMTX to luna.cosmos') + booleanParam(name: 'kiosk_refresh', defaultValue: false, description: 'Check this option to only refresh the chrome kiosk') + booleanParam(name: 'remote_deploy', defaultValue: false, description: 'Deploy as low-power transmit only node.') + booleanParam(name: 'server_deploy', defaultValue: false, description: 'Deploy as server to receive from remote deploy node') booleanParam(name: 'extra_storage', defaultValue: false, description: 'Check this option to automatically configure the secondary storage. Be careful.') } @@ -85,14 +89,15 @@ pipeline { } } - stage('Generate Inventory File') { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } @@ -100,8 +105,6 @@ pipeline { stage('Ansible Playbook') { steps { - //Run the VCR-captute ansible playbook - // /workspace/ansible/playbooks/cosmos-base.yaml sh """ echo ${params.host_ip} hash=\$(echo -n ${params.host_ip} | md5sum | cut -c 1-8) @@ -111,13 +114,15 @@ pipeline { ansible-playbook -i \$inventory_file \ /var/jenkins_home/ansible/playbooks/VCR-capture.yaml --ssh-common-args='-o StrictHostKeyChecking=no' \ - --extra-vars "docker_full=false no_vpn=true add_domain=false \ + --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} " + 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}" """ } diff --git a/Jenkinsfile.behemoth_containers b/Jenkinsfile.behemoth_containers index de0b141..e96f2e2 100644 --- a/Jenkinsfile.behemoth_containers +++ b/Jenkinsfile.behemoth_containers @@ -16,9 +16,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${env.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } diff --git a/Jenkinsfile.cd-to-iso b/Jenkinsfile.cd-to-iso index 9a190c9..e7a4282 100644 --- a/Jenkinsfile.cd-to-iso +++ b/Jenkinsfile.cd-to-iso @@ -26,9 +26,12 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} + """ } diff --git a/Jenkinsfile.cifs-mount b/Jenkinsfile.cifs-mount index 2b64e21..7de496b 100644 --- a/Jenkinsfile.cifs-mount +++ b/Jenkinsfile.cifs-mount @@ -27,9 +27,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } diff --git a/Jenkinsfile.cosmos-base b/Jenkinsfile.cosmos-base index e9d5cd2..6f2eb27 100644 --- a/Jenkinsfile.cosmos-base +++ b/Jenkinsfile.cosmos-base @@ -37,9 +37,12 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} + """ } diff --git a/Jenkinsfile.cosmos-console b/Jenkinsfile.cosmos-console index 446e6a8..c003613 100644 --- a/Jenkinsfile.cosmos-console +++ b/Jenkinsfile.cosmos-console @@ -35,9 +35,12 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} + """ } diff --git a/Jenkinsfile.cosmos-kiosk b/Jenkinsfile.cosmos-kiosk index e06da82..3e85b14 100644 --- a/Jenkinsfile.cosmos-kiosk +++ b/Jenkinsfile.cosmos-kiosk @@ -8,7 +8,6 @@ pipeline { 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: 'install_docker', defaultValue: true, description: 'When checked docker packages are installed and portainer started on 9100') - booleanParam(name: 'public_deploy', defaultValue: true, description: 'Uncheck this option to deploy private SSH key') booleanParam(name: 'onboard_pi', defaultValue: false, description: 'Check this option to onboard a new FriendlyElec Device') booleanParam(name: 'install_python', defaultValue: false, description: 'Check this option to install python packages') booleanParam(name: 'refresh_special', defaultValue: false, description: 'When checked the autologin account and kiosk are refreshed only') @@ -97,9 +96,12 @@ pipeline { // Also create the kiosk variable yaml with hash value sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} + hash=\$(echo -n "${params.host_ip}" | md5sum | cut -c 1-8) kiosk_yaml=/var/jenkins_home/ansible/roles/chrome_kiosk/files/kiosk-\$hash.yaml @@ -130,14 +132,14 @@ pipeline { ansible-playbook -i \$inventory_file \ /var/jenkins_home/ansible/playbooks/cosmos-kiosk.yaml --ssh-common-args='-o StrictHostKeyChecking=no' \ - --extra-vars "docker_full=false no_vpn=true jenkins_kiosk=true \ + --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} public_deploy=${params.public_deploy} \ + 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} \ - force_x11=${params.force_x11} kiosk_yaml='\$kiosk_yaml'" + kiosk_yaml='\$kiosk_yaml'" """ } diff --git a/Jenkinsfile.cosmos-nvidia b/Jenkinsfile.cosmos-nvidia index 2800e1e..70cf462 100644 --- a/Jenkinsfile.cosmos-nvidia +++ b/Jenkinsfile.cosmos-nvidia @@ -21,9 +21,12 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} + """ } diff --git a/Jenkinsfile.cosmos-public b/Jenkinsfile.cosmos-public index dff3869..ccc322b 100644 --- a/Jenkinsfile.cosmos-public +++ b/Jenkinsfile.cosmos-public @@ -31,9 +31,12 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} + """ } diff --git a/Jenkinsfile.cosmos-server b/Jenkinsfile.cosmos-server index 956680d..3c9b922 100644 --- a/Jenkinsfile.cosmos-server +++ b/Jenkinsfile.cosmos-server @@ -11,7 +11,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'], description: 'Choose special server install if desired') + choice(name: 'special_server', choices: ['none', 'octoprint', 'kodi', 'timelapse', 'pxe_server', 'jenkins_vpn', 'net_bridge', 'carputer', 'video_capture', 'vcr_client', 'vcr_server'], 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') @@ -27,6 +27,7 @@ pipeline { environment { ANSIBLE_FORCE_COLOR = '1' SATURN_BEHEMOTH = credentials('SATURN_BEHEMOTH') + CIFS_CREDENTIALS = credentials("TERRA_BEHEMOTH_SMB") APPS_LIST = 'cosmos-base' LINUX_LDAP_PWD = credentials('LINUX_LDAP') pxe_proxy_password = credentials('pxe_proxy_password') @@ -107,9 +108,12 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} + """ } @@ -129,6 +133,7 @@ pipeline { ansible-playbook -i \$inventory_file \ /var/jenkins_home/ansible/playbooks/cosmos-server.yaml --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} \ 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}' \ diff --git a/Jenkinsfile.deb_init b/Jenkinsfile.deb_init index ff8359e..39414d8 100644 --- a/Jenkinsfile.deb_init +++ b/Jenkinsfile.deb_init @@ -91,9 +91,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } diff --git a/Jenkinsfile.jenkins_vpn b/Jenkinsfile.jenkins_vpn index d06f08e..9172ac3 100644 --- a/Jenkinsfile.jenkins_vpn +++ b/Jenkinsfile.jenkins_vpn @@ -27,9 +27,12 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} + echo 'echo Hello World' > /var/jenkins_home/ansible/.inv/vpn_check.sh chmod +x /var/jenkins_home/ansible/.inv/vpn_check.sh """ diff --git a/Jenkinsfile.lldp-scanner b/Jenkinsfile.lldp-scanner index 010d845..ead1ccb 100644 --- a/Jenkinsfile.lldp-scanner +++ b/Jenkinsfile.lldp-scanner @@ -30,9 +30,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ - cd /var/jenkins_home/ansible - chmod +x /var/jenkins_home/ansible/inventory/generate_inventory.sh - /var/jenkins_home/ansible/inventory/generate_inventory.sh ${params.host_ip} + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } @@ -60,7 +62,12 @@ pipeline { post { always { // Remove dynamic Inventory file - sh "rm /var/jenkins_home/ansible/.inv/inventory-${params.host_ip}.yml" + 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 + + """ } } diff --git a/Jenkinsfile.matt-profile-capture b/Jenkinsfile.matt-profile-capture index d1977c1..f64310b 100644 --- a/Jenkinsfile.matt-profile-capture +++ b/Jenkinsfile.matt-profile-capture @@ -22,9 +22,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | head -n 1) + jenkins_user=\$(echo ${env.BUILD_USER}) cd /var/jenkins_home/ansible - chmod +x /var/jenkins_home/ansible/inventory/generate_inventory.sh - /var/jenkins_home/ansible/inventory/generate_inventory.sh ${params.host_ip} + chmod +x /var/jenkins_home/ansible/inventory/inventory.sh + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } @@ -48,7 +50,12 @@ pipeline { post { always { // Remove dynamic Inventory file - sh "rm /var/jenkins_home/ansible/.inv/inventory-${params.host_ip}.yml" + 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 + + """ } } diff --git a/Jenkinsfile.mattgpt-capture b/Jenkinsfile.mattgpt-capture index d4328d5..8310d78 100644 --- a/Jenkinsfile.mattgpt-capture +++ b/Jenkinsfile.mattgpt-capture @@ -22,9 +22,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | head -n 1) + jenkins_user=\$(echo ${env.BUILD_USER}) cd /var/jenkins_home/ansible - chmod +x /var/jenkins_home/ansible/inventory/generate_inventory.sh - /var/jenkins_home/ansible/inventory/generate_inventory.sh ${params.host_ip} + chmod +x /var/jenkins_home/ansible/inventory/inventory.sh + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } @@ -48,7 +50,12 @@ pipeline { post { always { // Remove dynamic Inventory file - sh "rm /var/jenkins_home/ansible/.inv/inventory-${params.host_ip}.yml" + 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 + + """ } } diff --git a/Jenkinsfile.mc_vpn b/Jenkinsfile.mc_vpn index da38e31..9ce4ba4 100644 --- a/Jenkinsfile.mc_vpn +++ b/Jenkinsfile.mc_vpn @@ -72,11 +72,14 @@ pipeline { steps { // Generate the dynamic inventory files sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -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 \$vpn_ip + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i \$vpn_ip """ } diff --git a/Jenkinsfile.pi-top b/Jenkinsfile.pi-top index a41aa6c..207b617 100644 --- a/Jenkinsfile.pi-top +++ b/Jenkinsfile.pi-top @@ -110,9 +110,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } diff --git a/Jenkinsfile.pi_init b/Jenkinsfile.pi_init index 9dd517f..853e9a6 100644 --- a/Jenkinsfile.pi_init +++ b/Jenkinsfile.pi_init @@ -59,9 +59,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } diff --git a/Jenkinsfile.public-profile-capture b/Jenkinsfile.public-profile-capture index 89734e4..e08bcd1 100644 --- a/Jenkinsfile.public-profile-capture +++ b/Jenkinsfile.public-profile-capture @@ -22,9 +22,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | head -n 1) + jenkins_user=\$(echo ${env.BUILD_USER}) cd /var/jenkins_home/ansible - chmod +x /var/jenkins_home/ansible/inventory/generate_inventory.sh - /var/jenkins_home/ansible/inventory/generate_inventory.sh ${params.host_ip} + chmod +x /var/jenkins_home/ansible/inventory/inventory.sh + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } @@ -48,7 +50,12 @@ pipeline { post { always { // Remove dynamic Inventory file - sh "rm /var/jenkins_home/ansible/.inv/inventory-${params.host_ip}.yml" + 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 + + """ } } diff --git a/Jenkinsfile.pxe-server b/Jenkinsfile.pxe-server index 7a8355a..714cc45 100644 --- a/Jenkinsfile.pxe-server +++ b/Jenkinsfile.pxe-server @@ -42,9 +42,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | head -n 1) + jenkins_user=\$(echo ${env.BUILD_USER}) cd /var/jenkins_home/ansible - chmod +x /var/jenkins_home/ansible/inventory/generate_inventory.sh - /var/jenkins_home/ansible/inventory/generate_inventory.sh ${params.host_ip} + chmod +x /var/jenkins_home/ansible/inventory/inventory.sh + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } @@ -77,7 +79,12 @@ pipeline { post { always { // Remove dynamic Inventory file - sh "rm /var/jenkins_home/ansible/.inv/inventory-${params.host_ip}.yml" + 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 + + """ } } diff --git a/Jenkinsfile.rename-endpoint b/Jenkinsfile.rename-endpoint index 6e0ae8b..0d2e69c 100644 --- a/Jenkinsfile.rename-endpoint +++ b/Jenkinsfile.rename-endpoint @@ -25,9 +25,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | head -n 1) + jenkins_user=\$(echo ${env.BUILD_USER}) cd /var/jenkins_home/ansible - chmod +x /var/jenkins_home/ansible/inventory/generate_inventory.sh - /var/jenkins_home/ansible/inventory/generate_inventory.sh ${params.host_ip} + chmod +x /var/jenkins_home/ansible/inventory/inventory.sh + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } @@ -51,7 +53,12 @@ pipeline { post { always { // Remove dynamic Inventory file - sh "rm /var/jenkins_home/ansible/.inv/inventory-${params.host_ip}.yml" + 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 + + """ } } diff --git a/Jenkinsfile.rip-cd b/Jenkinsfile.rip-cd index b50cba8..3b3a9f4 100644 --- a/Jenkinsfile.rip-cd +++ b/Jenkinsfile.rip-cd @@ -30,9 +30,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } diff --git a/Jenkinsfile.test b/Jenkinsfile.test index c6298f1..5e28024 100644 --- a/Jenkinsfile.test +++ b/Jenkinsfile.test @@ -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') + is_admin = '0' } options { @@ -33,15 +34,16 @@ pipeline { stages { - stage('Generate Inventory File') { steps { + // Generate the dynamic inventory file sh """ - + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -s -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } @@ -65,7 +67,7 @@ pipeline { 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} " + vm_party_username_password=${env.vm_party_username_password} }" """ } } diff --git a/Jenkinsfile.trixie_upgrade b/Jenkinsfile.trixie_upgrade index f5b79a3..75f0ad6 100644 --- a/Jenkinsfile.trixie_upgrade +++ b/Jenkinsfile.trixie_upgrade @@ -22,9 +22,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } diff --git a/Jenkinsfile.update-endpoint b/Jenkinsfile.update-endpoint index 0ce2dec..36afc9f 100644 --- a/Jenkinsfile.update-endpoint +++ b/Jenkinsfile.update-endpoint @@ -21,10 +21,11 @@ pipeline { steps { // Generate the dynamic inventory file sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} - + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} """ } } diff --git a/Jenkinsfile.vm_party b/Jenkinsfile.vm_party index 55c2161..1d3a059 100644 --- a/Jenkinsfile.vm_party +++ b/Jenkinsfile.vm_party @@ -44,9 +44,11 @@ pipeline { } // Generate the dynamic inventory files sh """ + jenkins_group=\$(echo ${env.BUILD_USER_GROUPS} | sed 's/,/\\n/g' | grep Jenkins | 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 ${params.host_ip} + /var/jenkins_home/ansible/inventory/inventory.sh -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip} echo Stage Two Hash: ${env.STAGE_TWO_HASH} """