68 lines
2.6 KiB
Plaintext
68 lines
2.6 KiB
Plaintext
pipeline {
|
|
agent any
|
|
|
|
// Define parameters
|
|
parameters {
|
|
string(name: 'host_ip', defaultValue: '10.250.128.10', description: 'Target System Address')
|
|
string(name: 'chrome_resolution', defaultValue: '720,1000', description: 'Chrome App Resolution')
|
|
// reference for later
|
|
// choice(name: 'DEPLOY_ENV', choices: ['dev', 'staging', 'prod'], description: 'Environment to deploy to')
|
|
booleanParam(name: 'run_test', defaultValue: false, description: 'Check this to run a test LLDP scan')
|
|
booleanParam(name: 'refresh_only', defaultValue: false, description: 'Check this to re-run on existing LLDP Scan device')
|
|
}
|
|
|
|
environment {
|
|
ANSIBLE_FORCE_COLOR = '1'
|
|
SATURN_BEHEMOTH = credentials('SATURN_BEHEMOTH')
|
|
matt_public_key = credentials('matt_public_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 cosmos-base ansible playbook
|
|
// /workspace/ansible/playbooks/cosmos-base.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/lldp-scan.yaml --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 remove_default_vpn=true matt_public_key='${env.matt_public_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"
|
|
}
|
|
}
|
|
|
|
}
|