---

# build trigger: 201907171352

variables:
  ssh_auth_keys: "{{ env `PACKER_SSH_AUTH_KEYS` }}"
  esx_host: "{{ env `PACKER_ESX_HOST` }}"
  esx_datastore: "{{ env `PACKER_ESX_DATASTORE` }}"
  esx_username: "{{ env `PACKER_ESX_USERNAME` }}"
  esx_password: "{{ env `PACKER_ESX_PASSWORD` }}"
  network_ip: "{{ env `NETWORK_IP` }}"
  network_mask: "{{ env `NETWORK_MASK` }}"
  network_gateway: "{{ env `NETWORK_GATEWAY` }}"
  network_dns: "{{ env `NETWORK_DNS` }}"
  skyreach_system_key: "{{ env `SKYREACH_SYSTEM_KEY` }}"

builders:
  - type: vmware-iso
    vm_name: ubicast-aio
    display_name: ubicast-aio
    output_directory: output
    guest_os_type: debian10-64
    iso_urls:
      - http://debian.univ-lorraine.fr/debian-cd/current/amd64/iso-cd/debian-10.1.0-amd64-netinst.iso
      - https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.1.0-amd64-netinst.iso
    iso_checksum: 23237b0a100a860b3dc7ffcfb5baae4bed5460ac5f3f2b929df3154f3319b9809055b695264586f60289cc6cb25077c12938cc612fee01756bfa779c87d5a315
    iso_checksum_type: sha512
    remote_type: esx5
    remote_host: "{{ user `esx_host` }}"
    remote_datastore: "{{ user `esx_datastore` }}"
    remote_username: "{{ user `esx_username` }}"
    remote_password: "{{ user `esx_password` }}"
    format: ova
    tools_upload_flavor: linux
    vnc_disable_password: true
    cpus: 2
    memory: 2048
    vmx_data:
      ethernet0.networkName: VM Network
    boot_command:
      - "<esc><wait>"
      - "/install.amd/vmlinuz "
      - "initrd=/install.amd/initrd.gz "
      - "hostname={{ .Name }} "
      - "domain= "
      - "auto=true "
      - "url=https://www.ubicast.eu/media/downloads/sys/preseed.cfg "
      - "vga=788 noprompt quiet --<enter>"
    ssh_username: root
    ssh_password: ubicast
    ssh_timeout: 15m
    headless: false
    shutdown_command: shutdown -P now

provisioners:
  - type: shell
    pause_before: 10s
    environment_vars:
      - PACKER_SSH_AUTH_KEYS={{ user `ssh_auth_keys` }}
    scripts:
      - packer/scripts/root.sh
      - packer/scripts/upgrade.sh
  - type: ansible
    ansible_env_vars:
      - NETWORK_IP={{ user `network_ip` }}
      - NETWORK_MASK={{ user `network_mask` }}
      - NETWORK_GATEWAY={{ user `network_gateway` }}
      - NETWORK_DNS={{ user `network_dns` }}
      - SKYREACH_SYSTEM_KEY={{ user `skyreach_system_key` }}
    playbook_file: site.yml
    groups:
      - monitor
      - postgres
      - manager
      - wowza
      - celerity
      - server
      - worker

...
