PXE+DHCP+TFTP+Cobbler Unmanned Installation centos 7

Keywords: Linux Python network yum CentOS

Cobbler (cobbler) is to create a central management node by integrating DHCP, TFTP, DNS, HTTP and other services. Its functions include configuration services, creation of repositories, decompression of operating system media, proxy or integration of a configuration management system, and control of power management. The ultimate goal of Cobbler is to install machines without manual intervention.

pxe overview
Preboot eXecution Environment (PXE), also known as Pre-Execution Environment, allows computers to independently use data devices (such as hard disks) or install operating systems via network cards.

PXE Client Sends Broadcast Packet Request DHCP Assignment IP Address DHCP
Server responds to requests, giving IP addresses and Boot s
Server address PXE download boot file to execute boot program

In conclusion,

The pxe client calls Internet Protocol (ip), User Data Reporting Protocol (udp), Dynamic Host Setting Protocol (DHCP), Small File Transfer Protocol (TFTP).

The pxe client refers to the machine's role in the pxe boot process. A pxe client can be a server, laptop, or other machine with pxe startup code

PXE mainly transmits a package by broadcasting. Please note to get an address, and then send it to TFTP program to download a boot file.

cobbler and Kickstart Batch Installation Software

Developed by python, Cobbler is a package for PXE, Kickstart and DHCP. It integrates many features and provides CLI and Web management forms. More convenient implementation of network installation. At the same time, Cobbler also provides API interfaces, which can be easily extended in other languages. It's not tight enough to install physical machines, but also supports kvm, xen virtualization, Guest OS installation. More importantly, it can also combine Puppet and other centralized management software to achieve automated management.

Kickstart is an unattended installation method. Its working principle is to record various parameters filled in by manual intervention during installation and generate a file named ks.cfg. We can simply think of it as an automatic installation response configuration manager. By reading this configuration file, the system knows how to partition, what packages to install, what IP to match, what kernel parameters to optimize, and so on.

Summary: Cobbler cobbler cobbler cobbler covers Kickstart, simplifies installation procedures and use processes, and officially claims that cobbler cobbler can learn to install machines in batches.

Cobbler workflow

server terminal:

The first step is to start the Cobbler service
The second step is to do Cobbler error checking and execute the cobbler check command
Step 3: Configuration synchronization and execution of the cobbler sync command
Step 4: Copy the relevant startup files into the TFTP directory
Step 5: Start the DHCP service and provide address assignment
Step 6: DHCP Service Assignment IP Address
Step 7, TFTP transfers startup files
Step 8: Server receives installation information
Step 9: Server sends ISO image and Kickstart file

Client terminal:

The first step is to start the client in PXE mode
The second step, the client obtains the IP address
Step 3: Get the startup file through the TFTP server
Step 4: Enter the Cobbler Installation Selection Interface
Step 5: The client determines the load information
Step 6: Prepare to install the system based on configuration information
Step 7: Load the Kickstart file
Step 8: Transfer system installation of other files
Step 9: Install the system

 

Formal environmental preparation:

1. Network environment: host-only, nat network, because Cobbler needs to use its own dhcp server, so in order to prevent dhcp acquisition chaos caused by the same network, it is necessary to switch the network!

2. The necessary environment preparation for similar installation services: 1. Close iptables,selinux 2, configure static IP, set host name and bind under hosts file 3. Time synchronization 4. Configure yum warehouse in local iso image, 163 source epel source (installation software)

cobbler server    -------    client
192.168.100.221/24----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

I. Install cobbler on cobbler server

  yum install cobbler cobbler-web tftp* rsync xinetd http* syslinux dhcp* pykickstart

