Last active
February 25, 2020 19:13
-
-
Save hbokh/c236b8b1f4e985251c4ebd85d1affbe3 to your computer and use it in GitHub Desktop.
Script to deploy Cobbler 2.8.5 and test cobblerclient & terrafrom-provider-cobbler in CentOS7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
sudo yum install -y epel-release | |
sudo yum update -y | |
sudo yum install -y make automake gcc gcc-c++ git wget | |
cd | |
echo "export PATH=$PATH:$HOME/terraform:$HOME/go/bin" >> ~/.bashrc | |
export PATH=$PATH:$HOME/terraform:$HOME/go/bin | |
if [ ! -d "/root/go" ]; then | |
# Give me Golang 1.13 | |
sudo wget -O /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | |
sudo chmod +x /usr/local/bin/gimme | |
/usr/local/bin/gimme 1.13 >> ~/.bashrc | |
eval "$(/usr/local/bin/gimme 1.13)" | |
mkdir ~/go | |
echo "export GOPATH=$HOME/go" >> ~/.bashrc | |
echo "export GO113MODULE=on" >> ~/.bashrc | |
fi | |
export GOPATH=$HOME/go | |
source ~/.bashrc | |
if [ ! -d "/root/terraform-provider-cobbler" ]; then | |
git clone https://github.com/wearespindle/terraform-provider-cobbler | |
fi | |
# Cobbler 3 - lots of changes and lots of bugs. | |
sudo yum install -y cobbler cobbler-web debmirror dnsmasq fence-agents pykickstart | |
sudo tee /etc/cobbler/modules.conf <<EOF | |
[authentication] | |
module = authn_configfile | |
[authorization] | |
module = authz_allowall | |
[dns] | |
module = manage_dnsmasq | |
[dhcp] | |
module = manage_dnsmasq | |
[tftpd] | |
module = manage_in_tftpd | |
EOF | |
sudo tee /etc/cobbler/dnsmasq.template <<EOF | |
dhcp-range = 192.168.255.200,192.168.255.250 | |
server = 8.8.8.8 | |
read-ethers | |
addn-hosts = /var/lib/cobbler/cobbler_hosts | |
dhcp-option=3,\$next_server | |
dhcp-lease-max=1000 | |
dhcp-authoritative | |
dhcp-boot=pxelinux.0 | |
dhcp-boot=net:normalarch,pxelinux.0 | |
dhcp-boot=net:ia64,\$elilo | |
\$insert_cobbler_system_definitions | |
EOF | |
sudo sed -i -e 's/^manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings | |
sudo sed -i -e 's/^manage_dns: 0/manage_dns: 1/' /etc/cobbler/settings | |
sudo sed -i -e 's/^next_server:.*/next_server: 192.168.33.11/' /etc/cobbler/settings | |
sudo sed -i -e 's/^server:.*/server: 192.168.33.11/' /etc/cobbler/settings | |
# User: cobbler / Pass: cobbler | |
sudo tee /etc/cobbler/users.digest <<EOF | |
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3 | |
EOF | |
# Disable HTTPS for now | |
sudo tee /etc/httpd/conf.d/cobbler_web.conf<<EOF | |
# This configuration file enables the cobbler web | |
# interface (django version) | |
<Directory "/usr/share/cobbler/web/"> | |
SetEnv VIRTUALENV | |
Options Indexes MultiViews | |
AllowOverride None | |
Order allow,deny | |
Allow from all | |
</Directory> | |
<Directory "/var/www/cobbler_webui_content/"> | |
Options +Indexes +FollowSymLinks | |
AllowOverride None | |
Order allow,deny | |
Allow from all | |
</Directory> | |
# Use separate process group for wsgi | |
WSGISocketPrefix /var/run/wsgi | |
WSGIScriptAlias /cobbler_web /usr/share/cobbler/web/cobbler.wsgi | |
WSGIDaemonProcess cobbler_web display-name=%{GROUP} | |
WSGIProcessGroup cobbler_web | |
WSGIPassAuthorization On | |
<IfVersion >= 2.4> | |
<Location /cobbler_web> | |
Require all granted | |
</Location> | |
<Location /cobbler_webui_content> | |
Require all granted | |
</Location> | |
</IfVersion> | |
EOF | |
# Instead of downlaoding a ~900MB ISO, add the basic repo and distro for Ubuntu 18.04 | |
if [ ! -d "/var/www/cobbler/ks_mirror/Ubuntu-18.04" ]; then | |
UBUNTU_REPOSITORY="http://nl.archive.ubuntu.com/ubuntu/" | |
# Copy kernel and initrd which will be used as installers. | |
sudo mkdir -p /var/www/cobbler/ks_mirror/Ubuntu-18.04/install/netboot/ubuntu-installer/amd64 | |
sudo rsync -av rsync://nl.archive.ubuntu.com:/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/ /var/www/cobbler/ks_mirror/Ubuntu-18.04/install/netboot/ubuntu-installer/amd64/ | |
# Add Debian repository, not mirrored nor updated. | |
sudo cobbler repo add --name=Ubuntu-18.04-x86_64 \ | |
--apt-components='main' \ | |
--apt-dists='bionic' \ | |
--arch=x86_64 \ | |
--breed=apt \ | |
--keep-updated=no \ | |
--mirror=${UBUNTU_REPOSITORY} \ | |
--mirror-locally=no | |
# Create Cobbler distro and Cobbler profile. | |
sudo cobbler distro add --name=Ubuntu-18.04-x86_64 \ | |
--kernel=/var/www/cobbler/ks_mirror/Ubuntu-18.04/install/netboot/ubuntu-installer/amd64/linux \ | |
--initrd=/var/www/cobbler/ks_mirror/Ubuntu-18.04/install/netboot/ubuntu-installer/amd64/initrd.gz \ | |
--ksmeta=tree=http://@@http_server@@/cblr/ks_mirror/Ubuntu-18.04-x86_64 \ | |
--arch=x86_64 \ | |
--breed=ubuntu \ | |
--os-version=bionic | |
fi | |
sudo systemctl daemon-reload | |
sudo systemctl enable httpd | |
sudo systemctl restart httpd | |
sudo systemctl enable cobblerd | |
sudo systemctl restart cobblerd | |
sleep 3 | |
sudo cobbler get-loaders | |
sudo cobbler signature update | |
sudo cobbler sync | |
# Create a file with the cobbler credential environment variables | |
cat > ~/cobblerc <<EOF | |
export COBBLER_USERNAME="cobbler" | |
export COBBLER_PASSWORD="cobbler" | |
export COBBLER_URL="http://localhost:25151" | |
EOF | |
echo " | |
Done! Open http://cobbler.internal/cobbler_web/ for | |
the Cobbler webUI and login with cobbler / cobbler. | |
" | |
echo " | |
When running a make testacc on the local machine, export these: | |
export COBBLER_USERNAME="cobbler" | |
export COBBLER_PASSWORD="cobbler" | |
export COBBLER_URL="http://cobbler.internal/cobbler_api" | |
" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.provider :virtualbox do |vb| | |
# change the network card hardware for better performance | |
vb.customize ["modifyvm", :id, "--nictype1", "virtio" ] | |
vb.customize ["modifyvm", :id, "--nictype2", "virtio" ] | |
# suggested fix for slow network performance | |
# see https://github.com/mitchellh/vagrant/issues/1807 | |
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | |
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] | |
end | |
# Plugin vagrant-hostsupdater needs to be installed | |
config.vm.box = "bento/centos-7.7" | |
config.vm.network "private_network", ip: "192.168.33.11" | |
config.vm.hostname = 'cobbler.internal' | |
config.vm.synced_folder '.', '/vagrant', type: 'nfs' | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = "2048" | |
end | |
# PROVISIONING | |
config.vm.provision "shell", path: "deploy.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment