Skip to content

Commit

Permalink
Convert AtoM packer template into HCL2
Browse files Browse the repository at this point in the history
  • Loading branch information
replaceafill committed Jan 30, 2025
1 parent 00b1275 commit 0e74e2a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 53 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/vagrant-box-atom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ jobs:
- name: Build
run: |
cd ${{ github.workspace }}/packer/templates/vagrant-box-atom
packer plugins install github.com/hashicorp/virtualbox
packer plugins install github.com/hashicorp/ansible
packer plugins install github.com/hashicorp/vagrant
packer build -on-error=abort template.json
packer init template.json.pkr.hcl
packer build -on-error=abort template.json.pkr.hcl
mv ${{ github.workspace }}/packer/builds/virtualbox/vagrant-atom.box \
${{ github.workspace }}/atom-vagrant-${{ github.event.inputs.version }}.box
- name: Provision a test VM with the new image
Expand Down
49 changes: 0 additions & 49 deletions packer/templates/vagrant-box-atom/template.json

This file was deleted.

60 changes: 60 additions & 0 deletions packer/templates/vagrant-box-atom/template.json.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
packer {
required_plugins {
ansible = {
source = "github.com/hashicorp/ansible"
version = "~> 1"
}
vagrant = {
source = "github.com/hashicorp/vagrant"
version = "~> 1"
}
virtualbox = {
source = "github.com/hashicorp/virtualbox"
version = "~> 1"
}
}
}

source "virtualbox-ovf" "ubuntu" {
headless = "true"
shutdown_command = "echo 'vagrant' | sudo -S shutdown -P now"
source_path = "../../builds/virtualbox/vagrant-base-ubuntu-20.04-amd64/vagrant-base-ubuntu-20.04-amd64.ovf"
ssh_password = "vagrant"
ssh_username = "vagrant"
ssh_wait_timeout = "30s"
}

build {
sources = [
"source.virtualbox-ovf.ubuntu"
]

provisioner "shell" {
execute_command = "echo 'vagrant'|{{ .Vars }} sudo -S -E bash '{{ .Path }}'"
scripts = [
"../../scripts/ubuntu/ansible.sh"
]
}

provisioner "ansible-local" {
extra_arguments = [
"--extra-vars=@./host_vars/all"
]
galaxy_file = "requirements.yml"
host_vars = "./provisioning/host_vars/"
playbook_file = "./provisioning/singlenode.yml"
}

provisioner "shell" {
execute_command = "echo 'vagrant'|{{ .Vars }} sudo -S -E bash '{{ .Path }}'"
scripts = [
"../../scripts/ubuntu/cleanup.sh",
"../../scripts/common/minimize.sh"
]
}

post-processor "vagrant" {
output = "../../builds/{{ .Provider }}/vagrant-atom.box"
vagrantfile_template = "./Vagrantfile"
}
}

0 comments on commit 0e74e2a

Please sign in to comment.