much tidying up
This commit is contained in:
@ -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
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user