码迷,mamicode.com
首页 > Web开发 > 详细

运维自动化之系统安装-应答文件制作并结合ftp和http完成半自动安装

时间:2018-06-14 23:13:50      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:isa   pos   共享网络   otl   hello   额外   SM   共享   boa   

应答文件的制作方式:
cat /root/anaconda-ks.cfg 参考模板进行制作
yum install system-config-kickstart 使用图形工具进行制作
system-config-kickstart 启动工具进行设置
centos6:将应答文件放到共享网络访问中以便进行系统的安装
依靠光盘和应答文件的半自动化安装:
(1)搭建存放应答文件的共享服务 在额外机器上
yum install vsftpd
systemctl start vsftpd
cp ks.cfg /var/ftp/pub/ks6-mini.cfg
vim /var/ftp/pub/ks6-mini.cfg 应答文件模板
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
#Firewall configuration
firewall --disabled

            #Install OS instead of upgrade
                    install

            #Use network installation
                    url --url="http://mirrors.aliyun.com/centos/6/os/x86_64/"

            #Root password
                    rootpw --iscrypted $1$pJZ2W0AP$nFQbRMMdRE1/YO4ddglBi0

            #System authorization information
                    auth  --useshadow  --passalgo=sha512

            #Use text mode install
                    text
                    firstboot --disable

            #System keyboard
                    keyboard us

            #System language
                    lang en_US

            #SELinux configuration
                    selinux --disabled

            #Installation logging level
                    logging --level=info

            #Reboot after installation
                    reboot

            #System timezone
                    timezone  Asia/Shanghai

            #Network information
                    network  --bootproto=dhcp --device=eth0 --onboot=on

            #System bootloader configuration
                    bootloader --location=mbr

            #Clear the Master Boot Record
                    zerombr

            #Partition clearing information
                    clearpart --all --initlabel 

            #Disk partitioning information
                    part / --fstype="ext4" --size=10240
                    part /boot --fstype="ext4" --size=500
                    part swap --fstype="swap" --size=1024

        %post
                    mkdir /root/.ssh/
                    cat > /root/.ssh/authorized_keys <<EOF
                        ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAruUSGJQ6UYn45lD0TRifnqYzy5izR6Eskjk0DV25Eplc7TDHqKH/98WatoN3l0zyM+v9IWxlg2HCaLdm0dreRVu7YP6q0NO9yyu+dgsasTVNdrNJi5B3qRhpLvboSbltVqdC9eT7txmCp7ZMcUH1YqcPSRnf/DulaeIJYmtivHG68X0WGPgTPcGSZ1ujXs6Ho/v8i+3bPnZ+w+KMMI9ajCCzoG9mV7+zshAQ6hdlMaKbosabYcDXCZJ4Q5EUtpjap0nK6nKsVi6TPU+o7GlD1UJF4qUXNGmcP79erp+TxCVEujgA3JP0TdgYXVu4fDw8rppNfxVejd+Kt00yxlMZEw== root@localhost.wang
                    EOF
                    chmod 600 /root/.ssh/authorized_keys
                    cat > /etc/yum.repos.d/base.repo <<EOF
                    [hello]
                    name=base_centos6
                    baseurl=https://mirrors.aliyun.com/centos/6/os/x86_64/
                    gpgcheck=0
                    EOF
                    useradd wang
                    echo 123789|passwd --stdin wang &> /dev/null
                    %end

                    %packages
                    @core
                    @server-policy
                    @workstation-policy
                    vim-enhanced
                    lrzsz
                    %end
    (2)应答文件见linux资料的pxe资料中
    (3)创建虚拟机,设置网络模式
    (4)按ESC,进入光盘启动界面
    (5)按TAB键,进入选项设置界面
    (6)添加选项
                    ks=ftp://192.168.43.60/pub/ks6-mini.cfg  ip=192.168.43.52  netmask=255.255.255.0

                centos7:将ks文件和iso镜像仓库共享到同一个httpd服务目录下以安装系统
                使用system-config-kickstart工具进行应答文件的制作时会找不到待选择安装的包的信息:
                此时需要将base仓库名改成development,然后重启system-config-kickstart程序即可

                yum install httpd
                systemctl start httpd
                cd /var/www/html/
                mkdir ks
                mkdir centos/7 -pv
                vim ks/ks7-desktop.cfg  编辑应答文件
                        #version=DEVEL
                        # System authorization information
                        auth --enableshadow --passalgo=sha512
                        # Use CDROM installation media
                        url --url=http://192.168.43.60/centos/7/
                        #cdrom
                        # Use graphical install
                        text
                        #graphical
                        # Run the Setup Agent on first boot
                        firstboot --disable
                        ignoredisk --only-use=sda
                        # Keyboard layouts
                        keyboard --vckeymap=us --xlayouts=‘us‘
                        # System language
                        lang en_US.UTF-8
                        selinux --disabled
                        firewall --disabled
                        # Network information
                        network  --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto --activate
                        network  --hostname=centos7.yongstar.tech

                        # Root password
                        rootpw --iscrypted $6$UrJjRqHwvRhBAASK$Z/4YajRVYaXxtxgp2Q7c0IU0wYN6Wgo8ImM8KH6KGVKkPdXkXt8NoLW.igTbEO/npImGvC0H/p3lB0gCxcOQP/
                        # System services
                        services --disabled="chronyd"
                        # System timezone
                        timezone Asia/Shanghai --isUtc --nontp
                        user --name=wang --password=$6$lLulhDZMW4jlO7GX$8LZgrCv.0f8AiqkIUf.TCfQtcUFd4iG5smtp6nNQicseSBB88VIcLK1TOl.BU7PJ4vRKTnVSZKqlO3hH6tgOu/ --iscrypted --gecos="wang"
                        # X Window System configuration information
                        xconfig  --startxonboot
                        # System bootloader configuration
                        bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
                        part swap --fstype="swap" --ondisk=sda --size=2048
                        part /boot --fstype="xfs" --ondisk=sda --size=1024
                        part / --fstype="xfs" --ondisk=sda --size=51200
                        part /app --fstype="xfs" --ondisk=sda --size=20480
                        #autopart --type=lvm
                        # Partition clearing information
                        zerombr
                        clearpart --all --initlabel

                        %packages
                        @^gnome-desktop-environment
                        @base
                        @core
                        @desktop-debugging
                        @directory-client
                        @fonts
                        @gnome-apps
                        @gnome-desktop
                        @guest-agents
                        @guest-desktop-agents
                        @input-methods
                        @internet-browser
                        @network-file-system-client
                        @networkmanager-submodules
                        @x11

                        %end

                        %addon com_redhat_kdump --enable --reserve-mb=‘auto‘

                        %end

                        %anaconda
                        pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
                        pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
                        pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
                        %end

                        %post
                        mkdir /root/.ssh/
                        cat > /root/.ssh/authorized_keys <<EOF
                        ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAruUSGJQ6UYn45lD0TRifnqYzy5izR6Eskjk0DV25Eplc7TDHqKH/98WatoN3l0zyM+v9IWxlg2HCaLdm0dreRVu7YP6q0NO9yyu+dgsasTVNdrNJi5B3qRhpLvboSbltVqdC9eT7txmCp7ZMcUH1YqcPSRnf/DulaeIJYmtivHG68X0WGPgTPcGSZ1ujXs6Ho/v8i+3bPnZ+w+KMMI9ajCCzoG9mV7+zshAQ6hdlMaKbosabYcDXCZJ4Q5EUtpjap0nK6nKsVi6TPU+o7GlD1UJF4qUXNGmcP79erp+TxCVEujgA3JP0TdgYXVu4fDw8rppNfxVejd+Kt00yxlMZEw== root@localhost.wang
                        EOF
                        chmod 600 /root/.ssh/authorized_keys
                        cat > /etc/yum.repos.d/base.repo <<EOF
                        [hello]
                        name=base_centos7
                        baseurl=https://mirrors.aliyun.com/centos/7/os/x86_64/
                        gpgcheck=0
                        EOF
                        useradd wang
                        echo 123789|passwd --stdin wang &> /dev/null
                        %end
                chmod 644  ks/ks7-desktop.cfg   设置可读权限
                yum install pykickstart 安装能检测应答文件语法的包
                ksvalidator ks/ks7-desktop.cfg  检测应答文件的语法
                mount /dev/sr0 centos/7/        挂载iso文件到目录下以共享
                如果没有光盘设备:
                        cp /dev/sr0 centos7.iso 制作iso镜像文件
                        mount centos7.iso centos/7/ 挂载iso文件到目录下
                        目前此实验还需挂载光盘引导安装系统

运维自动化之系统安装-应答文件制作并结合ftp和http完成半自动安装

标签:isa   pos   共享网络   otl   hello   额外   SM   共享   boa   

原文地址:http://blog.51cto.com/angwoyufengtian/2129537

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!