Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add our VM baseline to amphora images #31

Merged
merged 16 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion amphora-image-builder/README
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Usage
# Set as appropriate to your environment
export TARGET_PROJECT=service

openstack image create --property hw_disk_bus=virtio --property hw_scsi_model=virtio-scsi --property hw_vif_multiqueue_enabled=true --private --project $TARGET_PROJECT --disk-format raw --container-format bare --file amphora-x64-haproxy.raw --progress amphora-x64-$(date +%Y-%m-%d)-haproxy
openstack image create --property hw_disk_bus=virtio --property hw_scsi_model=virtio-scsi --property hw_vif_multiqueue_enabled=true --private --project $TARGET_PROJECT --disk-format qcow2 --container-format bare --file amphora-x64-haproxy.qcow2 --progress amphora-x64-$(date +%Y-%m-%d)-haproxy
```
1 change: 1 addition & 0 deletions amphora-image-builder/elements/vm_baseline/element-deps
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-installs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shellcheck required in the future - nothing critical/blocking at the moment

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
DavidFair marked this conversation as resolved.
Show resolved Hide resolved

set -euo pipefail

#install ansible
/usr/bin/python3 -m venv /tmp/amphora-venv
source /tmp/amphora-venv/bin/activate
/usr/bin/python3 -m pip install ansible
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a venv, just because this will break in 22.04 onwards and it's bad to potentially trash the system packages anyway:

python3 -m venv /tmp/amphora-venv
source /tmp/amphora-venv/bin/activate

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, done

/usr/bin/git clone https://github.com/stfc/cloud-image-builders.git
cd cloud-image-builders

locale-gen en_GB.UTF-8
dpkg-reconfigure locales
update-locale LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF-8
source /etc/default/locale
locale

apt-get install gpg-agent -y
/usr/bin/gpg-agent --daemon

hostname
sed -i "s/hosts: default/hosts: localhost/g" os_builders/*.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I feel like there's something we can tweak in the os_builders dir to make this easier rather than using sed, but I'm drawing a blank currently...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, default includes localhost so it should work but doesnt

echo "{\"groups\": [\"default\", \"cloud\", \"ubuntu\", \"debian\", \"octavia-amphora\"], \"labels\": {\"amphora-build-date\": \"$(date '+%Y-%m-%d %H:%M:%S')\" }}" > /var/ossec/etc/extra/03-amphora.json
ansible-playbook os_builders/prepare_user_image.yml --extra-vars provision_this_machine=true -i os_builders/inventory/localhost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
python3-pip:
installtype: package
git:
installtype: package
gpg-agent:
installtype: package
12 changes: 11 additions & 1 deletion amphora-image-builder/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ git clone --depth=1 https://github.com/openstack/octavia
DIB_REPO_PATH="$(pwd)/octavia"
export DIB_REPO_PATH

# run local config elements
git clone https://github.com/stfc/cloud-image-builders.git
cd /tmp/cloud-image-builders
chmod 755 amphora-image-builder/elements/vm_baseline/*/*
cd /tmp
DIB_LOCAL_ELEMENTS="vm_baseline"
export DIB_LOCAL_ELEMENTS
DIB_LOCAL_ELEMENTS_PATH="/tmp/cloud-image-builders/amphora-image-builder/elements"
export DIB_LOCAL_ELEMENTS_PATH

cd octavia/diskimage-create
pip3 install -r requirements.txt
./diskimage-create.sh -t raw -o "/output/amphora-x64-$(date +"%Y-%m-%d")-haproxy.raw"
./diskimage-create.sh -t qcow2 -m -o "/output/amphora-x64-$(date +"%Y-%m-%d")-haproxy.qcow2"
Loading