[root@bokeyuan ~]# yum install cobbler cobbler-web tftp* rsync xinetd http* syslinux dhcp* pykickstart
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package rsync-3.0.9-17.el7.x86_64 already installed and latest version
Package 12:dhcp-common-4.2.5-47.el7.centos.x86_64 already installed and latest version
Package 12:dhcp-libs-4.2.5-47.el7.centos.x86_64 already installed and latest version
Package pykickstart-1.99.66.10-1.el7.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: mod_wsgi for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: PyYAML for package: cobbler-2.6.3-1.el6.noarch
---> Package cobbler-web.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: mod_ssl for package: cobbler-web-2.6.3-1.el6.noarch
--> Processing Dependency: Django for package: cobbler-web-2.6.3-1.el6.noarch
---> Package dhcp.x86_64 12:4.2.5-47.el7.centos will be installed
---> Package httpcomponents-client.noarch 0:4.2.5-5.el7_0 will be installed
--> Processing Dependency: mvn(commons-logging:commons-logging) for package: httpcomponents-client-4.2.5-5.el7_0.noarch
--> Processing Dependency: mvn(commons-codec:commons-codec) for package: httpcomponents-client-4.2.5-5.el7_0.noarch
---> Package httpcomponents-core.noarch 0:4.2.4-6.el7 will be installed
---> Package httpd.x86_64 0:2.4.6-45.el7.centos will be installed
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-45.el7.centos.x86_64
---> Package httpd-devel.x86_64 0:2.4.6-45.el7.centos will be installed
--> Processing Dependency: apr-util-devel for package: httpd-devel-2.4.6-45.el7.centos.x86_64
--> Processing Dependency: apr-devel for package: httpd-devel-2.4.6-45.el7.centos.x86_64
---> Package httpd-manual.noarch 0:2.4.6-45.el7.centos will be installed
---> Package httpd-tools.x86_64 0:2.4.6-45.el7.centos will be installed
---> Package syslinux.x86_64 0:4.05-13.el7 will be installed
---> Package tftp.x86_64 0:5.2-13.el7 will be installed
---> Package tftp-server.x86_64 0:5.2-13.el7 will be installed
---> Package xinetd.x86_64 2:2.3.15-13.el7 will be installed
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package PyYAML.x86_64 0:3.10-11.el7 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: PyYAML-3.10-11.el7.x86_64
---> Package apache-commons-codec.noarch 0:1.8-7.el7 will be installed
---> Package apache-commons-logging.noarch 0:1.1.2-7.el7 will be installed
--> Processing Dependency: mvn(logkit:logkit) for package: apache-commons-logging-1.1.2-7.el7.noarch
--> Processing Dependency: mvn(log4j:log4j) for package: apache-commons-logging-1.1.2-7.el7.noarch
--> Processing Dependency: mvn(avalon-framework:avalon-framework-api) for package: apache-commons-logging-1.1.2-7.el7.noarch
---> Package apr-devel.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util-devel.x86_64 0:1.5.2-6.el7 will be installed
--> Processing Dependency: openldap-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: libdb-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: expat-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
---> Package mod_ssl.x86_64 1:2.4.6-45.el7.centos will be installed
---> Package mod_wsgi.x86_64 0:3.4-12.el7_0 will be installed
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package avalon-framework.noarch 0:4.3-10.el7 will be installed
--> Processing Dependency: xalan-j2 for package: avalon-framework-4.3-10.el7.noarch
---> Package avalon-logkit.noarch 0:2.1-14.el7 will be installed
--> Processing Dependency: tomcat-servlet-3.0-api for package: avalon-logkit-2.1-14.el7.noarch
--> Processing Dependency: jms for package: avalon-logkit-2.1-14.el7.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package expat-devel.x86_64 0:2.1.0-8.el7 will be installed
---> Package libdb-devel.x86_64 0:5.3.21-19.el7 will be installed
---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed
---> Package log4j.noarch 0:1.2.17-15.el7 will be installed
--> Processing Dependency: mvn(javax.mail:mail) for package: log4j-1.2.17-15.el7.noarch
---> Package openldap-devel.x86_64 0:2.4.40-13.el7 will be installed
--> Processing Dependency: cyrus-sasl-devel(x86-64) for package: openldap-devel-2.4.40-13.el7.x86_64
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package cyrus-sasl-devel.x86_64 0:2.1.26-20.el7_2 will be installed
---> Package geronimo-jms.noarch 0:1.1.1-19.el7 will be installed
---> Package javamail.noarch 0:1.4.6-8.el7 will be installed
---> Package tomcat-servlet-3.0-api.noarch 0:7.0.69-10.el7 will be installed
---> Package xalan-j2.noarch 0:2.7.1-23.el7 will be installed
--> Processing Dependency: xerces-j2 for package: xalan-j2-2.7.1-23.el7.noarch
--> Processing Dependency: osgi(org.apache.xerces) for package: xalan-j2-2.7.1-23.el7.noarch
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package xerces-j2.noarch 0:2.11.0-17.el7_0 will be installed
--> Processing Dependency: xml-commons-resolver >= 1.2 for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Processing Dependency: xml-commons-apis >= 1.4.01 for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Processing Dependency: osgi(org.apache.xml.resolver) for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Processing Dependency: osgi(javax.xml) for package: xerces-j2-2.11.0-17.el7_0.noarch
--> Running transaction check
---> Package Django14.noarch 0:1.4.20-1.el6 will be installed
--> Processing Dependency: python(abi) = 2.6 for package: Django14-1.4.20-1.el6.noarch
--> Processing Dependency: python-simplejson for package: Django14-1.4.20-1.el6.noarch
---> Package cobbler.noarch 0:2.6.3-1.el6 will be installed
--> Processing Dependency: python-simplejson for package: cobbler-2.6.3-1.el6.noarch
--> Processing Dependency: python-cheetah for package: cobbler-2.6.3-1.el6.noarch
---> Package xml-commons-apis.noarch 0:1.4.01-16.el7 will be installed
---> Package xml-commons-resolver.noarch 0:1.2-15.el7 will be installed
--> Finished Dependency Resolution
Error: Package: Django14-1.4.20-1.el6.noarch (cobbler)
           Requires: python-simplejson
