zoukankan      html  css  js  c++  java
  • centos7源码安装cloud-init

    <template>
      <name>centos72-source</name>
      <os>
        <name>CentOS-7</name>
        <version>2</version>
        <arch>x86_64</arch>
        <install type='iso'>
          <iso>file:///data/md0/iso/CentOS-7.2-x86_64-Minimal-1511.iso</iso>
        </install>
        <rootpw>Ct@2017Yun!@$%.CN</rootpw>
      </os>
      <disk>
        <size>20</size>
      </disk>
      <description>CentOS 7.2 x86_64</description>
      <packages>
        <package name='net-tools'/>
        <package name='acpid'/>
        <package name='cloud-utils-growpart'/>
        <package name='sysstat'/>
      </packages>
      <commands>
        <command name='install_qga'>
    cd /root
    tar xf qga.20171124.tar.gz
    cd qga
    bash ./install_qga_local.sh
        </command>
        
       <command name='sed_profile'>
    echo "NOZEROCONF=yes" >> /etc/sysconfig/network
    rm -rf /etc/udev/rules.d/70-persistent-net.rules
    touch /etc/udev/rules.d/75-persistent-net-generator.rules
    chmod +x /var/lib/cloud/scripts/per-boot/resetroot
    chmod +x /var/lib/cloud/scripts/per-instance/ssh.sh
    chmod +x /usr/local/bin/nic_set_mq.sh
    echo "/usr/local/bin/nic_set_mq.sh > /tmp/nic_set_mq.log 2&gt;&amp;1" >> /etc/rc.d/rc.local
    chmod +x /etc/rc.d/rc.local
       </command>
       
       <command name='install_Cloudinit_and_dependencies'>
    mkdir -p  /root/.pip/
    yum install wget -y
    yum install epel-release -y
    yum clean all
    yum install python-pip -y
    pip install setuptools jinja2 prettytable oauthlib pyyaml requests jsonpatch jsonschema six --upgrade
    cd /root
    wget https://launchpad.net/cloud-init/trunk/17.1/+download/cloud-init-17.1.tar.gz
    tar -zxvf cloud-init-17.1.tar.gz
    cd ./cloud-init-17.1
    python setup.py build
    python setup.py install --init-system systemd
       </command>
        
       <command name='console'>
    grub2-mkconfig -o /boot/grub2/grub.cfg
       </command>
       
       <command name='services'>
    systemctl enable sshd
    systemctl disable firewalld
    systemctl enable cloud-init
    systemctl enable cloud-config
    systemctl enable cloud-final
    systemctl enable cloud-init-local
    systemctl enable acpid
    systemctl disable NetworkManager
       </command>
       
       <command name='clear-logs'>
    rm -rf /root/*
    rm -rf /var/log/anaconda*
    rm -rf /var/log/message
    >/var/log/boot.log
    >/var/log/messages
    >/var/log/cloud-init-output.log
    >/var/log/yum.log
    >/var/log/lastlog
       </command>
      </commands>
    
        <files>
            <file name="/root/qga.20171124.tar.gz" type="url">
                file:///data/nvme0n1/OZ-build-image/scripts/qga.20171124.tar.gz
            </file>
            <file name="/var/lib/cloud/scripts/per-boot/resetroot" type="url">
                file:///data/nvme0n1/OZ-build-image/scripts/resetroot
            </file>
            <file name="/etc/cloud/cloud.cfg" type="url">
                file:///data/nvme0n1/OZ-build-image/scripts/cloud.cfg_centos7
            </file>
            <file name="/usr/local/bin/nic_set_mq.sh" type="url">
                file:///data/nvme0n1/OZ-build-image/scripts/nic_set_mq.sh
            </file>
            <file name="/etc/default/grub" type="url">
                file:///data/nvme0n1/OZ-build-image/scripts/grub_centos7
            </file>
            <file name="/var/lib/cloud/scripts/per-instance/ssh.sh" type="url">
                file:///data/nvme0n1/OZ-build-image/scripts/ssh-centos7.ssh
            </file>
            <file name="/root/.pip/pip.conf" type="url">
                file:///data/nvme0n1/OZ-build-image/scripts/pip.conf
            </file>
            <file name="/lib/systemd/system/cloud-init-local.service" type="url">
                file:///data/nvme0n1/OZ-build-image/scripts/cloud-init-local.service
            </file>
            <file name="/lib/systemd/system/cloud-init.service" type="url">
                file:///data/nvme0n1/OZ-build-image/scripts/cloud-init.service
            </file>
        </files>
    </template>
    View Code
    install
    text
    keyboard us
    lang en_US.UTF-8
    skipx
    network --device eth0 --bootproto dhcp --onboot=on
    rootpw Ct@2017Yun!@$%.CN
    firewall --disabled
    authconfig --enableshadow --enablemd5
    timezone --utc Asia/Shanghai
    selinux --disabled
    zerombr
    clearpart --all --drives=vda
    bootloader --location=mbr --append="console=tty0 console=ttyS0,115200n8"
    part / --fstype xfs --size=2048 --grow --ondisk=vda
    reboot
    %post
    
    cat <<EOL >> /etc/rc.local
    if [ ! -d /root/.ssh ] ; then
        mkdir -p /root/.ssh
        chmod 0700 /root/.ssh
        restorecon /root/.ssh
    fi
    EOL
    
    
    echo "ttyS0" >> /etc/securetty
    cat <<EOF > /etc/init/ttyS0.conf
    start on stopped rc RUNLEVEL=[2345]
    stop on starting runlevel [016]
    respawn
    instance /dev/ttyS0
    exec /sbin/agetty /dev/ttyS0 115200 vt100-nav
    EOF
    %end
    %packages --nobase --excludedocs
    %end
    View Code
  • 相关阅读:
    pl/sql developer 布局结构保存
    pl/sql developer 快捷操作: 显示不可见字符 显示历史sql语句 拷贝整个sql窗口的语句至新的sql窗口
    pl/sql developer 自带汉化选项
    Unix(AIX) set命令
    PAT 1004 To Fill or Not to Fill (25)
    “command line option syntax error,Type command/?for help
    以前的笔记迁移__形參,实參,递归
    清河好程序猿训练营是什么?
    Linux多线程实践(三)线程的基本属性设置API
    Linux定时器工具-crontab 各參数具体解释及怎样查看日志记录
  • 原文地址:https://www.cnblogs.com/gushiren/p/9590950.html
Copyright © 2011-2022 走看看