• disk image builder support x86 unbuntu 18.04


    https://cloud-images.ubuntu.com/bionic/current/

    (dib-env) [root@bogon dib-env]# DIB_RELEASE=bionic disk-image-create vm ubuntu baremetal dhcp-all-interfaces devuser -o ubuntu cloud-init-datasources cloud-init disable-selinux -a x86_64
    2020-07-14 06:51:42.812 | Could not open /root/.cache/image-create/bionic-server-cloudimg-x86_64.squashfs, because No such file or directory
    2020-07-14 06:51:43.533 | INFO diskimage_builder.block_device.blockdevice [-] State already cleaned - no way to do anything here
    (dib-env) [root@bogon dib-env]# 
    export ELEMENTS_PATH=./builder/ironic-python-agent-builder/dib/
    export DIB_DEV_USER_USERNAME=devuser
    export DIB_DEV_USER_PASSWORD=cloud_123.
    export DIB_DEV_USER_PWDLESS_SUDO=YES
    export DIB_CLOUD_INIT_DATASOURCES="ConfigDrive, OpenStack,Ec2"
    #disk-image-create vm centos7 baremetal dhcp-all-interfaces devuser -o centos7 cloud-init-datasources cloud-init disable-selinux -a x86_64

     

     DIB_RELEASE=bionic disk-image-create vm ubuntu baremetal dhcp-all-interfaces devuser -o ubuntu cloud-init-datasources cloud-init disable-selinux -a amd64
    (dib-env) root@zj-x86:/data# find ./ -name ironic-python-agent-builder
    ./dib-env/bin/ironic-python-agent-builder
    ./dib-env/share/ironic-python-agent-builder
    (dib-env) root@zj-x86:/data# ls ./dib-env/bin/ironic-python-agent-builder
    ./dib-env/bin/ironic-python-agent-builder
    (dib-env) root@zj-x86:/data# ls ./dib-env/share/ironic-python-agent-builder/dib/
    ironic-python-agent-ramdisk
    (dib-env) root@zj-x86:/data# 
    (dib-env) root@zj-x86:/data# ls ./dib-env/share/ironic-python-agent-builder/dib/ironic-python-agent-ramdisk/
    cleanup.d         environment.d  package-installs.yaml  README.rst                             static
    element-deps      extra-data.d   pkg-map                source-repository-ironic-python-agent  svc-map
    element-provides  install.d      post-install.d         source-repository-requirements         test-elements
    (dib-env) root@zj-x86:/data# 
    2020-07-14 08:09:17.395 | + source /tmp/in_target.d/post-install.d/../environment.d/99-dib-init-system
    2020-07-14 08:09:17.395 | ++ '[' -z systemd ']'
    2020-07-14 08:09:17.396 | ++ case $DIB_INIT_SYSTEM in
    2020-07-14 08:09:17.396 | dib-run-parts Running /tmp/in_target.d/post-install.d/00-package-installs
    2020-07-14 08:09:17.451 | Nothing to install
    2020-07-14 08:09:17.458 | dib-run-parts 00-package-installs completed
    2020-07-14 08:09:17.458 | dib-run-parts Running /tmp/in_target.d/post-install.d/10-enable-init-scripts
    2020-07-14 08:09:17.464 | dib-run-parts 10-enable-init-scripts completed
    2020-07-14 08:09:17.464 | dib-run-parts Running /tmp/in_target.d/post-install.d/15-disable-selinux
    2020-07-14 08:09:17.482 | Unmount /tmp/dib_build.XEGeNBqK/mnt/var/cache/apt/archives
    2020-07-14 08:09:17.494 | Unmount /tmp/dib_build.XEGeNBqK/mnt/tmp/in_target.d
    2020-07-14 08:09:17.504 | Unmount /tmp/dib_build.XEGeNBqK/mnt/sys
    2020-07-14 08:09:17.511 | Unmount /tmp/dib_build.XEGeNBqK/mnt/proc
    2020-07-14 08:09:17.520 | Unmount /tmp/dib_build.XEGeNBqK/mnt/dev/pts
    2020-07-14 08:09:17.530 | Unmount /tmp/dib_build.XEGeNBqK/mnt/dev
    2020-07-14 08:09:17.784 | INFO diskimage_builder.block_device.blockdevice [-] State already cleaned - no way to do anything here

    原理是这条命令有问题:

     DIB_RELEASE=bionic disk-image-create vm ubuntu baremetal dhcp-all-interfaces devuser -o ubuntu cloud-init-datasources cloud-init disable-selinux -a amd64

    打开日志

    env DIB_RELEASE=bionic DIB_DEBUG_TRACE=1 disk-image-create vm ubuntu baremetal dhcp-all-interfaces devuser -o ubuntu cloud-init-datasources cloud-init disable-selinux block-device-mbr  -a amd64

    发现

    + config=/etc/selinux/config
    2020-07-14 08:26:29.185 | + '[' -e /etc/selinux/config ']'
    2020-07-14 08:26:29.192 | ++ diskimage_builder/lib/img-functions:run_in_target:60                             :   check_break after-error run_in_target bash

    不能去disable-selinux

    env DIB_RELEASE=bionic DIB_DEBUG_TRACE=1 disk-image-create vm ubuntu baremetal dhcp-all-interfaces devuser -o ubuntu cloud-init-datasources cloud-init   -a amd64 

    The actual setup
    What diskimage-builder actually does is take elements and run them. Each elements consists of a set of phases where the element takes actions. All you are really doing is defining the elements and they will insert themselves where needed. It also uses environment variables for tunables, or for other various small tweaks.
    
    This is how I build the images at http://distfiles.gentoo.org/experimental/amd64/openstack/
    
    export GENTOO_PORTAGE_CLEANUP=True
    export DIB_INSTALLTYPE_pip_and_virtualenv=package
    export DIB_INSTALLTYPE_simple_init=repo
    export GENTOO_PYTHON_TARGETS="python3_6"
    export GENTOO_PYTHON_ACTIVE_VERSION="python3.6"
    export ELEMENTS="gentoo simple-init growroot vm openssh-server block-device-mbr"
    export COMMAND="disk-image-create -a amd64 -t qcow2 --image-size 3"
    export DATE="$(date -u +%Y%m%d)"
    
    GENTOO_PROFILE=default/linux/amd64/17.0/no-multilib/hardened ${COMMAND} -o "gentoo-openstack-amd64-hardened-nomultilib-${DATE}" ${ELEMENTS}
    GENTOO_PROFILE=default/linux/amd64/17.0/no-multilib ${COMMAND} -o "gentoo-openstack-amd64-default-nomultilib-${DATE}" ${ELEMENTS}
    GENTOO_PROFILE=default/linux/amd64/17.0/hardened ${COMMAND} -o "gentoo-openstack-amd64-hardened-${DATE}" ${ELEMENTS}
    GENTOO_PROFILE=default/linux/amd64/17.0/systemd ${COMMAND} -o "gentoo-openstack-amd64-systemd-${DATE}" ${ELEMENTS}
    ${COMMAND} -o "gentoo-openstack-amd64-default-${DATE}" ${ELEMENTS}
    For musl I've had to do some custom work as I have to build the stage4s locally, but it's largely the same (with the additional need to define a musl overlay.
    
    cd ~/diskimage-builder
    cp ~/10-gentoo-image.musl diskimage_builder/elements/gentoo/root.d/10-gentoo-image
    pip install -U .
    cd ~/
    
    export GENTOO_PORTAGE_CLEANUP=False
    export DIB_INSTALLTYPE_pip_and_virtualenv=package
    export DIB_INSTALLTYPE_simple_init=repo
    export GENTOO_PYTHON_TARGETS="python3_6"
    export GENTOO_PYTHON_ACTIVE_VERSION="python3.6"
    DATE="$(date +%Y%m%d)"
    export GENTOO_OVERLAYS="musl"
    export GENTOO_PROFILE=default/linux/amd64/17.0/musl/hardened
    
    disk-image-create -a amd64 -t qcow2 --image-size 3 -o gentoo-openstack-amd64-hardened-musl-"${DATE}" gentoo simple-init growroot vm
    
    cd ~/diskimage-builder
    git checkout diskimage_builder/elements/gentoo/root.d/10-gentoo-image
    pip install -U .
    cd ~/
  • 相关阅读:
    Django Ajax
    Django模板层
    Django session源码剖析
    CBV源码剖析
    Django视图层
    Django版本区别
    Django路由层
    Django高级
    Django ORM
    Django入门
  • 原文地址:https://www.cnblogs.com/dream397/p/13298986.html
Copyright © 2020-2023  润新知