Error: Package: cobbler-2.6.3-1.el6.noarch (cobbler)
           Requires: python-simplejson
Error: Package: Django14-1.4.20-1.el6.noarch (cobbler)
           Requires: python(abi) = 2.6
           Installed: python-2.7.5-48.el7.x86_64 (@anaconda)
               python(abi) = 2.7
               python(abi) = 2.7
Error: Package: cobbler-2.6.3-1.el6.noarch (cobbler)
           Requires: python-cheetah
 You could try using --skip-broken to work around the problem
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
ipa-client-4.4.0-12.el7.centos.x86_64 has installed conflicts freeipa-client: ipa-client-4.4.0-12.el7.centos.x86_64
ipa-client-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-client-common: ipa-client-common-4.4.0-12.el7.centos.noarch
ipa-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-common: ipa-common-4.4.0-12.el7.centos.noarch

Error Solution: Tip skip-broken, check found that yum source incomplete yum can not install the above three dependency packages. Complete yum Source Solution

 

Installation completed, start software

[root@bokeyuan ~]# systemctl restart cobblerd.service
[root@bokeyuan ~]# systemctl restart httpd.service
[root@bokeyuan ~]# system CTL enable cobblerd.service // / boot-up self-startup
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.
[root@bokeyuan ~]# system CTL enable httpd.service // / boot-up self-startup
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

Why start apache? The lesson of blood has been waiting for a long time. Do not start Apache follow-up cobbler check report python file error!!!

II. Basic configuration

 

