aboutsummaryrefslogtreecommitdiff
path: root/packer.conf
blob: cfe30862c0cd2f78a3ef7689f67e69e928921c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# This Packer config file is in HOCON, and is converted to JSON at build time.
# https://github.com/lightbend/config/blob/master/HOCON.md
# vim: ts=2 et:

builders = [
  {
    type = "amazon-ebssurrogate"

    ### Builder Instance Details

    region                      = "{{user `build_region`}}"
    subnet_id                   = "{{user `build_subnet`}}"
    instance_type               = "{{user `build_instance_type`}}"
    associate_public_ip_address = "{{user `build_public_ip`}}"
    source_ami_filter {
      # use the latest Amazon Linux AMI
      owners      = [ "{{user `build_ami_owner`}}" ]
      most_recent = "{{user `build_ami_latest`}}"
      filters {
        virtualization-type = "hvm"
        root-device-type    = "ebs"
        architecture        = "{{user `build_arch`}}"
        name                = "{{user `build_ami_name`}}"
      }
    }
    launch_block_device_mappings = [
      {
        volume_type           = "gp2"
        device_name           = "/dev/xvdf"
        delete_on_termination =  "true"
        volume_size           = "{{user `ami_volume_size`}}"
      }
    ]
    shutdown_behavior = "terminate"
    ssh_username      = "{{user `build_user`}}"

    ### AMI Build Details

    ami_name        = "{{user `ami_name`}}"
    ami_description = "{{user `ami_desc`}}"
    tags {
      Name = "{{user `ami_name`}}"
    }
    ami_virtualization_type = "hvm"
    ami_architecture = "{{user `build_arch`}}"  # need packer 1.4.1
    ami_root_device {
      volume_type           = "gp2"
      source_device_name    = "/dev/xvdf"
      device_name           = "/dev/xvda"
      delete_on_termination = "true"
      volume_size           = "{{user `ami_volume_size`}}"
    }
    encrypt_boot  = "{{user `ami_encrypt`}}"
    ena_support   = "true"
    sriov_support = "true"
    ami_groups    = "{{user `ami_access`}}"
    ami_regions   = "{{user `ami_regions`}}"
  }
]


provisioners = [
  {
    type        = "file"
    source      = "nvme/"
    destination = "/tmp"
  }
  {
    type    = "shell"
    script  = "setup-ami"
    environment_vars = [
      "VERSION={{user `version`}}"
      "RELEASE={{user `release`}}"
      "REVISION={{user `revision`}}"
      "ARCH={{user `arch`}}"
      "APK_TOOLS={{user `apk_tools`}}"
      "APK_TOOLS_SHA256={{user `apk_tools_sha256`}}"
      "ALPINE_KEYS={{user `alpine_keys`}}"
      "ALPINE_KEYS_SHA256={{user `alpine_keys_sha256`}}"
      "REPOS={{user `repos`}}"
      "PKGS={{user `pkgs`}}"
      "SVCS={{user `svcs`}}"
      "KERNEL_MODS={{user `kernel_modules`}}"
      "KERNEL_OPTS={{user `kernel_options`}}"
    ]
    use_env_var_file = "true"
    execute_command = "sudo sh -c '. {{.EnvVarFile}} && {{.Path}}'"
  }
]


post-processors = [
  {
    type    = "manifest"
    output  = "profile/{{user `profile`}}/{{user `profile_build`}}/manifest.json"
    custom_data {
      ami_name      = "{{user `ami_name`}}"
      ami_desc      = "{{user `ami_desc`}}"
      profile       = "{{user `profile`}}"
      profile_build = "{{user `profile_build`}}"
      version       = "{{user `version`}}"
      release       = "{{user `release`}}"
      arch          = "{{user `arch`}}"
      revision      = "{{user `revision`}}"
      end_of_life   = "{{user `end_of_life`}}"
    }
  }
]