- Rocky or Ubuntu VM
- Access to the packer project, on dev and prod
- Application credential for packer project, admin is not required
-
Install Python pip and venv modules
# Ubuntu sudo apt install python3-pip python3-venv -y # Rocky sudo dnf install python3-pip python3-venv -y
-
Create a virtual environment
python3 -m venv image_builders source image_builders/bin/activate -
Clone the repository
git clone https://github.com/stfc/cloud-image-builders.git cd cloud-image-builders/os_builders -
Install Python packages
# Unless you are building Rocky 8 images, use the standard requirements.txt pip install -r requirements.txt # For Rocky 8 images pip install -r requirements-rl8.txt
-
Install Packer and dependencies
ansible-playbook prep_builder.yml
-
Create clouds.yaml with application credential
mkdir -p ~/.config/openstack touch ~/.config/openstack/clouds.yaml # Using vim or nano, paste your application credential into the clouds.yaml
The following steps assume you have set up your VM correctly as in the previous steps.
- Ensure environment is prepared
source ~/image_builders/bin/activate cd ~/cloud-image-builders/os_builders export OS_CLOUD=openstack
- Choose from the following steps whether you want to build all, multiple or one image. Also, "env=dev" should match the environment your application credentials were made in.
- Initiate Packer image build for all images
packer build --var env=dev build.pkr.hcl
- Intiate Packer image build for multiple images
# Replace image-name with the actual image name. "openstack." is required packer build --var env=dev -only <openstack.image-name>,<openstack.image-name>... build.pkr.hcl # e.g. packer build --var env=dev -only openstack.ubuntu-jammy-22.04-nogui,openstack.rocky-8-nogui build.pkr.hcl
- Initiate Packer image build for a single image
# Replace image-name with the actual image name. "openstack." is required packer build --var env=dev -only <openstack.image-name> build.pkr.hcl # e.g. packer build --var env=dev -only openstack.ubuntu-jammy-22.04-nogui build.pkr.hcl
- Once the build completes successfully you should get a UUID of the new image
We need to do some basic verification on the image before releasing it to users.
-
Ensure environment is prepared
source ~/image_builders/bin/activate cd ~/cloud-image-builders/os_builders export OS_CLOUD=openstack
-
Build a new VM using the new image. This can be done in Horizon or command line from the VM
openstack server create --wait \ --flavor l3.nano \ --network Internal \ --key-name <openstack-ssh-key-name> \ --image <new-image-id> \ <server-name>
-
SSH to VM with your fed ID, if you are not using an SSH agent you will need to exit this VM first
ssh <fed-id>@172.16.X.Y
-
If you get logged in then testing is complete. If not then it needs to be looked into.
-
Delete VM in Horizon or command line from the VM
openstack server delete <server-name>
The new image needs to be made public and renamed, the old image needs to be deactivated and renamed. This requires an admin account.
-
Ensure environment is prepared
source ~/image_builders/bin/activate cd ~/cloud-image-builders/os_builders export OS_CLOUD=openstack
-
Run the rename_images.sh script to make it public
./rename_images.sh <current-image-name> <new-image-id> # e.g. ./rename_images.sh ubuntu-jammy-22.04-nogui 0b8884fa-111c-4d8f-aa4c-98bed3f521c8
The image configuration is based on the Ansible playbooks run by Packer. If we want to make changes, e.g. update a pinned package version, then you need to update or add new roles / tasks. When making any changes you will need to verify they work across all the OS images in the build file.
-
Ensure environment is prepared
source ~/image_builders/bin/activate cd ~/cloud-image-builders/os_builders export OS_CLOUD=openstack
-
Switch to the next version branch and checkout from there before developing
git switch 0.3.X git checkout -b <new-feature-branch>
-
Create a VM using the current image for the OS
openstack server create --wait \
--network Internal
--flavor l3.nano \
--image <os-image> \
--key-name <your-openstack-key> \
<server-name>- Edit
inventory.ymland add your host's IP
# Contents of: inventory.yml
---
all:
hosts:
test-vm:
ansible_host: "172.16.255.255" # Your host's IP
ansible_user: "ubuntu" # or rocky- Run the baseline against the VM
ansible-playbook -i inventory configure_os_images.yml- If it is an AQ image, run the quattor playbook
ansible-playbook -i inventory quattor.yml-
Repeat steps 5-6 making changes to the playbooks
-
Commit any changes you have made and update the CHANGELOG
-
Make a pull request to the next version branch adding the relevant labels and linking, if any, the GitHub issue
By default we do not put any unreleased changes into the main branch. This allows images to be built without switching branches, preventing mistakes. To release the next version we need to merge the next version branch into main.
This only requires Git and you do not need the environment set up to build images.
-
Clone and change into the repository directory
git clone git@github.com:stfc/cloud-image-builders.git cd cloud-image-builders/os_builders -
Switch to the next version branch
git switch 0.3.X
-
In CHANEGLOG.md update the unreleased section to the next version and date it.
-
Add a new unreleased section at the top linking to the next branch name
-
In RELEASES.md add the releasing version with the date and summarise changes that users using the format of previous releases.
-
Update the version.txt if not already done
-
Update the image_builder_version in build.pkr.hcl if not already done
-
Commit and push the changes as the following, updating where needed:
RELEASE: Version 0.3.0 Brief summary of changes. Including breaking changes or unexpected new beaviour.
-
In GitHub, create a pull request from the next version branch to main here
-
Once pull request is merged create a new branch from main with the next version