-
Notifications
You must be signed in to change notification settings - Fork 53
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 aws image generation based of the raw image #338
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# steps | ||
|
||
- build cos (sudo make build) | ||
- create repo (sudo make create-repo) | ||
- create raw image (sudo make raw_disk) | ||
- upload raw image to s3 (aws s3 cp IMAGE s3://cos-images/) | ||
- import image as snapshot (aws ec2 import-snapshot --description "Cos raw import" --disk-container "file://containers.json") | ||
|
||
containers.json: | ||
```json | ||
{ | ||
"Description": "Example image originally in raw format", | ||
"Format": "raw", | ||
"UserBucket": { | ||
"S3Bucket": "cos-images", | ||
"S3Key": "IMAGE_NAME" | ||
} | ||
} | ||
``` | ||
|
||
- create ami from snapshot in aws console | ||
- launch packer with aws image creation (make packer-aws) | ||
|
||
|
||
# image creation | ||
|
||
- Set proper disk partitions (aws/setup-disk.yaml) | ||
- cos-deploy: | ||
`cos-deploy --docker-image quay.io/costoolkit/releases-opensuse:cos-system-0.5.3-3` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: "Default deployment" | ||
stages: | ||
rootfs.after: | ||
- name: "Repart image" | ||
layout: | ||
device: | ||
label: COS_RECOVERY | ||
add_partitions: | ||
- fsLabel: COS_STATE | ||
size: 9192 | ||
pLabel: state | ||
- fsLabel: COS_PERSISTENT | ||
pLabel: persistent |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
source "amazon-ebs" "cos" { | ||
access_key = var.aws_access_key | ||
ami_name = "cos-${var.cos_version}-${formatdate("DDMMYYYY", timestamp())}" | ||
ami_description = "cos-${var.cos_version}-${formatdate("DDMMYYYY", timestamp())}" | ||
instance_type = "t3.small" | ||
region = var.aws_region | ||
secret_key = var.aws_secret_key | ||
ssh_password = "cos" | ||
ssh_username = "root" | ||
source_ami_filter { | ||
filters = { | ||
name = "*cos*recovery*" | ||
root-device-type = "ebs" | ||
virtualization-type = "hvm" | ||
} | ||
most_recent = true | ||
owners = ["self"] | ||
} | ||
launch_block_device_mappings { | ||
device_name = "/dev/sda1" | ||
volume_size = 15 | ||
} | ||
user_data_file = "aws/setup-disk.yaml" | ||
tags = { | ||
Name = "cOS" | ||
Version = var.cos_version | ||
Base_AMI_ID = "{{ .SourceAMI }}" | ||
Base_AMI_Name = "{{ .SourceAMIName }}" | ||
} | ||
} | ||
|
||
source "qemu" "cos" { | ||
accelerator = "${var.accelerator}" | ||
boot_wait = "${var.sleep}" | ||
cpus = "${var.cpus}" | ||
disk_interface = "ide" | ||
disk_size = "${var.disk_size}" | ||
format = "qcow2" | ||
headless = true | ||
iso_checksum = "none" | ||
iso_url = "${var.iso}" | ||
qemuargs = [["-m", "${var.memory}M"]] | ||
shutdown_command = "shutdown -hP now" | ||
ssh_handshake_attempts = "20" | ||
ssh_password = "${var.root_password}" | ||
ssh_timeout = "5m" | ||
ssh_username = "${var.root_username}" | ||
vm_name = "cOS" | ||
} | ||
|
||
source "virtualbox-iso" "cos" { | ||
boot_wait = "${var.sleep}" | ||
cpus = "${var.cpus}" | ||
disk_size = "${var.disk_size}" | ||
format = "ova" | ||
guest_additions_mode = "disable" | ||
guest_os_type = "cOS" | ||
headless = true | ||
iso_checksum = "none" | ||
iso_url = "${var.iso}" | ||
memory = "${var.memory}" | ||
shutdown_command = "shutdown -hP now" | ||
ssh_handshake_attempts = "20" | ||
ssh_password = "${var.root_password}" | ||
ssh_timeout = "5m" | ||
ssh_username = "${var.root_username}" | ||
vm_name = "cOS" | ||
} | ||
|
||
# a build block invokes sources and runs provisioning steps on them. The | ||
# documentation for build blocks can be found here: | ||
# https://www.packer.io/docs/templates/hcl_templates/blocks/build | ||
build { | ||
description = "cOS" | ||
|
||
sources = ["source.amazon-ebs.cos", "source.qemu.cos", "source.virtualbox-iso.cos"] | ||
|
||
provisioner "file" { | ||
except = ["amazon-ebs.cos"] | ||
destination = "/90_custom.yaml" | ||
source = "config.yaml" | ||
} | ||
|
||
provisioner "file" { | ||
except = ["amazon-ebs.cos"] | ||
destination = "/vagrant.yaml" | ||
source = "vagrant.yaml" | ||
} | ||
|
||
provisioner "shell" { | ||
except = ["amazon-ebs.cos"] | ||
inline = ["INTERACTIVE=false cos-installer --config /90_custom.yaml /dev/sda", | ||
"if [ -n \"${var.feature}\" ]; then mount /dev/disk/by-label/COS_OEM /oem; cos-feature enable ${var.feature}; fi" | ||
] | ||
pause_after = "30s" | ||
} | ||
|
||
provisioner "shell" { | ||
only = ["amazon-ebs.cos"] | ||
inline = [ | ||
"${var.aws_cos_install_args}", | ||
"sync" | ||
] | ||
pause_after = "30s" | ||
} | ||
|
||
post-processor "vagrant" { | ||
only = ["virtualbox-iso.cos", "qemu.cos"] | ||
output = "cOS_${var.build}_${var.arch}_${var.flavor}.box" | ||
} | ||
post-processor "compress" { | ||
only = ["virtualbox-iso.cos", "qemu.cos"] | ||
output = "cOS_${var.build}_${var.arch}_${var.flavor}.tar.gz" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also probably this one too should be customizable, with a default (like this one)