|
| 1 | +# Use like: |
| 2 | +# $ PACKER_LOG=1 packer build --on-error=ask -var-file=<something>.pkrvars.hcl <thisfile> |
| 3 | + |
| 4 | +# "timestamp" template function replacement:s |
| 5 | +locals { timestamp = formatdate("YYMMDD-hhmm", timestamp())} |
| 6 | + |
| 7 | +variable "source_image_name" { |
| 8 | + type = string |
| 9 | +} |
| 10 | + |
| 11 | +variable "network" { |
| 12 | + type = string |
| 13 | +} |
| 14 | + |
| 15 | +variable "floating_ip_network" { |
| 16 | + type = string |
| 17 | +} |
| 18 | + |
| 19 | +variable "flavor" { |
| 20 | + type = string |
| 21 | +} |
| 22 | + |
| 23 | +variable "security_groups" { |
| 24 | + type = list(string) |
| 25 | +} |
| 26 | + |
| 27 | +variable "volume_size" { |
| 28 | + type = number |
| 29 | + default = 10 |
| 30 | +} |
| 31 | + |
| 32 | +variable "disk_format" { |
| 33 | + type = string |
| 34 | + default = "qcow2" |
| 35 | +} |
| 36 | + |
| 37 | +variable "distro_name" { |
| 38 | + type = string |
| 39 | +} |
| 40 | + |
| 41 | +variable "ssh_username" { |
| 42 | + type = string |
| 43 | +} |
| 44 | + |
| 45 | +source "openstack" "linux-slurmcompute" { |
| 46 | + image_name = "${var.distro_name}-desktop-${local.timestamp}" |
| 47 | + image_visibility = "private" |
| 48 | + image_disk_format = "${var.disk_format}" |
| 49 | + |
| 50 | + source_image_name = "${var.source_image_name}" |
| 51 | + flavor = "${var.flavor}" |
| 52 | + networks = ["${var.network}"] |
| 53 | + security_groups = "${var.security_groups}" |
| 54 | + floating_ip_network = "${var.floating_ip_network}" |
| 55 | + |
| 56 | + use_blockstorage_volume = true |
| 57 | + volume_size = "${var.volume_size}" |
| 58 | + |
| 59 | + communicator = "ssh" |
| 60 | + ssh_username = "${var.ssh_username}" |
| 61 | + ssh_clear_authorized_keys = true |
| 62 | +} |
| 63 | + |
| 64 | +build { |
| 65 | + source "source.openstack.linux-desktop" { } |
| 66 | + |
| 67 | + provisioner "ansible" { |
| 68 | + galaxy_file = "${path.root}/../requirements.yml" |
| 69 | + playbook_file = "${path.root}/../ansible/linux-slurmcompute.yml" |
| 70 | + use_proxy = false |
| 71 | + extra_arguments = [ |
| 72 | + "-v", |
| 73 | + ] |
| 74 | + ansible_env_vars = ["ANSIBLE_SSH_RETRIES=10"] |
| 75 | + } |
| 76 | + |
| 77 | + post-processor "manifest" { |
| 78 | + custom_data = { |
| 79 | + source = "${source.name}" |
| 80 | + } |
| 81 | + } |
| 82 | +} |
0 commit comments