|
| 1 | +OpenStack Images |
| 2 | +================ |
| 3 | + |
| 4 | +This role generates guest instance images using disk-image-builder |
| 5 | +and uploads them to OpenStack using the `openstack.cloud.image` module. |
| 6 | + |
| 7 | +Requirements |
| 8 | +------------ |
| 9 | + |
| 10 | +The OpenStack APIs should be accessible from the target host. |
| 11 | +Client credentials should have been set in the environment, or |
| 12 | +using the `clouds.yaml` format. |
| 13 | + |
| 14 | +You must use a virtualenv with system site packages enabled |
| 15 | +as this role relies on python packages installed by the package |
| 16 | +manager, e.g: |
| 17 | + |
| 18 | +``` |
| 19 | +virtualenv --system-site-packages ~/venvs/dib |
| 20 | +``` |
| 21 | + |
| 22 | +Role Variables |
| 23 | +-------------- |
| 24 | + |
| 25 | +`os_images_package_dependencies_extra`: List of additional packages to install |
| 26 | +on the build host. |
| 27 | + |
| 28 | +`os_images_cache`: a path to a directory in which to cache build artefacts. |
| 29 | +It defaults to `~/disk_images` |
| 30 | +`NOTE`: new images will NOT be built, even if changes are made in config, if an image is already cached. |
| 31 | +Use `force_rebuild` flag in order to apply new config changes. |
| 32 | + |
| 33 | +`os_images_auth_type`: OpenStack authentication endpoint and credentials. |
| 34 | +Defaults to `password`. |
| 35 | + |
| 36 | +`os_images_auth`: OpenStack authentication endpoint and credentials. For |
| 37 | +example, a dict of the form: |
| 38 | +* `auth_url`: Keystone auth endpoint URL. Defaults to `OS_AUTH_URL`. |
| 39 | +* `project`: OpenStack tenant/project. Defaults to `OS_TENANT_NAME`. |
| 40 | +* `username`: OpenStack username. Defaults to `OS_USERNAME`. |
| 41 | +* `password`: OpenStack password. Defaults to `OS_PASSWORD`. |
| 42 | + |
| 43 | +`os_images_region`: Define a region to upload the images. Default is None. |
| 44 | + |
| 45 | +`os_images_cacert` is an optional path to a CA certificate bundle. |
| 46 | + |
| 47 | +`os_images_interface` is the endpoint URL type to fetch from the service |
| 48 | +catalog. Maybe be one of `public`, `admin`, or `internal`. |
| 49 | + |
| 50 | +`os_images_list` is a list of YAML dicts, where `elements` and `image_url` are |
| 51 | +mutually exclusive where each contain: |
| 52 | +* `name`: the image name to use in OpenStack. |
| 53 | +* `elements`: a list of diskimage-builder elements to incorporate into the image. |
| 54 | +* `image_url`: the URL to image location on the Internet. |
| 55 | +* `checksum`: Checksum to validate a downloaded image. Format: <algorithm>:<checksum|url>. |
| 56 | +* `env`: (optional) environment variables to define for diskimage-builder parameters. |
| 57 | + This is a dict of the form of `KEY: VALUE`. |
| 58 | +* `packages`: (optional) list of packages to install in the image. |
| 59 | +* `size`: (optional) size to make the image filesystem. |
| 60 | +* `properties`: (optional) dict of properties to set on the glance image. |
| 61 | + Common image properties are available |
| 62 | + [here](https://docs.openstack.org/glance/latest/user/common-image-properties.html). |
| 63 | +* `type`: (optional) image type. Default in DIB is qcow2. Image formats are |
| 64 | + available [here](https://docs.openstack.org/glance/latest/user/formats.html). |
| 65 | +* `force_rebuild`: (optional) boolean flag indicating whether or not the image should always |
| 66 | + be built (even if an existing image that name has been built before). The images on glance |
| 67 | + will be replaced if `os_images_upload` is set to `True`. This defaults to |
| 68 | + `os_images_force_rebuild`if left unset. |
| 69 | +* `is_public`: (optional) whether the image should be set as visible to all |
| 70 | + projects or kept private. |
| 71 | +* `owner`: (optional) ID of the project that should own the uploaded image. |
| 72 | + |
| 73 | +`os_images_common`: A set of elements to include in every image listed. |
| 74 | +Defaults to `cloud-init enable-serial-console stable-interface-names`. |
| 75 | + |
| 76 | +`os_images_dib_pkg_name`: Optionally customise the name parameter passed |
| 77 | +to the ansible.builtin.pip module when installing diskimage-builder. This can |
| 78 | +be used to install diskimage-builder from version control. |
| 79 | + |
| 80 | +`os_images_dib_version`: Optionally set a version of diskimage-builder to install. |
| 81 | +By default this is not constrained. |
| 82 | + |
| 83 | +`os_images_git_elements`: An optional list of elements to pull from github, deploy |
| 84 | +locally for incorporation into the images. Supply a list of dicts with the |
| 85 | +following parameters: |
| 86 | +* `repo`: URL to a git repo for cloning (if not already present) |
| 87 | +* `local`: local path for git cloning |
| 88 | +* `version`: optional git reference (branch, tag, hash) for cloning. Defaults |
| 89 | + to `HEAD` |
| 90 | +* `elements_path`: optional relative path to elements within the repository. |
| 91 | + |
| 92 | +`os_images_elements`: An optional list of paths for site-specific DIB elements. |
| 93 | + |
| 94 | +`os_images_upload`: Whether to upload built images to Glance. Defaults to `True`. |
| 95 | + |
| 96 | +`os_images_force_rebuild`: Whether or not to force a rebuild of the DIB image. The images on Glance |
| 97 | +will be replaced with the newly built image if `os_images_upload` is set to `True`. Defaults to |
| 98 | +`False`. |
| 99 | + |
| 100 | +`os_images_public`: Whether uploaded images are public. Defaults to `True` - note this requires admin permissions. |
| 101 | + |
| 102 | +`os_images_venv`: Path to virtualenv in which to install python dependencies to upload images. |
| 103 | + |
| 104 | +`os_images_dib_venv`: Path to virtualenv in which to install DIB to build images. |
| 105 | + |
| 106 | +`os_images_promote`: Whether or not to retire old and promote new images. Defaults to `False`. |
| 107 | + |
| 108 | +`os_images_build`: Whether or not to build the images. |
| 109 | + |
| 110 | +`os_images_name_suffix`: Image suffix which would be removed during image promotion, for exmple: -rc, -dev, -test etc. Mandatory for promotion functionality. Empty by default. |
| 111 | + |
| 112 | +`os_images_hide`: Whether or not to hide the images in Glance list. Hiding images is available as an option in image retirement/promotion process. Defaults to `False`. |
| 113 | + |
| 114 | +Dependencies |
| 115 | +------------ |
| 116 | + |
| 117 | +Example Playbook |
| 118 | +---------------- |
| 119 | + |
| 120 | +The following playbook generates a guest image and uploads it to OpenStack: |
| 121 | + |
| 122 | + --- |
| 123 | + - name: Generate guest image and upload |
| 124 | + hosts: localhost |
| 125 | + roles: |
| 126 | + - role: stackhpc.openstack.os_images |
| 127 | + os_images_auth: |
| 128 | + auth_url: "{{ lookup('env','OS_AUTH_URL') }}" |
| 129 | + username: "{{ lookup('env','OS_USERNAME') }}" |
| 130 | + password: "{{ lookup('env','OS_PASSWORD') }}" |
| 131 | + project_name: "{{ lookup('env','OS_TENANT_NAME') }}" |
| 132 | + os_images_list: |
| 133 | + - name: FedoraCore |
| 134 | + elements: |
| 135 | + - fedora |
| 136 | + - selinux-permissive |
| 137 | + - alaska-extras |
| 138 | + env: |
| 139 | + DIB_ALASKA_DELETE_REPO: "y" |
| 140 | + DIB_ALASKA_PKGLIST: "pam-python pam-keystone" |
| 141 | + - name: FedoraAtomic27 |
| 142 | + image_url: https://ftp.icm.edu.pl/pub/Linux/dist/fedora-alt/atomic/stable/Fedora-Atomic-27-20180326.1/CloudImages/x86_64/images/Fedora-Atomic-27-20180326.1.x86_64.qcow2 |
| 143 | + properties: |
| 144 | + os_distro: fedora-atomic |
| 145 | + type: qcow2 |
| 146 | + |
| 147 | +Author Information |
| 148 | +------------------ |
| 149 | + |
| 150 | +- Stig Telfer ( <[email protected]>) |
0 commit comments