Author: Solo @TaoCloud
Preface
Cobbler is a necessary tool for automating operations and maintenance, and it can be used to quickly install operating systems in batches by means of network startup (PXE).Cobbler's fast installation operating system is based on kickstart, but Cobbler has better functionality, easier and more efficient management.By centrally managing the services (tftp, dhcp, kickstart) involved in installing the system, Cobbler provides a fully automated network environment for fast installing the system in batches to achieve the unified management of large-scale computer room equipment.
1. Introduction
Cobbler supports both CLI and WEB management.Requires that all servers of the installed system be in the same local area network as the Cobbler server, and that only Cobbler servers have DHCP services in that network environment to prevent multiple DHCP service conflicts.
This experimental environment deploys Cobbler in a virtual machine and needs to turn off the DHCP functionality that comes with virtualization.
VMware Workstation Shutdown Method: Edit - Virtual Network Editor - Change Settings - Assign IP Address to Virtual Machine using Local DHCP Service, apply Save after removing the checkmark.For other virtualization environments, look for a way to turn it off yourself.
2. Environmental Preparation
Operating System: CentOS 7.6.1810
Network IP: 10.10.10.70
Host name: cobbler
1. Close selinux and firewall
systemctl stop firewalld systemctl disable firewalld sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
2. Configure epel source
yum install epel-release -y reboot
Restart the server after provisioning to make the configuration take effect.
3. Install Cobbler
1. Install cobbler and related packages
yum -y install cobbler cobbler-web dhcp tftp-server xinetd pykickstart httpd
2. Configure cobbler to generate a new password with openssl
[root@cobbler ~]# openssl passwd -1 Password: Verifying - Password: $1$7Rx88tdC$j5r4XFSO8D9YgMCU1zEwU1
Record output: $1Rx88tdC$j5r4XFSO8D9YgMCU1zEwU1
Modify the /etc/cobbler/settings configuration file, find the default_password_crypted parameter, and replace the original password with the output above, as follows:
#About 101 lines default_password_crypted: "$1$7Rx88tdC$j5r4XFSO8D9YgMCU1zEwU1"
Modify server ip to local ip address:
sed -i 's/server: 127.0.0.1/server: 10.10.10.70/g' /etc/cobbler/settings sed -i 's/next_server: 127.0.0.1/next_server: 10.10.10.70/g' /etc/cobbler/settings
3. Configure to use DHCP services.Change the manage_dhcp parameter value 0 to 1.
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
Modify the contents of the / etc/cobbler/dhcp.template file according to the actual configuration of the network. In general, only the following changes are necessary:
subnet 10.10.10.0 netmask 255.255.255.0 { option routers 10.10.10.254; option domain-name-servers 10.10.10.254; option subnet-mask 255.255.255.0; range dynamic-bootp 10.10.10.100 10.10.10.200; default-lease-time 21600; max-lease-time 43200; next-server $next_server;
Explanation of relevant parameters:
subnet: Dynamically assign IP network segments, typically the same segment as the obbler server IP
netmask: subnet mask
option routers: Routes, usually gateway addresses
option domain-name-servers:DNS server
option subnet-mask: subnet mask
range dynamic-bootp: dynamic IP address assignment range
The remaining parameters are the default.
4. Start services such as dhcp, cobbler, http and set the startup self-startup
systemctl enable dhcpd.service systemctl enable cobblerd.service systemctl start cobblerd.service systemctl status cobblerd.service systemctl start httpd systemctl enable httpd systemctl start xinetd systemctl enable xinetd
5. Check for missing files
[root@cobbler ~]# cobbler check The following are potential configuration items that you may want to fix: 1 : change 'disable' to 'no' in /etc/xinetd.d/tftp 2 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements. 3 : enable and start rsyncd.service with systemctl 4 : debmirror package is not installed, it will be required to manage debian deployments and repositories 5 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them Restart cobblerd and then run 'cobbler sync' to apply changes.
6. Modify as prompted above
(1) Modify the/etc/xinetd.d/tftp file and set the disable parameter value to no
sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp
(2) Download the missing file and run the command:
cobbler get-loaders
(3) Start rsyncd and set start-up self-start
systemctl enable rsyncd.service && systemctl start rsyncd.service
(4) Install debmirror package and fence-agents tools
yum install debmirror fence-agents -y
(5) Comment out dists and arches to support the debian system
sed -i "s/@dists/#@dists/g" /etc/debmirror.conf sed -i "s/@arches/#@arches/g" /etc/debmirror.conf
(6) Restart the cobblerd service and resynchronize the configuration
systemctl restart cobblerd.service cobbler sync
There are no errors to proceed to the next step, returning the following:
[root@cobbler ~]# cobbler sync task started: 2019-08-11_113013_sync task started (id=Sync, time=Sun Aug 11 11:30:13 2019) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/grub/images copying bootloaders copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 copying: /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk copying: /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi copying: /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi copying distros to tftpboot copying images generating PXE configuration files generating PXE menu structure rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running: dhcpd -t -q received on stdout: received on stderr: running: service dhcpd restart received on stdout: received on stderr: Redirecting to /bin/systemctl restart dhcpd.service running shell triggers from /var/lib/cobbler/triggers/sync/post/* running python triggers from /var/lib/cobbler/triggers/change/* running python trigger cobbler.modules.manage_genders running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
7. After processing is completed, run the command again to check for missing files, and the following shows that the detection has passed.
# cobbler check No configuration problems found. All systems go.
IV. CLI Management
1. Download Mirror
Upload the mirror file to the server and mount it to the / mnt directory
mount -t iso9660 -o loop,ro /root/CentOS-7-x86_64-Minimal-1511.iso /mnt/
2. Import Mirror
cobbler import --name=centos7.2 --arch=x86_64 --path=/mnt
The /var/www/cobbler/ks_mirror directory is used to store system data files and generally requires at least 5-10GB of space to import system data
3. View objects and related details
cobbler distro list cobbler profile list cobbler distro report --name=centos7.2-x86_64
4. Create a system
cobbler system add --name=test --profile=centos7.2-x86_64 cobbler system edit --name=test --interface=eth0 --mac=00:11:22:AA:BB:CC --ip-address=10.10.10.100 --netmask=255.255.255.0 --static=1 --dns-name=test.mydomain.com
Since the default gateway does not set all ports, add them separately
cobbler system edit --name=test --gateway=10.10.10.254 --hostname=test.mydomain.com
5. View related configuration information
cobbler system report --name=test
6. Information Synchronization
cobbler sync
Note: Every time the cobbler information changes, it needs to be synchronized in time
7. Create a new test virtual machine and you will see that when the virtual machine is turned on, it will automatically enter the operating system installation.
V. WEB Management
1. Configure web access
Configure access user cobbler password: 111111
# htdigest /etc/cobbler/users.digest "Cobbler" cobbler Changing password for user cobbler in realm Cobbler New password: Re-type new password:
2. Synchronize information
cobbler sync
3. Restart Services
systemctl restart httpd systemctl restart cobblerd
4. In your chrome or Firefox browser, type: https://10.10.10.70/cobbler_web Access, username: cobbler, password: 111111111. If you can't access it properly, check the Error Handling section at the back.
6. Error Handling
Open the WEB link: https://10.10.10.70/cobbler_web , WEB error message:
View/var/log/httpd/ssl_error_log log log log log error information
[Mon Aug 12 22:10:03.269242 2019] [:error] [pid 9707] [remote 10.10.10.1:0] mod_wsgi (pid=9707): Exception occurred processing WSGI script '/usr/share/cobbler/web/cobbler.wsgi'. [Mon Aug 12 22:10:03.269317 2019] [:error] [pid 9707] [remote 10.10.10.1:0] Traceback (most recent call last): [Mon Aug 12 22:10:03.269342 2019] [:error] [pid 9707] [remote 10.10.10.1:0] File "/usr/share/cobbler/web/cobbler.wsgi", line 26, in application [Mon Aug 12 22:10:03.269417 2019] [:error] [pid 9707] [remote 10.10.10.1:0] _application = get_wsgi_application() [Mon Aug 12 22:10:03.269431 2019] [:error] [pid 9707] [remote 10.10.10.1:0] File "/usr/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application [Mon Aug 12 22:10:03.270122 2019] [:error] [pid 9707] [remote 10.10.10.1:0] django.setup(set_prefix=False) [Mon Aug 12 22:10:03.270146 2019] [:error] [pid 9707] [remote 10.10.10.1:0] File "/usr/lib/python2.7/site-packages/django/__init__.py", line 22, in setup [Mon Aug 12 22:10:03.270893 2019] [:error] [pid 9707] [remote 10.10.10.1:0] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) [Mon Aug 12 22:10:03.270923 2019] [:error] [pid 9707] [remote 10.10.10.1:0] File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__ [Mon Aug 12 22:10:03.271868 2019] [:error] [pid 9707] [remote 10.10.10.1:0] self._setup(name) [Mon Aug 12 22:10:03.271902 2019] [:error] [pid 9707] [remote 10.10.10.1:0] File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup [Mon Aug 12 22:10:03.271929 2019] [:error] [pid 9707] [remote 10.10.10.1:0] self._wrapped = Settings(settings_module) [Mon Aug 12 22:10:03.271939 2019] [:error] [pid 9707] [remote 10.10.10.1:0] File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__ [Mon Aug 12 22:10:03.271951 2019] [:error] [pid 9707] [remote 10.10.10.1:0] mod = importlib.import_module(self.SETTINGS_MODULE) [Mon Aug 12 22:10:03.271963 2019] [:error] [pid 9707] [remote 10.10.10.1:0] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module [Mon Aug 12 22:10:03.272747 2019] [:error] [pid 9707] [remote 10.10.10.1:0] __import__(name) [Mon Aug 12 22:10:03.272767 2019] [:error] [pid 9707] [remote 10.10.10.1:0] File "/usr/share/cobbler/web/settings.py", line 89, in <module> [Mon Aug 12 22:10:03.273494 2019] [:error] [pid 9707] [remote 10.10.10.1:0] from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS [Mon Aug 12 22:10:03.273523 2019] [:error] [pid 9707] [remote 10.10.10.1:0] ImportError: cannot import name TEMPLATE_CONTEXT_PROCESSORS
Judged as a Django version problem, the specified Django version needs to be installed for processing
yum install python-pip -y pip install Django==1.8.9 systemctl restart cobblerd systemctl restart httpd
Refresh your browser and access it again.
Enter the user name: cobbler password: 111111, open the cobbler web administration page after authentication to operate.
Welcome to code-sweeping questions, which can be answered online.Periodically share virtualization, containers, DevOps, etc.