much tidying up
This commit is contained in:
@ -7,6 +7,7 @@ pipeline {
|
||||
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: 'cosmos_refresh', defaultValue: false, description: 'This just runs the cosmos_init task')
|
||||
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')
|
||||
@ -37,12 +38,15 @@ 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/cosmos-base.yaml"
|
||||
cd /var/jenkins_home/ansible
|
||||
chmod +x /var/jenkins_home/ansible/inventory/inventory.sh
|
||||
/var/jenkins_home/ansible/inventory/inventory.sh -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 -a \$jenkins_subnet_group -g \$jenkins_group -u \$jenkins_user -i ${params.host_ip}
|
||||
|
||||
|
||||
"""
|
||||
@ -54,21 +58,36 @@ pipeline {
|
||||
//Run the cosmos-base ansible playbook
|
||||
// /workspace/ansible/playbooks/cosmos-base.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/cosmos-base.yaml"
|
||||
extra_vars=\$(echo " \
|
||||
kde_full=true \
|
||||
docker_full=true \
|
||||
rename_host=${params.rename_host} \
|
||||
no_vpn=${params.remove_default_vpn} \
|
||||
new_hostname=${params.new_hostname}.home.cosmos \
|
||||
reboot_host=${params.reboot_host} \
|
||||
config_matt=${params.config_matt} \
|
||||
install_LDAP=${params.install_LDAP} \
|
||||
apps_list=${env.APPS_LIST} \
|
||||
linux_ldap_pwd=${env.LINUX_LDAP_PWD} \
|
||||
MATT_PASSWORD=${env.MATT_PASSWORD} \
|
||||
matt_public_key='${env.matt_public_key}' \
|
||||
cosmos_password='${env.cosmos_password}' \
|
||||
cosmos_root_password='${env.cosmos_root_password}' \
|
||||
cosmos_refresh=${env.cosmos_refresh} \
|
||||
saturn_behemoth=${env.SATURN_BEHEMOTH} \
|
||||
" | tr -s " ")
|
||||
|
||||
set -x
|
||||
|
||||
cd /var/jenkins_home/ansible
|
||||
|
||||
ansible-playbook -i \$inventory_file /var/jenkins_home/ansible/playbooks/cosmos-base.yaml \
|
||||
ansible-playbook -i \$inventory_file \$playbook_file \
|
||||
--ssh-common-args='-o StrictHostKeyChecking=no' \
|
||||
--extra-vars "kde_full=true docker_full=true rename_host=${params.rename_host} no_vpn=${params.remove_default_vpn} \
|
||||
new_hostname=${params.new_hostname}.home.cosmos saturn_behemoth=${env.SATURN_BEHEMOTH}
|
||||
reboot_host=${params.reboot_host} config_matt=${params.config_matt} \
|
||||
apps_list=${env.APPS_LIST} linux_ldap_pwd=${env.LINUX_LDAP_PWD} \
|
||||
install_LDAP=${params.install_LDAP} MATT_PASSWORD=${env.MATT_PASSWORD} \
|
||||
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}'"
|
||||
|
||||
"""
|
||||
}
|
||||
@ -79,8 +98,10 @@ 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