{{inherit "preseed_master"}}

{{def squashfs_image}}
{{if node.distro_series in {'quantal'} and node.architecture in {'i386/generic', 'amd64/generic'} and use_squashfs is True }}
d-i    preseed/early_command string anna-install live-installer
d-i    live-installer/enable boolean true
d-i    live-installer/mode select normal
d-i    live-installer/net-image string http://{{server_host}}/MAAS/static/images/{{node.architecture}}/{{node.distro_series}}/filesystem/filesystem.squashfs
{{endif}}
{{enddef}}

{{def proxy}}
d-i     mirror/country string manual
{{if node.architecture in {'i386/generic', 'amd64/generic'} }}
d-i     mirror/http/hostname string archive.ubuntu.com
d-i     mirror/http/directory string /ubuntu
{{else}}
d-i     mirror/http/hostname string ports.ubuntu.com
d-i     mirror/http/directory string /ubuntu-ports
{{endif}}
d-i     mirror/http/proxy string http://{{server_host}}:8000/
{{enddef}}

{{def client_packages}}
d-i     pkgsel/include string cloud-init openssh-server python-software-properties vim avahi-daemon server^
{{enddef}}

{{def preseed}}
{{preseed_data}}
{{enddef}}

{{def post_scripts}}
# Executes late command and disables PXE.
d-i     preseed/late_command string true && \
    in-target sh -c 'f=$1; shift; echo $0 > $f && chmod 0440 $f $*' 'ubuntu ALL=(ALL) NOPASSWD: ALL' /etc/sudoers.d/maas && \
    in-target wget --no-proxy "{{node_disable_pxe_url|escape.shell}}" --post-data "{{node_disable_pxe_data|escape.shell}}" -O /dev/null && \
    true
{{enddef}}