[root@bokeyuan ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : 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.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
8 : 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.

Step by step to address the above needs, some of which can be ignored. Individual differences differ from person to person in terms of quantity of demand, which is basically the same.

Addressing Needs 1, 2, 7
[openssl passwd-1-salt'werwqerwqr''123456') -- 123456 is the password (this is the root login password after the successful installation of the client system), and werwqerwqr is the random byte interference code (random writing)
$1$werwqerw$.prcfrYFbwuvkD8XspayN.

 

# vim /etc/cobbler/settings
384 server: 192.168.100.221 -- Change to cobbler server-side IP
272 next_server: 192.168.100.221 -- ibid.
101 default_password_crypted: "$werwqerw$.prcfrYFbwuvkD8XspayN."-- Replace the password string with the string you generated above (this password is the root login password installed by the client)

Addressing Needs 3
# vim /etc/xinetd.d/tftp
disable = no -- yes changed to no

 

Addressing Needs 5

#systemctl restart rsyncd.service

#systemctl enable  rsyncd.service

 

Addressing Needs 8
# yum install fence-agents

OK, the rest of the requirements are like

4 : 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.
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories

(Problem 4 can be solved by cobbler get-loaders, but it needs yum sources to skip over the external network and the external network, which is now NAT mode; Problem 6 is about debian system, which we can ignore here.)

Finally # system CTL restart cobblerd. service restarts cobbler service!

 

III. Import the iso image of CentOS 7.3

My environment iso image is mounted in the / yum directory, which takes a long time to copy.

# cobbler import --path=/yum/ --name=centos7.3

# cobbler distro list -- Once the import is successful, confirm the imported image name
   centos7.3-x86_64
# cobbler profile list -- After importing successfully, confirm the default profile name
   centos7.3-x86_64

[root@bokeyuan ~]# cobbler import --path=/yum/ --name=centos7.3
task started: 2017-09-03_175701_import
task started (id=Media import, time=Sun Sep  3 17:57:01 2017)
Found a candidate signature: breed=redhat, version=rhel6
Found a candidate signature: breed=redhat, version=rhel7
Found a matching signature: breed=redhat, version=rhel7
Adding distros from path /var/www/cobbler/ks_mirror/centos7.3:
creating new distro: centos7.3-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos7.3 -> /var/www/cobbler/links/centos7.3-x86_64
creating new profile: centos7.3-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/centos7.3 for centos7.3-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos7.3
need to process repo/comps: /var/www/cobbler/ks_mirror/centos7.3
looking for /var/www/cobbler/ks_mirror/centos7.3/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7.3/repodata
*** TASK COMPLETE ***

 


IV. Modifying dhcp configuration
# vim/etc/cobbler/dhcp.template -- Modify lines 21 to 25 of this file to your corresponding network segment and ip

subnet 192.168.100.0 netmask 255.255.255.0 {
     option routers             192.168.100.221;
     option domain-name-servers 192.168.100.221;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.100.100 192.168.100.254;


-- The operation of graphics is important to omit the follow-up.

# vim/etc/cobbler/settings -- Modify the configuration file and change it to dhcp service managed by cobbler
242 manage_dhcp: 1 -- Change 0 to 1

# system CTL restart cobblerd. Service -- save and restart the service

5. Synchronize with cobbler sync and start xinetd service

The following cobbler sync is very important. If this error must be discharged, it is usually an IP configuration error in terms of experience. Remember to be careful, individual differences need not be expressed in detail.

# cobbler sync

[root@bokeyuan ~]# cobbler sync
task started: 2017-09-03_180107_sync
task started (id=Sync, time=Sun Sep  3 18:01:07 2017)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos7.3-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/centos7.3-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying distros to tftpboot
copying files for distro: centos7.3-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos7.3-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos7.3-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos7.3-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos7.3-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7.3/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos7.3-x86_64/initrd.img
Writing template files for centos7.3-x86_64
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: centos7.3-x86_64
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 shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

 
# systemctl restart xinetd.service
# systemctl enable xinetd.service

 

6. Build another virtual machine to install PXE (ensure the same private network, and preferably 2G memory, if the memory is small, there will be insufficient space at the time of installation) and test the installation.

    

After installation, change boot boot boot

 

 

 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Auto-install has been implemented, but how to customize the profile we want to install

The point is that you need to customize a ks file


Method of Customizing ks File
1. If you are familiar with this file, copy other people's template modification directly or use / root/anaconda-ks.cfg to modify it directly.
2. Use a graphics tool system-config-kickstart to help you configure (I use this method below)


# yum install system-config-kickstart
# system-config-kickstart    

--The operation of graphics is omitted here.


Give you two good ks.cfg file reference:

The first file is the ks file used to install the centos7.3 host, which reads as follows:
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6RbFC2nC$GBugZL7ACuGhck8DbUZgM/
# Use network installation
url --url="http://172.16.13.250/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled

# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=300
part swap --fstype="swap" --size=4000
part / --fstype="xfs"  --size=150000
part /data --fstype="xfs" --size=80000


%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@kde-desktop
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre

%end


The second file is the ks file for the host to install the dual system

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6RbFC2nC$GBugZL7ACuGhck8DbUZgM/
# Use network installation
url --url="http://172.16.13.250/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled

# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --none
# Disk partitioning information
part swap --fstype="swap" --size=4000
part / --fstype="xfs" --grow --size=1


%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@kde-desktop
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre

%end



=========================================================================


# cobbler profile help -- View help
# cobbler profile list -- see which profiles are there
   centos7.3-x86_64    


# cobbler profile report --name=centos7.3-x86_64 |grep Kickstart
Kickstart: / var/lib/cobbler/kickstart/sample_end.ks -- this is the kickstart file for this installation plan
Kickstart Metadata             : {}


Now I customize a ks file and want to make a profile. The steps are as follows:
Step one:
Custom ks file (using system-config-kickstart or directly looking for a template file to modify), get the following file

# vim/var/lib/cobbler/kickstart/centos7.3.ks -- Copy a large section of information below and paste it into this file

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6RbFC2nC$GBugZL7ACuGhck8DbUZgM/
# Use network installation
url --url="http://192.168.100.2/cobbler/ks_mirror/centos7.3/"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# SELinux configuration
selinux --disabled

# Network information
network  --bootproto=dhcp --device=eth0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append="rhgb quiet" --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=300
part swap --fstype="swap" --size=2000
part / --fstype="xfs" --grow --size=1


%post
rm /etc/yum.repos.d/* -rf
cat > /etc/yum.repos.d/local.repo << EOF
[base]
name=base
baseurl=file:///yum
enabled=1
gpgcheck=0
EOF
%end


%packages
@additional-devel
@desktop-debugging
@development
@fonts
@gnome-desktop
@input-methods
@kde-desktop
@legacy-x
@platform-devel
@remote-desktop-clients
@x11
initial-setup
initial-setup-gui
vinagre

%end


Step 2: Make the prepared ks file into a new profile
# cobbler profile add --name=new_centos7.3 --distro=centos7.3-x86_64  --kickstart=/var/lib/cobbler/kickstarts/centos7.3.ks

# cobbler profile list -- There are more customized installation schemes on the original basis
   centos7.3-x86_64
   new_centos7.3


Step three:
test
Then you can create a new client virtual machine and test it with the new_centos7.3 installation name above.



==================================================================

Extensions to the above operations (for reference only)
# cobbler profile edit --name=new_centos7.3 --kickstart=/var/lib/cobbler/kickstarts/xxx.ks   
# cobbler profile remove --name=new_centos7.3    



======================================================================




The client uses koan to connect with cobbler of server to realize automatic reloading system

Clients need to install koan packages (available from epel sources)


# yum install koan  
koan --server=192.168.100.2 --list=profiles -- 192.168.100.2 is the IP of the cobbler server, and the result is the same as that of the cobbler profile list command on the cobbler server.
   centos7.3-x86_64
   new_centos7.3


koan --replace-self --server=192.168.100.2 --profile=new_centos7.3 -- specifies that the client reloads the system according to a profile named new_centos7.3

# reboot -- After typing the above command and using reboot, it will be rebooted (reboot is reboot without typing the above command)

Writing is not easy, feasible and cherished

This is a two-dimensional code.

Give me a chance. The guest officer sweeps me.

Posted by shergar1983 on Tue, 18 Dec 2018 20:45:05 -0800