cloud-init-18.5
cloud-init源码下载地址:https://launchpad.net/cloud-init/+download
参考:https://cloud.tencent.com/document/product/213/12587
# mkdir /usr/local/sources
将cloud-init-18.5.tar.gz上传到/usr/local/sources目录下
# 上传依赖包到/tmp下
# ls /tmp/cloud-init-soft.tar.bz2
# mv kylin_x86_64.repo kylin_x86_64.repo.bak
# tar -xf /tmp/cloud-init-soft.tar.bz2 -C /media/
# yum-config-manager --add-repo=file:///media/cloud-init-soft/
# echo "gpgcheck=0" >> media_cloud-init-soft_.repo
# yum clean all && yum list
# yum -y install python* #一定要把本机自带的repo备份移走,用上面我们自己创建的!
# cd /usr/local/sources/ && tar -xf cloud-init-18.5.tar.gz
# cd cloud-init-18.5/
# python setup.py build #输出如下:
.....
running build_scripts
creating build/scripts-2.7
copying tools/cloud-init-per -> build/scripts-2.7
# python setup.py install --init-system systemd #输出如下:
......
Using /usr/lib/python2.7/site-packages
Finished processing dependencies for cloud-init==18.5
将/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
# systemctl daemon-reload
# export LC_ALL=C
# 启动并开机自启
# 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
[root@v10-sp1-0518-2 ~]# cloud-init -v
/usr/bin/cloud-init 18.5