Common commands and deployment of cobbler

Posted by kevinjo on Thu, 06 Jun 2019 01:36:41 +0200

Common orders

cobbler check checks cobbler configuration
 The cobbler list lists all the cobbler elements
 cobbler report lists the details of the elements
 cobbler distro to view imported distribution system information
 cobbler system Views Additional System Information
 cobbler profile view configuration information
 cobbler sync synchronizes Cobbler configuration, and changes to configuration are best performed
 cobbler reposync synchronous yum repository

Configuration files

/ etc/cobbler/settings Cobbler master configuration file
 / etc/cobbler/users.digest User Name Password Profile for web Access
 / etc/cobbler/users.conf Cobbler WebUI/Web Services Authorization Profile
 / etc/cobbler/modules.conf module configuration file
 / etc/cobbler/iso/Buildiso Template Profile
 / etc/cobbler/power power power configuration file
 / etc/cobbler/pxe Pxeprofile configuration template
 / etc/cobbler contains rsync, dhcp, dns, pxe and other service templates

3. Practical operation
Modify the pxe boot interface file / var/lib/tftpboot/pxelinux.cfg/default;
Ignore the name of the network card that comes with the system, and specify the name of the network card according to the requirement.
vim /etc/cobbler/pxe/pxeprofile.template

 LABEL $profile_name
        kernel $kernel_path
        $menu_label
        $append_line initrd=initrd.img net.ifnames=0 biosdevname=0
        ipappend 2

IV. System Mirror Data Catalogue
repos mirrors and kickstart files are placed in the / var/www/cobbler directory to ensure that the / var directory has enough space to store these files.

/ var/www/cobbler/images/distribution Kernel and initrd images for remote network startup
 / var/www/cobbler/ks_mirror/Store imported distribution system data
 / var/www/cobbler/repo_mirror/yum warehouse storage directory
 / var/log/cobbler Cobbler log file cobbler.log install.log 

V. Cobbler Data Catalogue
/ var/lib/cobbler directory storage and configuration related to Cobler profiles, systems, distros.

/ var/lib/cobbler/config/Deposit distros, repos, systems, profiles and other configurations
 / var/lib/cobbler/snippets/small script fragments that can be imported from the storage ks file are worth studying.
/ var/lib/cobbler/triggers stores user-defined cobbler commands
 / var/lib/cobbler/kickstart/store kickstart configuration file

VI. Log files

web Log repository
/var/log/httpd/access_log
/var/log/httpd/error_log

/var/log/httpd/ssl_access_log
/var/log/httpd/ssl_error_log

Cobbler Journal
/var/log/cobbler/cobbler.log
/var/log/cobbler/install.log

7. Deployment scripts

#Install the RPM package
yum install epel-release -y
yum makecache -y
yum -y install cobbler cobbler-web xinetd pykickstart cman dhcp crudini
systemctl enable httpd.service dhcpd.service cobblerd.serivce rsyncd.serivce
yum -y install pykickstart debmirror cman fence-agents

#Prepare system image
mkdir -p /mnt/cdrom/CentOS-7.3-x86_64
mount -t iso9660 -o loop /ios/CentOS-7-x86_64-DVD-1611.iso /mnt/cdrom/CentOS-7.3-x86_64
sed -i '/CentOS-7-x86_64-DVD-1611/d' /etc/fstab
echo "/ios/CentOS-7-x86_64-DVD-1611.iso /mnt/cdrom/CentOS-7.3-x86_64    iso9660    defaults,ro,loop    0 0" >> /etc/fstab

#Set up startup service
systemctl enable httpd
systemctl enable dhcpd  
systemctl enable cobblerd
systemctl enable rsyncd

#Set a variable
dhcp_net =172.16.0.0
dhcp_netmask=255.255.0.0
routers=172.16.1.1
local_ip=172.16.5.135
node=bs
mac=
interface=eth0




#Start the DHCP
cat >> /etc/dhcp/dhcpd.conf <<EOF
ddns-update-style interim;
ignore client-updates;
option domain-name-servers 114.114.114.114, 8.8.8.8;
subnet $dhcp_net netmask $dhcp_netmask {
    option broadcast-address $broadcast;
    option routers $routers;
    default-lease-time 600; 
    max-lease-time 7200; 
    next-server $local_ip; 
    filename "pxelinux.0"; 
}
EOF
systemctl restart dhcpd

#Cobbler takes over the service
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings 
sed -i 's/manage_rsync: 0/manage_rsync: 1/' /etc/cobbler/settings 
sed -i "s/next_server: 127.0.0.1/next_server: $local_ip/" /etc/cobbler/settings 
sed -i "s/server: 127.0.0.1/server: $local_ip/" /etc/cobbler/settings 
sed -i '/disable/s/yes/no/' /etc/xinetd.d/tftp

#The DHCP configuration
sed -i "s/192.168.1.0/$dhcp_net/g" /etc/cobbler/dhcp.template
sed -i "s/255.255.255.0/$dhcp_netmask/g" /etc/cobbler/dhcp.template
sed -i "s/192.168.1.5;/$routers/g" /etc/cobbler/dhcp.template
sed -i 's/192.168.1.1/114.114.114.114/g' /etc/cobbler/dhcp.template
sed -i 's/range dynamic-bootp/#range dynamic-bootp/g' /etc/cobbler/dhcp.template
sed -i "/#for dhcp_tag/i\host $node {\n    hardware ethernet $mac;\n    fixed-address $ipaddr;\n}" /etc/cobbler/dhcp.template

#Cobbler check
systemctl restart cobblerd
systemctl restart httpd
cobbler get-loaders
sed -i 's/@dists="sid";/#@dists="sid";/' /etc/debmirror.conf
sed -i 's/@arches="i386";/#@arches="i386";/' /etc/debmirror.conf
sed -i 's/default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac.";/default_password_crypted: "$1$random-p$LAW1z9ai7QwuGMEOj72qV/";/' /etc/cobbler/settings 
sed -i 's/allow_dynamic_settings: 0/allow_dynamic_settings: 1/' /etc/cobbler/settings 
cobbler sync
cobbler check
systemctl restart httpd
systemctl restart dhcpd  
systemctl restart cobblerd
systemctl restart xinetd
systemctl restart rsyncd
cobbler import --path=/mnt/cdrom/CentOS-7.3-x86_64 --name=Centos7.3 --arch=x86_64  
##Cobbler add repo (make sure you have access to local-yum)
cobbler repo add --name=base --mirror=http://"$local_ip"/local-yum/ --arch=x86_64 --breed=wget
cobbler reposync
rm -f /var/lib/cobbler/kickstarts/test.ks
\cp /var/lib/cobbler/kickstarts/test.ks /var/lib/cobbler/kickstarts/
cobbler profile edit --name=Centos7.3-x86_64 --kickstart=/var/lib/cobbler/kickstarts/test.ks --repos="local-yum"

cobbler system add --name=$node --mac=$mac --profile=centos7.3-x86_64  --ip-address=$local_ip --subnet=$dhcp_netmask --gateway=$routers--interface=$interface --static=1 --hostname=$node --name-servers="114.114.114.114 "

Topics: yum CentOS Mac network