minimal-windows-server.json

{
  "builders": [
    {
      "azure_tags": {
        "OS": "WindowsServer 2019-Datacenter",
        "automation": "packer",
        "date": "{{user `datemark`}}",
        "description": "{{user `image_description`}}"
      },
      "capture_container_name": "appveyor-images-win",
      "capture_name_prefix": "win-{{user `datemark`}}",
      "client_id": "{{ user `azure_client_id` }}",
      "client_secret": "{{ user `azure_client_secret` }}",
      "communicator": "winrm",
      "image_offer": "WindowsServer",
      "image_publisher": "MicrosoftWindowsServer",
      "image_sku": "2019-Datacenter",
      "location": "{{ user `azure_location` }}",
      "os_disk_size_gb": 128,
      "os_type": "Windows",
      "resource_group_name": "{{ user `azure_resource_group_name` }}",
      "storage_account": "{{ user `azure_storage_account` }}",
      "subscription_id": "{{ user `azure_subscription_id` }}",
      "temp_resource_group_name": "packer-RG-win-{{uuid}}",
      "type": "azure-arm",
      "vm_size": "{{user `azure_vm_size`}}",
      "winrm_insecure": "true",
      "winrm_timeout": "30m",
      "winrm_use_ssl": "true",
      "winrm_username": "packer"
    },
    {
      "access_key": "{{user `aws_access_key`}}",
      "ami_description": "{{user `image_description`}}",
      "ami_name": "Appveyor Worker Windows Server 2019 {{uuid}}",
      "communicator": "winrm",
      "instance_type": "{{user `aws_instance_type`}}",
      "launch_block_device_mappings": [
        {
          "delete_on_termination": true,
          "device_name": "/dev/sda1",
          "volume_size": 128,
          "volume_type": "gp2"
        }
      ],
      "region": "{{user `aws_region`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "source_ami_filter": {
        "filters": {
          "name": "Windows_Server-2019-English-Full-Base*",
          "root-device-type": "ebs",
          "virtualization-type": "hvm"
        },
        "most_recent": true,
        "owners": [
          "801119661308"
        ]
      },
      "type": "amazon-ebs",
      "user_data_file": "{{ template_dir }}/scripts/Windows/ec2-userdata.ps1",
      "winrm_insecure": true,
      "winrm_use_ssl": true,
      "winrm_username": "Administrator"
    },
    {
      "account_file": "{{user `gce_account_file`}}",
      "communicator": "winrm",
      "disk_size": 200,
      "image_description": "{{ user `image_description` }}",
      "image_name": "windows-server-2019-{{timestamp}}",
      "instance_name": "windows-server-2019-{{uuid}}",
      "machine_type": "{{ user `gce_machine_type` }}",
      "metadata": {
        "windows-startup-script-cmd": "winrm quickconfig -quiet \u0026 net user /add packer_user \u0026 net localgroup administrators packer_user /add \u0026 winrm set winrm/config/service/auth @{Basic=\"true\"}"
      },
      "project_id": "{{ user `gce_project` }}",
      "source_image_family": "windows-2019",
      "state_timeout": "15m",
      "type": "googlecompute",
      "winrm_insecure": true,
      "winrm_use_ssl": true,
      "winrm_username": "packer_user",
      "zone": "{{ user `gce_zone` }}"
    },
    {
      "clone_from_vm_name": "{{ user `clone_vm_name` }}",
      "communicator": "winrm",
      "cpus": "{{user `cpus`}}",
      "enable_secure_boot": true,
      "enable_virtualization_extensions": true,
      "generation": 2,
      "memory": "{{user `memory`}}",
      "output_directory": "{{user `output_directory`}}",
      "shutdown_command": "powershell -command Disable-NetFirewallRule -Direction Inbound; Stop-Computer",
      "switch_name": "{{user `hyperv_switchname`}}",
      "temp_path": "{{user `packer_temp_dir`}}",
      "type": "hyperv-vmcx",
      "vm_name": "master-vs2019-{{ user `datemark` }}",
      "winrm_password": "{{ user `install_password` }}",
      "winrm_timeout": "1h",
      "winrm_username": "{{ user `install_user` }}"
    },
    {
      "boot_command": [
        "<esc>",
        "<enter>",
        "<enter>",
        "<enter>"
      ],
      "boot_wait": "1s",
      "communicator": "winrm",
      "cpus": "{{user `cpus`}}",
      "disk_size": "{{user `disk_size`}}",
      "enable_secure_boot": true,
      "enable_virtualization_extensions": true,
      "generation": 2,
      "guest_additions_mode": "disable",
      "iso_checksum": "{{user `iso_checksum_type`}}:{{user `iso_checksum`}}",
      "iso_url": "{{user `iso_url`}}",
      "memory": "{{user `memory`}}",
      "output_directory": "{{user `output_directory`}}",
      "secondary_iso_images": [
        "{{ template_dir }}/iso/minimal-windows-server.iso"
      ],
      "shutdown_command": "shutdown -s -t 0",
      "switch_name": "{{user `hyperv_switchname`}}",
      "temp_path": "{{user `packer_temp_dir`}}",
      "type": "hyperv-iso",
      "vm_name": "windows-server-2019-{{user `datemark`}}",
      "winrm_password": "{{user `install_password`}}",
      "winrm_timeout": "2h",
      "winrm_username": "{{user `install_user`}}"
    }
  ],
  "post-processors": [
    {
      "output": "{{user `packer_manifest`}}",
      "strip_path": true,
      "type": "manifest"
    }
  ],
  "provisioners": [
    {
      "environment_vars": [
        "appveyor_user={{user `install_user`}}",
        "appveyor_password={{user `install_password`}}"
      ],
      "scripts": [
        "{{ template_dir }}/scripts/Windows/create_appveyor_user.ps1"
      ],
      "type": "powershell"
    },
    {
      "elevated_password": "{{user `install_password`}}",
      "elevated_user": "{{user `install_user`}}",
      "inline": [
        "Write-Host \"Current user: $(whoami)\""
      ],
      "type": "powershell"
    },
    {
      "elevated_password": "{{user `install_password`}}",
      "elevated_user": "{{user `install_user`}}",
      "scripts": [
        "{{ template_dir }}/scripts/Windows/init_server.ps1"
      ],
      "type": "powershell"
    },
    {
      "elevated_password": "{{user `install_password`}}",
      "elevated_user": "{{user `install_user`}}",
      "only": [
        "azure-arm"
      ],
      "scripts": [
        "{{ template_dir }}/scripts/Windows/extend_system_volume.ps1"
      ],
      "type": "powershell"
    },
    {
      "restart_timeout": "10m",
      "type": "windows-restart"
    },
    {
      "elevated_password": "{{user `install_password`}}",
      "elevated_user": "{{user `install_user`}}",
      "environment_vars": [
        "avma_key={{user `avma_key`}}"
      ],
      "only": [
        "hyperv-iso"
      ],
      "scripts": [
        "{{ template_dir }}/scripts/Windows/activate_avma.ps1"
      ],
      "type": "powershell"
    },
    {
      "destination": "C:/Users/{{user `install_user`}}/AppData/Local/Temp/path-utils.psm1",
      "source": "{{ template_dir }}/scripts/Windows/path-utils.psm1",
      "type": "file"
    },
    {
      "elevated_password": "{{user `install_password`}}",
      "elevated_user": "{{user `install_user`}}",
      "scripts": [
        "{{ template_dir }}/scripts/Windows/install_path_utils.ps1",
        "{{ template_dir }}/scripts/Windows/install_powershell_core.ps1",
        "{{ template_dir }}/scripts/Windows/install_powershell_get.ps1",
        "{{ template_dir }}/scripts/Windows/install_7zip.ps1",
        "{{ template_dir }}/scripts/Windows/install_chocolatey.ps1",
        "{{ template_dir }}/scripts/Windows/install_nuget.ps1",
        "{{ template_dir }}/scripts/Windows/install_pstools.ps1"
      ],
      "type": "powershell"
    },
    {
      "elevated_password": "{{user `install_password`}}",
      "elevated_user": "{{user `install_user`}}",
      "scripts": [
        "{{ template_dir }}/scripts/Windows/install_git.ps1",
        "{{ template_dir }}/scripts/Windows/install_git_lfs.ps1",
        "{{ template_dir }}/scripts/Windows/install_mercurial.ps1",
        "{{ template_dir }}/scripts/Windows/install_subversion.ps1",
        "{{ template_dir }}/scripts/Windows/add_ssh_known_hosts.ps1"
      ],
      "type": "powershell"
    },
    {
      "elevated_password": "{{user `install_password`}}",
      "elevated_user": "{{user `install_user`}}",
      "environment_vars": [
        "appveyor_user={{user `install_user`}}",
        "appveyor_password={{user `install_password`}}",
        "build_agent_mode={{user `build_agent_mode`}}"
      ],
      "scripts": [
        "{{ template_dir }}/scripts/Windows/install_appveyor_build_agent_core.ps1",
        "{{ template_dir }}/scripts/Windows/enable_autologon.ps1"
      ],
      "type": "powershell"
    },
    {
      "inline": [
        "C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/InitializeInstance.ps1 -Schedule"
      ],
      "only": [
        "amazon-ebs"
      ],
      "type": "powershell"
    }
  ],
  "variables": {
    "iso_checksum": "221F9ACBC727297A56674A0F1722B8AC7B6E840B4E1FFBDD538A9ED0DA823562",
    "iso_checksum_type": "sha256",
    "iso_url": "https://software-download.microsoft.com/download/sg/17763.379.190312-0539.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso"
  }
}