制作rhe7.3- cloud-init

https://cloud.tencent.com/document/product/213/12587

http://blog.csdn.net/cuigelasi/article/details/73291566


1、ip、dns、



2、repo


3、


yum install python-setuptools python-cheetah python-six python-jsonpatch python-requests python-yaml / PyYAML python-configobj python-oauthlib python-prettytable python-jinja2 python-markdown  --nogpgcheck -y


yum install python2-jsonschema.noarch  --nogpgcheck -y


wget https://launchpad.net/cloud-init/trunk/17.1/+download/cloud-init-17.1.tar.gz


tar -xvf cloud-init-17.1.tar.gz


cd ./cloud-init-17.1
python setup.py build
python setup.py install --init-system systemd




wget http://cloudinit-1251740579.cosgz.myqcloud.com/centos-cloud.cfg?_ga=1.128970569.434046064.1510539882


cp centos-cloud.cfg /etc/cloud/cloud.cfg


useradd syslog


systemctl enable cloud-init-local.service
systemctl start cloud-init-local.service
systemctl enable cloud-init.service
systemctl start cloud-init.service
systemctl enable cloud-config.service
systemctl start cloud-config.service
systemctl enable cloud-final.service
systemctl start cloud-final.service


systemctl status cloud-init-local.service
systemctl status cloud-init.service
systemctl status cloud-config.service
systemctl status cloud-final.service






centos 操作系统特殊执行


将 /lib/systemd/system/cloud-init-local.service 文件内容替换为如下:
[Unit]
Description=Initial cloud-init job (pre-networking)
Wants=network-pre.target
After=systemd-remount-fs.service
Before=NetworkManager.service
Before=network-pre.target
Before=shutdown.target
Conflicts=shutdown.target
RequiresMountsFor=/var/lib/cloud


[Service]
Type=oneshot
ExecStart=/usr/bin/cloud-init init --local
ExecStart=/bin/touch /run/cloud-init/network-config-ready
RemainAfterExit=yes
TimeoutSec=0


# Output needs to appear in instance console output
StandardOutput=journal+console


[Install]
WantedBy=cloud-init.target






将 /lib/systemd/system/cloud-init.service 文件内容替换为如下:
[Unit]
Description=Initial cloud-init job (metadata service crawler)
Wants=cloud-init-local.service
Wants=sshd-keygen.service
Wants=sshd.service
After=cloud-init-local.service
After=systemd-networkd-wait-online.service
After=networking.service
After=systemd-hostnamed.service
Before=network-online.target
Before=sshd-keygen.service
Before=sshd.service
Before=systemd-user-sessions.service
Conflicts=shutdown.target


[Service]
Type=oneshot
ExecStart=/usr/bin/cloud-init init
RemainAfterExit=yes
TimeoutSec=0


# Output needs to appear in instance console output
StandardOutput=journal+console


[Install]
WantedBy=cloud-init.target












vi ~/.bash_history


:%d








三、安装完之后关机,保存相应.cow2文件即可。


*注:执行完成后请勿重启服务器,否则需重新执行下以下操作。*
cloud-init init --local
rm -rf /var/lib/cloud

你可能感兴趣的:(制作rhe7.3- cloud-init)