Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
Signed-off-by: ivan katliarchuk <[email protected]>
  • Loading branch information
ivankatliarchuk committed Mar 23, 2024
1 parent d616771 commit 35d9b81
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ packer-init: ## Packer init
@packer init -upgrade vagrant.pkr.hcl
@packer init -upgrade docker.pkr.hcl

packer-build-vgr: ## Packer build vm
packer-vgr: ## Packer build vm with vagrant
@packer build vagrant.pkr.hcl

packer-build-docker: ## Packer build vm
packer-docker: ## Packer build vm with docker
@packer build docker.pkr.hcl
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@
- [Vagrant how-to](https://github.com/hashicorp/packer-plugin-vagrant/blob/main/docs/builders/vagrant.mdx)
- [Vagrant plugin](https://github.com/hashicorp/packer-plugin-vagrant/tree/main)
- [Packer docker plugin](https://github.com/hashicorp/packer-plugin-docker/blob/main/docs/builders/docker.mdx)
- [Build docker with ansible and packer](https://getbetterdevops.io/build-docker-images-using-ansible-and-packer/)
- [Build docker with packer and ansible](https://gist.github.com/maxivak/2d014f591fc8b7c39d484ac8d17f2a55)
- [Ansible plugin location](https://github.com/hashicorp/packer-plugin-ansible/tree/main)
- [Packer build-in functions](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/functions)
- [Packer functions](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/functions)
- [Packer contextual variables](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/contextual-variables)

36 changes: 33 additions & 3 deletions vagrant.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ packer {
source = "github.com/hashicorp/vagrant"
version = "~> 1"
}
hashicups = {
version = "~> 1"
source = "github.com/hashicorp/hashicups"
}
comment = {
version = ">= v0.2.23"
source = "github.com/sylviamoss/comment"
}
}
}

locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
locals { timestamp = formatdate("DDMMYY-hhmm", timestamp()) }

source "vagrant" "this" {
box_name = "packer/generic/ubuntu2204"
Expand All @@ -21,16 +29,38 @@ source "vagrant" "this" {
communicator = "ssh"
skip_add = true
add_force = true
skip_package = true
teardown_method = "destroy"
output_dir = "vm/ubuntu2204-${local.timestamp}"
}

# source "null" "basic-example" {
# communicator = "none"
# }

build {
name = "ubuntu-${local.timestamp}"
sources = ["source.vagrant.this"]

# provisioner "shell" {
# execute_command = "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'"
# # script = "scripts/setup.sh"
# }

provisioner "comment" {
comment = "*****Basic example to test with LATEST packer*****"
ui = true
}

provisioner "shell" {
inline = ["echo 'Build Vagrant Box'"]
}
inline = ["echo 'Build Vagrant Box ${local.timestamp}'",
"echo HOST $HOST",
"echo UUID ${build.PackerRunUUID}",
]
}

# post-processor "checksum" { # checksum image
# checksum_types = [ "md5", "sha512" ] # checksum the artifact
# keep_input_artifact = false # keep the artifact
# }
}

0 comments on commit 35d9b81

Please sign in to comment.