---
# System prepended metadata

title: Build VM or Baremetal Image

---

# Build VM or Baremetal Image
This document for CentOS

## Install dependences
```
yum install git -y
curl https://bootstrap.pypa.io/get-pip.py | python
pip install virtualenv
virtualenv img
source img/bin/activate
pip install git+https://opendev.org/openstack/diskimage-builder
git clone https://opendev.org/openstack/tripleo-image-elements
git clone https://opendev.org/openstack/heat-agents

```

## Build image
* vm
```
disk-image-create vm \
    centos7 selinux-permissive \
    heat-config \
    os-collect-config \
    os-refresh-config \
    os-apply-config \
    heat-config-cfn-init \
    heat-config-puppet \
    heat-config-script \
    -o centos-software-config.qcow2
```

* baremetal
```
disk-image-create baremetal \
    centos7 selinux-permissive \
    heat-config \
    os-collect-config \
    os-refresh-config \
    os-apply-config \
    heat-config-cfn-init \
    heat-config-puppet \
    heat-config-script \
    -o centos-software-config.qcow2
```

## Troubleshooting
* Build fail because virtualenv too few arguments
Edit
tripleo-image-elements/elements/os-apply-config/install.d/os-apply-config-source-install/10-os-apply-config
tripleo-image-elements/elements/os-collect-config/install.d/os-collect-config-source-install/10-os-collect-config
tripleo-image-elements/elements/os-net-config/install.d/os-net-config-source-install/50-os-net-config-source
tripleo-image-elements/elements/os-refresh-config/install.d/os-refresh-config-source-install/10-os-refresh-config
```diff=
- virtualenv --setuptools xxx
+ virtualenv xxx
```

* Build fail because python-requests package dependencies
Edit
heat-agents/diskimage_builder/elements/pip-and-virtualenv/install.d/pip-and-virtualenv-source-install/04-install-pip
```diff
-PACKAGES_TO_BE_CLEARED="PyYAML python-ipaddress"
+PACKAGES_TO_BE_CLEARED="PyYAML python-ipaddress python-requests"
```

## Reference
* https://docs.openstack.org/heat/train/getting_started/jeos_building.html
* https://docs.openstack.org/diskimage-builder/latest/index.html