Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cgwalters
Created December 13, 2019 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cgwalters/5741d640f4c2af811f47c043de392c32 to your computer and use it in GitHub Desktop.
Save cgwalters/5741d640f4c2af811f47c043de392c32 to your computer and use it in GitHub Desktop.
Overriding content in an old RHCOS AMI for testing
First, given a build like: https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/rhcos-4.3/43.81.201911081536.0/x86_64/meta.json
Download the qemu image:
```
$ curl -L https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/rhcos-4.3/43.81.201911081536.0/x86_64/rhcos-43.81.201911081536.0-qemu.x86_64.qcow2.gz | gunzip > rhcos-43.81.201911081536.0-qemu.x86_64.qcow2
```
Download new RPM or other content you want, in this case let's assume it's a new hyperkube we want to drop in `/usr/bin`:
`$ curl -L http://example/openshift-hyperkube-4.3.0-201912131246.git.0.09a9468.el8.x86_64.rpm | rpm2cpio | cpio -div`
Run libguestfs:
```
$ guestfish -a rhcos-43.81.201911081536.0-qemu.x86_64.qcow2
```
Inside libguestfs:
```
# run
# mount /dev/sda4 /
# copy-in ./usr/bin/hyperkube /ostree/deploy/rhcos/deploy/<checksum>/usr/bin
# selinux-relabel /ostree/deploy/rhcos/deploy/<checksum>/etc/selinux/targeted/contexts/files/file_contexts /ostree/deploy/rhcos/deploy/<checksum>/usr/bin/hyperkube
# sync
# exit
```
Bless it as an AWS image via coreos-assembler:
```
$ /usr/lib/coreos-assembler/gf-oemid rhcos-43.81.201911081536.0-qemu.x86_64.qcow2 aws
```
Upload it.
@mike-nguyen
Copy link

mike-nguyen commented Dec 14, 2019

Then change launch/snapshop permissions

aws ec2 modify-image-attribute --image-id <ami_id> --launch-permission '{"Add":[{"Group":"all"}]}'

aws ec2 modify-snapshot-attribute --snapshot-id <snapshot_id> --create-volume-permission '{"Add":[{"Group":"all"}]}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment