init commit
This commit is contained in:
84
Jenkinsfile.pxe-server
Normal file
84
Jenkinsfile.pxe-server
Normal file
@ -0,0 +1,84 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
// Define parameters
|
||||
parameters {
|
||||
//booleanParam(name: 'deploy_iso', defaultValue: true, description: 'Deploy extra ISO boot options - will increase pipeline runtime.')
|
||||
string(name: 'host_ip', defaultValue: '172.20.20.40', description: 'PXE Server IP Address')
|
||||
string(name: 'iface', defaultValue: 'eth1', description: 'Listen interface for PXE')
|
||||
string(name: 'server_ip', defaultValue: '172.29.1.10', description: 'IP address for DHCP server, might not match the target IP such as in the default case where I have two interfaces')
|
||||
string(name: 'router_ip', defaultValue: '172.29.1.1', description: 'IP Address for router')
|
||||
string(name: 'dhcp_subnet', defaultValue: '172.29.1.0', description: 'Default Subnet for DHCP server')
|
||||
string(name: 'dhcp_netmask', defaultValue: '255.255.255.0', description: 'Default netmask for DHCP server')
|
||||
string(name: 'dhcp_start', defaultValue: '172.29.1.100', description: 'DHCP start IP')
|
||||
string(name: 'dhcp_end', defaultValue: '172.29.1.150', description: 'DHCP end IP')
|
||||
booleanParam(name: 'configure_routing', defaultValue: false, description: 'Check this option to configure the PXE server to be the gateway for the dhcp network')
|
||||
string(name: 'inet_iface', defaultValue: 'eth0', description: 'Interface for internet if enabling routing')
|
||||
booleanParam(name: 'refresh_only', defaultValue: false, description: 'Only run the PXE Role to refresh configs')
|
||||
}
|
||||
|
||||
environment {
|
||||
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')
|
||||
matt_private_key = credentials('matt_private_key')
|
||||
cosmos_password = credentials('cosmos_password')
|
||||
cosmos_root_password = credentials('cosmos_root_password')
|
||||
}
|
||||
|
||||
options {
|
||||
ansiColor('xterm')
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
|
||||
stage('Generate Inventory File') {
|
||||
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}
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Ansible Playbook') {
|
||||
steps {
|
||||
//Run the pxe-server ansible playbook
|
||||
// /workspace/ansible/playbooks/pxe-server.yaml
|
||||
sh """
|
||||
cd /var/jenkins_home/ansible
|
||||
|
||||
ansible-playbook -i /var/jenkins_home/ansible/.inv/inventory-${params.host_ip}.yml \
|
||||
/var/jenkins_home/ansible/playbooks/pxe-server.yaml --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}' "
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
// Remove dynamic Inventory file
|
||||
sh "rm /var/jenkins_home/ansible/.inv/inventory-${params.host_ip}.yml"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user