init commit
This commit is contained in:
85
Jenkinsfile.cosmos-base
Normal file
85
Jenkinsfile.cosmos-base
Normal file
@ -0,0 +1,85 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
// Define parameters
|
||||
parameters {
|
||||
string(name: 'host_ip', description: 'Target System Address')
|
||||
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: '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')
|
||||
booleanParam(name: 'remove_default_vpn', defaultValue: true, description: 'Remove default OpenVPN profile')
|
||||
}
|
||||
|
||||
environment {
|
||||
ANSIBLE_FORCE_COLOR = '1'
|
||||
SATURN_BEHEMOTH = credentials('SATURN_BEHEMOTH')
|
||||
APPS_LIST = 'cosmos-base'
|
||||
LINUX_LDAP_PWD = credentials('LINUX_LDAP')
|
||||
MATT_PASSWORD = credentials('MATT_PASSWORD')
|
||||
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/inventory.sh
|
||||
/var/jenkins_home/ansible/inventory/inventory.sh ${params.host_ip}
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Ansible Playbook') {
|
||||
steps {
|
||||
//Run the cosmos-base ansible playbook
|
||||
// /workspace/ansible/playbooks/cosmos-base.yaml
|
||||
sh """
|
||||
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"
|
||||
|
||||
cd /var/jenkins_home/ansible
|
||||
|
||||
ansible-playbook -i \$inventory_file \
|
||||
/var/jenkins_home/ansible/playbooks/cosmos-base.yaml --ssh-common-args='-o StrictHostKeyChecking=no' \
|
||||
--extra-vars "new_hostname=${params.new_hostname}.home.cosmos saturn_behemoth=${env.SATURN_BEHEMOTH} rename_host=${params.rename_host} \
|
||||
reboot_host=${params.reboot_host} config_matt=${params.config_matt} docker_full=true \
|
||||
kde_full=true apps_list=${env.APPS_LIST} linux_ldap_pwd=${env.LINUX_LDAP_PWD} \
|
||||
install_LDAP=${params.install_LDAP} MATT_PASSWORD=${env.MATT_PASSWORD} remove_default_vpn=${params.remove_default_vpn} \
|
||||
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 """
|
||||
hash=\$(echo -n "${params.host_ip}" | md5sum | cut -c 1-8)
|
||||
inventory_file="/var/jenkins_home/ansible/.inv/inventory-\$hash.yml"
|
||||
rm \$inventory_file
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user