使用disk-image-builder(DIB)制作Ironic 裸金属镜像

Diskimage-builder 是openstack社区用于制作镜像的工具。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
基于CentOS 7

#pip3 install diskimage-builder ironic-python-agent-builder
#yum -y install qemu-img
#yum install -y libguestfs-tools-c #提供virt-sysprep
#export DIB_DEV_USER_USERNAME=devuser #初始用户名devuser
#export DIB_DEV_USER_PASSWORD=password #初始密码password
#export DIB_DEV_USER_PWDLESS_SUDO=YES #允许sudo
#export DIB_CLOUD_INIT_DATASOURCES="ConfigDrive, OpenStack" #cloud-init 的datasource是ConfigDrive, OpenStack
#export AUTHORIZE_SSH=true
#export DIB_PYTHON_VERSION=3
#export DIB_PYTHON=python3
构建IPA引导镜像
#ironic-python-agent-builder -o centos7-ipa-x86 --release 7 centos -e "devuser dynamic-login dhcp-all-interfaces"
构建裸机镜像
#disk-image-create centos7 centos7 dhcp-all-interfaces iscsi-boot grub2 dracut-regenerate install-static devuser -o CentOS7 cloud-init-datasources
1
2
#export LIBGUESTFS_BACKEND=direct 
#virt-sysprep --root-password password:password -a CentOS7.qcow2

若 virt-sysprep 报错,请 yum update 再重启物理机

排错

1
2
3
4
5
6
1. git 连接openstack/requirements 失败,更改为自己的源
#vim /usr/local/share/ironic-python-agent-builder/dib/ironic-python-agent-ramdisk/source-repository-requirements

2. setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-rit13y_p/iso8601/
#yum -y install langpacks-zh_CN.noarch