master fd588b25e698 cached
69 files
17.0 MB
29.2k tokens
1 requests
Download .txt
Repository: chriswayg/packer-proxmox-templates
Branch: master
Commit: fd588b25e698
Files: 69
Total size: 17.0 MB

Directory structure:
gitextract__gjslv1q/

├── .gitignore
├── README.md
├── alpine-3-amd64-proxmox/
│   ├── LICENSE
│   ├── README.md
│   ├── alpine-3-amd64-proxmox.json
│   ├── build.conf
│   ├── http/
│   │   └── answers
│   ├── notes.md
│   └── playbook/
│       ├── ansible.cfg
│       ├── requirements.yml
│       ├── server-template-vars.yml
│       └── server-template.yml
├── alpine-3-amd64-qemu/
│   ├── LICENSE
│   ├── README.md
│   ├── alpine-3-amd64-qemu.json
│   ├── alpine_id_rsa
│   ├── alpine_id_rsa.ppk
│   ├── alpine_id_rsa.pub
│   ├── http/
│   │   └── answers
│   ├── meta-data
│   ├── notes-commands.md
│   ├── output/
│   │   ├── cloud-data.iso
│   │   └── qemu_4.2.0-1_amd64.deb
│   ├── scripts/
│   │   ├── 00base.sh
│   │   ├── 01alpine.sh
│   │   ├── 01networking.sh
│   │   ├── 02sshd.sh
│   │   ├── 04sudoers.sh
│   │   ├── 70random.sh
│   │   ├── 80cloudinit.sh
│   │   ├── 90showip.sh
│   │   └── 99minimize.sh
│   └── user-data
├── build.sh
├── check-functionality.md
├── debian-10-amd64-proxmox/
│   ├── README.md
│   ├── build.conf
│   ├── debian-10-amd64-proxmox.json
│   ├── playbook/
│   │   ├── ansible.cfg
│   │   ├── requirements.yml
│   │   ├── server-template-vars.yml
│   │   └── server-template.yml
│   └── preseed.cfg.j2
├── openbsd-6-amd64-proxmox/
│   ├── README.md
│   ├── build.conf
│   ├── install.conf.j2
│   ├── install.conf.j2.test
│   ├── openbsd-6-amd64-proxmox.json
│   └── playbook/
│       ├── ansible.cfg
│       ├── hosts
│       ├── requirements.yml
│       ├── server-template-vars.yml
│       └── server-template.yml
├── ubuntu-18.04-amd64-proxmox/
│   ├── README.md
│   ├── build.conf
│   ├── playbook/
│   │   ├── ansible.cfg
│   │   ├── requirements.yml
│   │   ├── server-template-vars.yml
│   │   └── server-template.yml
│   ├── preseed.cfg.j2
│   └── ubuntu-18.04-amd64-proxmox.json
└── ubuntu-20.04-amd64-proxmox/
    ├── README.md
    ├── build.conf
    ├── playbook/
    │   ├── ansible.cfg
    │   ├── requirements.yml
    │   ├── server-template-vars.yml
    │   └── server-template.yml
    ├── preseed.cfg.j2
    └── ubuntu-20.04-amd64-proxmox.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
*.img
*.qcow2
*.bz2
*.zip
*.bak
*.bak2
*.log
*.log.*
.DS_Store

# ignore directories
test/
roles/
crash_logs/
logs/
debug/
releases/

# ignore packer_cache
packer_cache
output-qemu
packer-qemu

# created from template
preseed.cfg
install.conf

# others
cloud-config.yml


================================================
FILE: README.md
================================================
# packer-proxmox-templates
:package: Packer templates for building Proxmox KVM images from ISO

- use the latest tagged version which has been tested more thoroughly than 'master'

#### [Debian ](https://www.debian.org/releases/) v10 (buster) [Packer Template](https://github.com/chriswayg/packer-proxmox-templates/tree/master/debian-10-amd64-proxmox) using Packer Proxmox Builder to build a Proxmox VM image template

#### [Ubuntu ](http://releases.ubuntu.com/) 18.04 (bionic) [Packer Template](https://github.com/chriswayg/packer-proxmox-templates/tree/master/ubuntu-18.04-amd64-proxmox) using Packer Proxmox Builder to build a Proxmox VM image template

#### [Ubuntu ](http://releases.ubuntu.com/) 20.04 (focal) [Packer Template](https://github.com/chriswayg/packer-proxmox-templates/tree/master/ubuntu-20.04-amd64-proxmox) using Packer Proxmox Builder to build a Proxmox VM image template

#### [OpenBSD ](https://www.openbsd.org/index.html) 6 [Packer Template](https://github.com/chriswayg/packer-proxmox-templates/tree/master/openbsd-6-amd64-proxmox) using Packer Proxmox Builder to build a Proxmox VM image template

#### [Alpine](https://wiki.alpinelinux.org/wiki/Alpine_Linux:Releases)  Linux [Packer Template](https://github.com/chriswayg/packer-proxmox-templates/tree/master/alpine-3-amd64-proxmox) using Packer Proxmox Builder to build a Proxmox VM image template

#### [Alpine](https://wiki.alpinelinux.org/wiki/Alpine_Linux:Releases)  Linux [Packer Template](https://github.com/chriswayg/packer-proxmox-templates/tree/master/alpine-3-amd64-qemu) using QEMU Builder to build a KVM image usable in Openstack or Proxmox

## Proxmox KVM image templates

- downloads the ISO and places it in Proxmox
- creates a Proxmox VM
- builds the image with Packer using automated installs
- configures the image with Packer using Ansible
- stores it as a Proxmox Template
- see specific README.md for details about each template

### Check Prerequisites

The build script which will run the packer template is *configured to run on the Proxmox server*. Thus the following pre-requisites should be installed on the Proxmox server:

- Ensure that [Proxmox 6](https://www.proxmox.com/en/downloads) is installed
- Set up a DHCP server on `vmbr1`, for example `isc-dhcp-server`  (see section [DHCP](https://github.com/chriswayg/ansible-proxmox/blob/master/tasks/main.yml) in the Proxmox Ansible role).

```
printf  "Proxmox $(pveversion)\n"
```

- Install [Packer](https://www.packer.io/downloads.html) on the Proxmox server

```
apt -y install unzip
packer_ver=1.5.5
wget https://releases.hashicorp.com/packer/${packer_ver}/packer_${packer_ver}_linux_amd64.zip
sudo unzip packer_${packer_ver}_linux_amd64.zip -d /usr/local/bin
packer --version
```

- Install [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) on the Proxmox server

```
apt -y install python3-pip
pip3 install ansible==2.9.7
pip3 install py-bcrypt
```

- Install [j2cli](https://github.com/kolypto/j2cli) on the Proxmox server

```
pip3 install j2cli[yaml]
```

### Download the latest tagged release of packer-proxmox-templates onto the Proxmox server

`wget https://github.com/chriswayg/packer-proxmox-templates/archive/v1.7.zip && unzip v1.7.zip && cd packer-proxmox-templates-*`

### Usage

On the Proxmox Server with Packer installed:

```
cd OSname-xy-amd64-proxmox

# for example
cd debian-10-amd64-proxmox
cd ubuntu-18.04-amd64-proxmox
cd openbsd-6-amd64-proxmox

```

- edit `build.conf`, including the default user and especially the Proxmox URL and the ISO download links for the latest distro version
- edit `playbook/server-template-vars.yml`, especially the SSH Key & regional repositories

```sh
../build.sh proxmox
```

- The template creation can be observed in the Proxmox GUI
- Login via SSH using the default username as set in `build.conf`, or login as root via console (if not disabled)

### Build Options

```sh
../build.sh (proxmox|debug [new_VM_ID])

proxmox    - Build and create a Proxmox VM template
debug      - Debug Mode: Build and create a Proxmox VM template

VM_ID     - VM ID for new VM template (or use default from build.conf)

Enter Passwords when prompted or provide them via ENV variables:
(use a space in front of ' export' to keep passwords out of bash_history)
 export proxmox_password=MyLoginPassword
 export ssh_password=MyPasswordInVM
```

#### Build environment

The Packer templates have been tested with the following versions of Packer and Ansible. If you use different versions, some details may need to be updated.

```sh
printf  "$(lsb_release -d) $(cat /etc/debian_version)\n" && \
  printf  "Proxmox $(pveversion)\n" &&
  packer version && \
  ansible --version |  sed -n '1p' && \
  ansible --version |  sed -n '6p' && \
  j2 --version

        Description:	Debian GNU/Linux 10 (buster) 10.3
        Proxmox pve-manager/6.1-8/806edfe1 (running kernel: 5.3.18-3-pve)
        Packer v1.5.5
        ansible 2.9.7
          python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
        j2cli 0.3.10, Jinja2 2.11.2
```

**NOTE:** For security reasons it would be preferable to build the Proxmox template images on a local Proxmox staging server (for example in a VM) and then to transfer the Proxmox templates using migration onto the live server(s).

It should also be possible to use Packer remotely and to control VM creation remotely via Ansible. The Packer template and the scripts would have to be modified accordingly. If you have it working remotely, please make a pull request.


================================================
FILE: alpine-3-amd64-proxmox/LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



================================================
FILE: alpine-3-amd64-proxmox/README.md
================================================
## [Alpine Linux](http://alpinelinux.org) Packer Template using [Packer Proxmox Builder](https://www.packer.io/docs/builders/proxmox.html) to build a Proxmox KVM image template

Status: **working**

### Features
- downloads the ISO and places it in Proxmox
- creates a Proxmox VM
- builds the image using an answers file and bash scripts
- stores it as a Proxmox Template

### Configurations
- passwordless sudo for default user 'christian'
- SSH public key installed for default user
- display IP and SSH fingerprint before console login
- automatically grow partition after resize by Proxmox

### Instructions
- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)

### Docs
- [Semi-Automatic Installation - Alpine Linux Documentation](https://beta.docs.alpinelinux.org/user-handbook/0.1a/Installing/manual.html)


### License and Credits
- Apache 2.0 Copyright 2019 Christian Wagner
- partially based on Matt Maier's [Packer Alpine Templates](https://github.com/maier/packer-templates)


================================================
FILE: alpine-3-amd64-proxmox/alpine-3-amd64-proxmox.json
================================================
{
    "description": "Build Alpine Linux 3 x86_64 Proxmox template",
    "variables": {
        "proxmox_url": "{{env `proxmox_url`}}",
        "proxmox_username": "root@pam",
        "proxmox_password": "{{env `proxmox_password`}}",
        "proxmox_host": "{{env `proxmox_host`}}",
        "iso_filename": "{{env `iso_filename`}}",
        "vm_id": "{{env `vm_id`}}",
        "vm_name": "alpine3-tmpl",
        "template_description": "Alpine Linux 3.11 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}",
        "vm_default_user": "{{env `vm_default_user`}}",
        "vm_memory": "{{env `vm_memory`}}",
        "ssh_username": "root",
        "ssh_password": "{{env `ssh_password`}}"
    },
    "sensitive-variables": ["proxmox_password", "ssh_password" ],
    "provisioners": [
      {
        "type": "ansible",
        "playbook_file": "./playbook/server-template.yml",
        "extra_arguments": [
          "{{user `ansible_verbosity`}}",
          "--extra-vars", "vm_default_user={{user `vm_default_user`}}",
          "--tags", "all,is_template",
          "--skip-tags", "debuntu,openbsd"
        ],
        "ansible_env_vars": [ "ANSIBLE_CONFIG=./playbook/ansible.cfg", "ANSIBLE_FORCE_COLOR=True" ]
      }
    ],
    "builders": [
        {
            "type": "proxmox",
            "proxmox_url":  "{{user `proxmox_url`}}",
            "insecure_skip_tls_verify": true,
            "username": "{{user `proxmox_username`}}",
            "password": "{{user `proxmox_password`}}",
            "vm_id":  "{{user `vm_id`}}",
            "vm_name": "{{user `vm_name`}}",
            "template_description":"{{user `template_description`}}",
            "memory": "{{user `vm_memory`}}",
            "cores": "2",
            "os": "l26",
            "http_directory": "http",

            "node": "{{user `proxmox_host`}}",
            "network_adapters": [
              {
                "model": "virtio",
                "bridge": "vmbr1"
              }
            ],
            "disks": [
              {
                "type": "sata",
                "disk_size": "8G",
                "storage_pool": "local",
                "storage_pool_type": "directory",
                "format": "qcow2"
              }
            ],
            "ssh_username": "{{user `ssh_username`}}",
            "ssh_password": "{{user `ssh_password`}}",
            "ssh_timeout": "15m",
            "iso_file": "local:iso/{{user `iso_filename`}}",
            "unmount_iso": true,
            "boot_wait": "10s",
            "boot_command": [
                "root<enter><wait>",
                "ifconfig eth0 up && udhcpc -i eth0<enter><wait5>",
                "wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers<enter><wait>",
                "setup-alpine -f $PWD/answers<enter><wait5>",
                "{{user `ssh_password`}}<enter><wait>",
                "{{user `ssh_password`}}<enter><wait>",
                "<wait10><wait5>",
                "y<enter>",
                "<wait10><wait10>",
                "rc-service sshd stop <enter>",
                "mount /dev/sda2 /mnt <enter>",
                "mount /dev/ /mnt/dev/ --bind <enter>",
                "mount -t proc none /mnt/proc <enter>",
                "mount -o bind /sys /mnt/sys <enter>",
                "chroot /mnt /bin/sh -l <enter><wait>",
                "echo '@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories <enter>",
                "echo -e 'nameserver 1.1.1.1' > /etc/resolv.conf <enter>",
                "apk update <enter><wait10>",
                "apk add 'qemu-guest-agent@edgecommunity' 'python' <enter><wait>",
                "echo -e GA_PATH=\"/dev/vport1p1\" >> /etc/conf.d/qemu-guest-agent <enter>",
                "rc-update add qemu-guest-agent <enter>",
                "echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config <enter>",
                "exit <enter><wait>",
                "umount /mnt/sys <enter><wait>",
                "umount /mnt/proc <enter><wait>",
                "umount /mnt/dev <enter><wait>",
                "umount /mnt <enter>",
                "reboot <enter>"
            ]
        }
    ],
    "post-processors": [
      {
        "type": "shell-local",
        "inline_shebang": "/bin/bash -e",
        "inline": ["qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0"]
      }
  ]
}


================================================
FILE: alpine-3-amd64-proxmox/build.conf
================================================
vm_default_user=christian
vm_memory=1024
default_vm_id=40000 # default VM ID for Alpine
proxmox_url=https://proxmox.lightinasia.site:8006/api2/json
proxmox_host=proxmox

iso_url=http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/x86_64/alpine-virt-3.11.6-x86_64.iso
iso_sha256_url=http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/x86_64/alpine-virt-3.11.6-x86_64.iso.sha256

iso_directory=/var/lib/vz/template/iso


================================================
FILE: alpine-3-amd64-proxmox/http/answers
================================================
KEYMAPOPTS="us us"
HOSTNAMEOPTS="-n alpine3"
INTERFACESOPTS="auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
    hostname alpine3
"
DNSOPTS="-d local -n 1.1.1.1 1.0.0.1"
TIMEZONEOPTS="-z UTC"
PROXYOPTS="none"
APKREPOSOPTS="http://nl.alpinelinux.org/alpine/v3.11/main
http://nl.alpinelinux.org/alpine/v3.11/community
"
SSHDOPTS="-c openssh"
NTPOPTS="-c chrony"
DISKOPTS="-s 0 -m sys /dev/sda"


================================================
FILE: alpine-3-amd64-proxmox/notes.md
================================================
# scratchpad


### Docker
```
apk add docker-engine@edgecommunity docker-openrc@edgecommunity docker-cli@edgecommunity docker@edgecommunity
docker --version

apk add py3-setuptools python3-dev libffi-dev openssl-dev gcc libc-dev make
pip3 install --upgrade pip
pip3 install docker-compose
docker-compose --version
```
or

```
apk add docker-compose@edgecommunity
docker-compose --version
```

### boot command:
`openntpd` missing (error)

### qemu guest

```
host:~# cat /etc/conf.d/qemu-guest-agent
# Specifies the transport method used to communicate to QEMU on the host side
# Default: virtio-serial
#GA_METHOD="virtio-serial"

# Specifies the device path for the communications back to QEMU on the host
# Default: /dev/virtio-ports/org.qemu.guest_agent.0
GA_PATH="/dev/vport1p1"
```


================================================
FILE: alpine-3-amd64-proxmox/playbook/ansible.cfg
================================================
[defaults]
deprecation_warnings = False
host_key_checking = False
callback_whitelist = timer, profile_roles
stdout_callback = yaml
roles_path = ./roles
log_path = ./logs/server-template.log


================================================
FILE: alpine-3-amd64-proxmox/playbook/requirements.yml
================================================
- src: https://github.com/chriswayg/ansible-initial-server.git
  #version: v1.7


================================================
FILE: alpine-3-amd64-proxmox/playbook/server-template-vars.yml
================================================
---

iserver_hostname: alpine3-kvm
iserver_sshkey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local"

iserver_alpine_repos:
  - 'http://nl.alpinelinux.org/alpine/v3.11/main'
  - 'http://nl.alpinelinux.org/alpine/v3.11/community'
  - '@edge http://nl.alpinelinux.org/alpine/edge/main'
  - '@testing http://nl.alpinelinux.org/alpine/edge/testing'
  - '@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community'


================================================
FILE: alpine-3-amd64-proxmox/playbook/server-template.yml
================================================
---
# Any remote_user defined in tasks will be ignored.
# Packer will always connect with the user given in the json config for this provisioner.
# https://www.packer.io/docs/provisioners/ansible.html

# TODO: For unclear reasons, I could only get it to work with the root user in Packer
# 'become' in playbook or role tasks seem to be ignored by Packer Ansible

- name: Initial configuration of a server.
  hosts: all
  vars_files:
    - server-template-vars.yml
  roles:
    - role: ansible-initial-server
      vars:
        iserver_user: "{{ vm_default_user }}"


================================================
FILE: alpine-3-amd64-qemu/LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



================================================
FILE: alpine-3-amd64-qemu/README.md
================================================
## [Alpine Linux](http://alpinelinux.org) Packer Template using QEMU Builder to build a KVM cloud image usable in Proxmox or Openstack

Status: **working**

* this creates a cloud image with cloud-init to be used on Proxmox and possibly Openstack

### Prerequisites

1) Packer 1.5.5 requires a recent qemu version with gtk support and fails on Ubuntu 18.04. Therefore install a current qemu from source.

- Install qemu build dependencies

```
sudo apt autoremove
sudo apt purge qemu

#sudo apt-get install build-essential pkg-config libglib2.0-dev  libpixman-1-dev libgtk-3-dev
sudo apt-get build-dep qemu
sudo apt-get install libgtk-3-dev checkinstall
```

- Build and install qemu 4.2.0

```
wget https://download.qemu.org/qemu-4.2.0.tar.xz
tar xvJf qemu-4.2.0
cd qemu-4.2.0
./configure --target-list=x86_64-softmmu --enable-gtk
make
sudo checkinstall
```

2) Install packer (see pre-reqs in main README)

### Usage notes

```sh
cd alpine-3-amd64-qemu
sudo packer build alpine-3-amd64-qemu.json
```
- The image is saved as `alpine-311-cloudimg-amd64.qcow2` in the `output` directory

- Test the image locally:
  - adapt `user-data` and `meta-data` as needed
  - login as root on the console. Password: alpineqemu
  - login via ssh

```sh
genisoimage -output output/cloud-data.iso -volid cidata -joliet -rock user-data meta-data

sudo qemu-system-x86_64 output/alpine-311-cloudimg-amd64.qcow2 -netdev  user,id=user.0,hostfwd=tcp::2222-:22 -device  virtio-net,netdev=user.0 -cdrom output/cloud-data.iso

ssh -i alpine_id_rsa -p 2222 alpine@localhost
```
- To install the image as a template on Proxmox, the following script can be used:
- [Script to download a cloud image and create a Proxmox 6 template](https://gist.github.com/chriswayg/43fbea910e024cbe608d7dcb12cb8466)

### Features
- default user alpine
- add user-data via image drive
- SSH login only via SHH key
- passwordless sudo
- no root login via ssh
  - optional root login via console

### cloud-init features on Alpine
- the fuctionality is not quite complete on Alpine

#### Working
- getting user and metadata from image drive
- setting hostname (1st boot)
- setting up user (1st boot)
- copying SSH authorized keys (1st boot)
- automatically growing the disk drive with growpart
  - `qm resize 8000 scsi0 +30G` upon restart

#### Not working (apparently)
- writing of network config
- password for user (not entered into `/etc/shadow`)
- changed data on image-drive is not applied after 1st boot
- serial console appears to be buggy, making it hard to log in

### Fulfills most Openstack requirements

For a Linux-based image to have full functionality in an OpenStack Compute cloud, there are a few requirements. For some of these, you can fulfill the requirements by installing the  [cloud-init](https://cloudinit.readthedocs.org/en/latest/)  package.

* Disk partitions and resize root partition on boot (cloud-init)
* No hard-coded MAC address information
* SSH server running
* Disable firewall
* Access instance using ssh public key (cloud-init)
* Process user data and other metadata (cloud-init)

[OpenStack Docs: Image requirements](https://docs.openstack.org/image-guide/openstack-images.html)

### Docs
- [Semi-Automatic Installation - Alpine Linux Documentation](https://beta.docs.alpinelinux.org/user-handbook/0.1a/Installing/manual.html)
- [OpenStack Docs: Create images manually](https://docs.openstack.org/image-guide/create-images-manually.html)

### Build environment

```sh
packer version && qemu-system-x86_64 -version && lsb_release -d

      Packer v1.5.5
      QEMU emulator version 4.2.0
      Ubuntu 18.04.4 LTS
```

### License and Credits
- Apache 2.0 Copyright 2019 Christian Wagner
- partially based on Matt Maier's [Packer Alpine Templates](https://github.com/maier/packer-templates)


================================================
FILE: alpine-3-amd64-qemu/alpine-3-amd64-qemu.json
================================================
{
  "description": "Build base Alpine Linux x86_64",

  "variables": {
      "disk_size": "2048",
      "memory": "1024",
      "cpus": "1"
  },
  "provisioners": [
    {
      "type": "shell",
      "scripts": [
        "scripts/00base.sh",
        "scripts/01alpine.sh",
        "scripts/01networking.sh",
        "scripts/02sshd.sh",
        "scripts/04sudoers.sh",
        "scripts/70random.sh",
        "scripts/80cloudinit.sh",
        "scripts/90showip.sh",
        "scripts/99minimize.sh"
      ]
    }
  ],
  "builders": [
    {
      "type": "qemu",
      "qemu_binary": "qemu-system-x86_64",
      "format": "qcow2",
      "accelerator": "kvm",
      "qemuargs": [
        [ "-device", "virtio-rng-pci" ],
        [ "-device", "virtio-scsi-pci,id=scsi0" ],
        [ "-device", "scsi-hd,bus=scsi0.0,drive=drive0" ],
        [ "-device", "virtio-net,netdev=user.0" ]
      ],
      "disk_interface": "virtio-scsi",
      "headless": false,
      "disk_size": "{{user `disk_size`}}",
      "memory": "{{user `memory`}}",
      "cpus": "{{user `cpus`}}",
      "http_directory": "http",

      "iso_urls": ["isos/alpine-virt-3.11.5-x86_64.iso",
                   "http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/x86_64/alpine-virt-3.11.5-x86_64.iso"],
      "iso_checksum": "8e14a8f23d1d0a3772d486a94a7d707df65a942e605617ed6431fcb1ede387e4",
      "iso_checksum_type": "sha256",

      "communicator": "ssh",
      "ssh_username": "root",
      "ssh_password": "alpineqemu",
      "ssh_wait_timeout": "10m",
      "shutdown_command": "poweroff",
      "boot_wait": "30s",
      "boot_command": [
        "root<enter><wait>",
        "ifconfig eth0 up && udhcpc -i eth0<enter><wait5>",
        "wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers<enter><wait>",
        "setup-alpine -f $PWD/answers<enter><wait5>",
        "alpineqemu<enter><wait>",
        "alpineqemu<enter><wait>",
        "<wait10><wait10>",
        "y<enter>",
        "<wait10><wait10><wait10>",
        "<wait10><wait10><wait10>",
        "rc-service sshd stop<enter>",
        "mount /dev/sda2 /mnt<enter>",
        "echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>",
        "umount /mnt<enter>",
        "reboot<enter>"
      ]
    }
  ],
  "post-processors": [
    {
      "type": "shell-local",
      "inline": ["mv -fv output-qemu/packer-qemu output/alpine-311-cloudimg-amd64.qcow2 && rmdir -v output-qemu"]
    }
  ]
}


================================================
FILE: alpine-3-amd64-qemu/alpine_id_rsa
================================================
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEArvZdvBLBAsidAnJ3ZKtNb2pFigEzr+P9KArOVV5futoZFWpI
Ho74XJ1E7bith29MQpsovWuUGiBqoGKDIFXxarpGQjs0NcTeO+gPjM3bYLnQrdh5
3V8n5iU8HoE27OHUj/+jtt3Ofe1spu7le6Vn5oRdOZEV/3ysK0YuNoXcHcJ2+1Ye
YsOY7D7J8zVXYkT8UgaDJTUaaIg8YIGFI7Fx16zVY2V72qbG3AYzLCWi15CdFEvV
O/S6lPOqrK1mHvznYt5jXiLnagyxQW95jeFO2Ux9GsFDQqB9cr9l/5ahGcdmYF8J
KsCqvW8j0gb94RGn0P/tHv/tyokHUd23gIc6kQIDAQABAoIBAQCLysar/WP/oGBq
0yB367LMIWH8WOd+UrAzrSac6PGd7qJ6DNggqmTgQrwPIC5t9sw8r5IGfozvrxTi
nrNcQ67HcpuuUXVuvKQ/wzOhcd0lVHHaZQtBh8TuSrPVP7Kt4+YdQ8j/1AsnbGsS
me/7MfZpJTsDQtwLrQY28TT9VUjA8QuCdz/1XFAq7eEqoOvQVfC+ulj5YwDqueHr
zC6ewZ4GFp7tpj66qYM0YR3jZXjqQCeqiFyxTbTxcErhlihcE499uIUoedb7GS4W
dOlTvfmZdxCM8xitXTDWrnmF3P+woXowE0gl8EcPmGcN+gsNUYgwnGF1YZM4/8Cd
0g7hKHIBAoGBAOJEtySti50urzrXF5hQ8/p6Kos/0IVgqBUQ1tcOWUZ2Ln9uuhpU
F+Esx3TQV2ET6MIh3DIGzqahcPMdaVuw5WwLxW5RBPZ+I6G2vgsXEfF2oQspiKH+
M49LFjK+XKIeTQpGc4/r8RDwlPsO5K3HsezCdfCDJPN0r0sIL0V515qhAoGBAMXz
zW7al+blz66XmI85H5qem/Vz8KioBNtLZK2SAazdtrDKhB7wR9ADKs4eOkWUOkeY
e/Oh6AV0a9cPSZ/KiYiGO1Y/manZ51MAUjmlRepMJKCbckNAJLgzfFuXg5EtqYY7
Q9mcPxae3U313H0hI77mGEd9NhcaoD0LlWaavwnxAoGBANsY9s6JTbuyTPOI+8v9
94H/cdrMvDmq0pczaxVrS38zSOsUaRi9fTIJjknKxBG4mZYB+5plhQ1NHnYLcM3c
iQsKiu67fTbCBfa9YWCTwkgyOtb4LNnPsFV8u83/Duvcs3TTq2sdaJyimWBRl5W+
3McJtfJiyxEDWAorrrpztRaBAoGAIW79KpT3BQOZoTZviPkv8lCJrNpJMmM2dsd0
GLDJYaYM3i1GRWd16ZcvWqLWWrwfX8pMXSjiZFF2iVtGpxtxQULSsM2LKZnpLSan
vJ7CgUEdCpdWpC8oRIhFn76mdRXORSKrYgy2xx5L6If3FpdLT0nTnfdy9FIF8GmN
cUf/rjECgYBfGI7fUm6E98xuuQGDOMiP4VPGm4aOznCnyXF3fI+Uw0ke/kI+Wvm+
LEeEHGlbOiS7x8nV5usm9j1DDrOFBhMWIC9Rasn6NZbcMYoQpiYABPJHBBGaqa19
PX9Dt8IssWUIhX1fFQdTJrzMo1VPZMu5NR3Axfp+z3ubosrTuplS1A==
-----END RSA PRIVATE KEY-----


================================================
FILE: alpine-3-amd64-qemu/alpine_id_rsa.ppk
================================================
PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: imported-openssh-key
Public-Lines: 6
AAAAB3NzaC1yc2EAAAADAQABAAABAQCu9l28EsECyJ0Ccndkq01vakWKATOv4/0o
Cs5VXl+62hkVakgejvhcnUTtuK2Hb0xCmyi9a5QaIGqgYoMgVfFqukZCOzQ1xN47
6A+MzdtgudCt2HndXyfmJTwegTbs4dSP/6O23c597Wym7uV7pWfmhF05kRX/fKwr
Ri42hdwdwnb7Vh5iw5jsPsnzNVdiRPxSBoMlNRpoiDxggYUjsXHXrNVjZXvapsbc
BjMsJaLXkJ0US9U79LqU86qsrWYe/Odi3mNeIudqDLFBb3mN4U7ZTH0awUNCoH1y
v2X/lqEZx2ZgXwkqwKq9byPSBv3hEafQ/+0e/+3KiQdR3beAhzqR
Private-Lines: 14
AAABAQCLysar/WP/oGBq0yB367LMIWH8WOd+UrAzrSac6PGd7qJ6DNggqmTgQrwP
IC5t9sw8r5IGfozvrxTinrNcQ67HcpuuUXVuvKQ/wzOhcd0lVHHaZQtBh8TuSrPV
P7Kt4+YdQ8j/1AsnbGsSme/7MfZpJTsDQtwLrQY28TT9VUjA8QuCdz/1XFAq7eEq
oOvQVfC+ulj5YwDqueHrzC6ewZ4GFp7tpj66qYM0YR3jZXjqQCeqiFyxTbTxcErh
lihcE499uIUoedb7GS4WdOlTvfmZdxCM8xitXTDWrnmF3P+woXowE0gl8EcPmGcN
+gsNUYgwnGF1YZM4/8Cd0g7hKHIBAAAAgQDiRLckrYudLq861xeYUPP6eiqLP9CF
YKgVENbXDllGdi5/broaVBfhLMd00FdhE+jCIdwyBs6moXDzHWlbsOVsC8VuUQT2
fiOhtr4LFxHxdqELKYih/jOPSxYyvlyiHk0KRnOP6/EQ8JT7DuStx7HswnXwgyTz
dK9LCC9FedeaoQAAAIEAxfPNbtqX5uXPrpeYjzkfmp6b9XPwqKgE20tkrZIBrN22
sMqEHvBH0AMqzh46RZQ6R5h786HoBXRr1w9Jn8qJiIY7Vj+ZqdnnUwBSOaVF6kwk
oJtyQ0AkuDN8W5eDkS2phjtD2Zw/Fp7dTfXcfSEjvuYYR302FxqgPQuVZpq/CfEA
AACAXxiO31JuhPfMbrkBgzjIj+FTxpuGjs5wp8lxd3yPlMNJHv5CPlr5vixHhBxp
Wzoku8fJ1ebrJvY9Qw6zhQYTFiAvUWrJ+jWW3DGKEKYmAATyRwQRmqmtfT1/Q7fC
LLFlCIV9XxUHUya8zKNVT2TLuTUdwMX6fs97m6LK07qZUtQ=
Private-MAC: cc9bd253b5cab2859e8324323fa108e5308d8108


================================================
FILE: alpine-3-amd64-qemu/alpine_id_rsa.pub
================================================
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu9l28EsECyJ0Ccndkq01vakWKATOv4/0oCs5VXl+62hkVakgejvhcnUTtuK2Hb0xCmyi9a5QaIGqgYoMgVfFqukZCOzQ1xN476A+MzdtgudCt2HndXyfmJTwegTbs4dSP/6O23c597Wym7uV7pWfmhF05kRX/fKwrRi42hdwdwnb7Vh5iw5jsPsnzNVdiRPxSBoMlNRpoiDxggYUjsXHXrNVjZXvapsbcBjMsJaLXkJ0US9U79LqU86qsrWYe/Odi3mNeIudqDLFBb3mN4U7ZTH0awUNCoH1yv2X/lqEZx2ZgXwkqwKq9byPSBv3hEafQ/+0e/+3KiQdR3beAhzqR christian@ubuntu


================================================
FILE: alpine-3-amd64-qemu/http/answers
================================================
KEYMAPOPTS="us us"
HOSTNAMEOPTS="-n alpine3"
INTERFACESOPTS="auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
    hostname alpine3
"
DNSOPTS="-d local -n 1.1.1.1 1.0.0.1"
TIMEZONEOPTS="-z UTC"
PROXYOPTS="none"
APKREPOSOPTS="http://dl-cdn.alpinelinux.org/alpine/v3.11/main"
SSHDOPTS="-c openssh"
NTPOPTS="-c openntpd"
DISKOPTS="-s 0 -m sys /dev/sda"


================================================
FILE: alpine-3-amd64-qemu/meta-data
================================================
instance-id: 12fb410a-6652-46e9-8b32-db6698678ddc


================================================
FILE: alpine-3-amd64-qemu/notes-commands.md
================================================
## Misc. Notes

- Alpine boot kernel 'virt' with randomness from CPU & info during boot for testing
```
virt random.trust_cpu=1 debug
```


================================================
FILE: alpine-3-amd64-qemu/output/qemu_4.2.0-1_amd64.deb
================================================
[File too large to display: 16.9 MB]

================================================
FILE: alpine-3-amd64-qemu/scripts/00base.sh
================================================
set -ux

apk upgrade -U --available

source /etc/os-release

printf "\n $PRETTY_NAME ($VERSION_ID) Cloud Server\n\n" > /etc/motd


================================================
FILE: alpine-3-amd64-qemu/scripts/01alpine.sh
================================================
set -ux

# adding repositories needed for cloud-init
echo "http://nl.alpinelinux.org/alpine/v3.11/community" >> /etc/apk/repositories
echo "@edge http://nl.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
echo "@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories

# update all packages, including the kernel.
apk update
apk upgrade


================================================
FILE: alpine-3-amd64-qemu/scripts/01networking.sh
================================================
set -ux

# nothing special required

exit 0

================================================
FILE: alpine-3-amd64-qemu/scripts/02sshd.sh
================================================
set -eux

# RootLogin without password was permitted in order to allow packer ssh access
# to provision the system. Its removed here to make the server more secure.
sed -i '/^PermitRootLogin no/d' /etc/ssh/sshd_config

# disable ssh password authentication
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config


================================================
FILE: alpine-3-amd64-qemu/scripts/04sudoers.sh
================================================
set -eux

# this configuration allows the alpine account to sudo su - without needing a password

# Install sudo
apk add sudo shadow

# Create Initial User
adduser -D alpine -G wheel

# allow sudo without password
echo "Defaults exempt_group=wheel" > /etc/sudoers
echo "%wheel ALL=NOPASSWD:ALL" >> /etc/sudoers

# allows ssh login without the user being locked
# https://unix.stackexchange.com/questions/193066/how-to-unlock-account-for-public-key-ssh-authorization-but-not-for-password-aut
usermod -p '*' alpine

# the root user is also being blocked from ssh login in sshd_config
# remove root password (optional - makes it impossible to login as root from console)
#usermod -p '*' root

# lock root account
#passwd -l root


================================================
FILE: alpine-3-amd64-qemu/scripts/70random.sh
================================================
set -eux

# Fixes: Boot delay/issues because of limited entropy
# https://gitlab.alpinelinux.org/alpine/aports/issues/9960
apk add haveged
rc-update add haveged boot


================================================
FILE: alpine-3-amd64-qemu/scripts/80cloudinit.sh
================================================
set -eux

apk add cloud-init@testing

# install missing dependencies
apk add eudev

# needed for 'growpart'
apk add cloud-utils@testing

# install utils
apk add acpi
apk add nano

# make sure CD drive with cloud-init config data gets mounted
# /dev/sr0        /media/cdrom    iso9660 ro 0 0
sed -i 's/\/dev\/cdrom/\/dev\/sr0/g' /etc/fstab
sed -i 's/noauto,ro/ro/g' /etc/fstab

# writing of network config is not implemented in alpine cloud-init
#apk add iproute2 ifupdown
echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

# Start Cloud-Init on Boot
rc-update add cloud-init default

# enable automatically growing the partition
cat > /etc/cloud/cloud.cfg.d/10_growpart.cfg << "EOF"
growpart:
  mode: growpart
  devices: ["/dev/sda2"]
  ignore_growroot_disabled: false

# the above settings do not seem to get used, thus run growpart here
bootcmd:
 - growpart /dev/sda 2
EOF

# activate serial console
# it is buggy, as it makes it hard to log in

# sed -i 's/quiet/console=ttyS0,9600/g' /etc/update-extlinux.conf
# update-extlinux
#
# sed -i 's/#ttyS0/ttyS0/g' /etc/inittab


================================================
FILE: alpine-3-amd64-qemu/scripts/90showip.sh
================================================
# show SSH key fingerprint and IP address on console

cp /etc/issue /etc/issue-standard

# Creates a script which will run when the network comes up
cat > /etc/network/if-up.d/show-ip-address << "EOF"
#!/bin/sh
if [ "$METHOD" = loopback ]; then
    exit 0
fi

# Only run from ifup.
if [ "$MODE" != start ]; then
    exit 0
fi

cp /etc/issue-standard /etc/issue
printf "ECDSA key fingerprint:\n$(ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub)\n" >> /etc/issue
printf "\nSSH user: alpine     IP: $(ifconfig eth0 | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')\n\n" >> /etc/issue

EOF

chmod +x /etc/network/if-up.d/show-ip-address


================================================
FILE: alpine-3-amd64-qemu/scripts/99minimize.sh
================================================
set -ux

dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
# Block until the empty file has been removed, otherwise, Packer
# will try to kill the box while the disk is still full and that's bad
sync
sync
sync

exit 0


================================================
FILE: alpine-3-amd64-qemu/user-data
================================================
#cloud-config
hostname: alpine3
ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu9l28EsECyJ0Ccndkq01vakWKATOv4/0oCs5VXl+62hkVakgejvhcnUTtuK2Hb0xCmyi9a5QaIGqgYoMgVfFqukZCOzQ1xN476A+MzdtgudCt2HndXyfmJTwegTbs4dSP/6O23c597Wym7uV7pWfmhF05kRX/fKwrRi42hdwdwnb7Vh5iw5jsPsnzNVdiRPxSBoMlNRpoiDxggYUjsXHXrNVjZXvapsbcBjMsJaLXkJ0US9U79LqU86qsrWYe/Odi3mNeIudqDLFBb3mN4U7ZTH0awUNCoH1yv2X/lqEZx2ZgXwkqwKq9byPSBv3hEafQ/+0e/+3KiQdR3beAhzqR christian@ubuntu
chpasswd:
  expire: False
users:
  - default
package_upgrade: true


================================================
FILE: build.sh
================================================
#!/usr/bin/env bash

# Many variables are sourced from build.conf and passed as environment variables to Packer.
# The vm_default_user name will be used by Packer and Ansible.
# (j2 is a better solution than 'envsubst' which messes up '$' in the text unless you specify each variable)
# vm_default_user
# vm_memory
# proxmox_host
# iso_filename
# vm_ver
# vm_id
# proxmox_password
# ssh_password

set -o allexport
build_conf="build.conf"

function help {
    printf "\n"
    echo "$0 (proxmox|debug [VM_ID])"
    echo
    echo "proxmox   - Build and create a Proxmox VM template"
    echo "debug     - Debug Mode: Build and create a Proxmox VM template"
    echo
    echo "VM_ID     - VM ID for new VM template (overrides default from build.conf)"
    echo
    echo "Enter Passwwords when prompted or provide them via ENV variables:"
    echo "(use a space in front of ' export' to keep passwords out of bash_history)"
    echo " export proxmox_password=MyLoginPassword"
    echo " export ssh_password=MyPasswordInVM"
    printf "\n"
    exit 0
}

function die_var_unset {
    echo "ERROR: Variable '$1' is required to be set. Please edit '${build_conf}' and set."
    exit 1
}

## check that data in build_conf is complete
[[ -f $build_conf ]] || { echo "User variables file '$build_conf' not found."; exit 1; }
source $build_conf

[[ -z "$vm_default_user" ]] && die_var_unset "vm_default_user"
[[ -z "$vm_memory" ]] && die_var_unset "vm_memory"
[[ -z "$proxmox_host" ]] && die_var_unset "proxmox_host"
[[ -z "$default_vm_id" ]] && die_var_unset "default_vm_id"
[[ -z "$iso_url" ]] && die_var_unset "iso_url"
[[ -z "$iso_sha256_url" ]] && die_var_unset "iso_sha256_url"
[[ -z "$iso_directory" ]] && die_var_unset "iso_directory"

## check that build-mode (proxmox|debug) is passed to script
target=${1:-}
[[ "${1}" == "proxmox" ]] || [[ "${1}" == "debug" ]] || help

## VM ID for new VM template (overrides default from build.conf)
vm_id=${2:-$default_vm_id}
printf "\n==> Using VM ID: $vm_id with default user: '$vm_default_user'\n"

## template_name is based on name of current directory, check it exists
template_name="${PWD##*/}.json"

[[ -f $template_name ]] || { echo "Template (${template_name}) not found."; exit 1; }

## check that prerequisites are installed
[[ $(packer --version)  ]] || { echo "Please install 'Packer'"; exit 1; }
[[ $(ansible --version)  ]] || { echo "Please install 'Ansible'"; exit 1; }
[[ $(j2 --version)  ]] || { echo "Please install 'j2cli'"; exit 1; }

## If passwords are not set in env variable, prompt for them
[[ -z "$proxmox_password" ]] && printf "\n" && read -s -p "Existing PROXMOX Login Password: " proxmox_password && printf "\n"
printf "\n"

if [[ -z "$ssh_password" ]]; then
    while true; do
        read -s -p "Enter  new SSH Password: " ssh_password
        printf "\n"
        read -s -p "Repeat new SSH Password: " ssh_password2
        printf "\n"
        [ "$ssh_password" = "$ssh_password2" ] && break
        printf "Passwords do not match. Please try again!\n\n"
    done
fi

[[ -z "$proxmox_password" ]] && echo "The Proxmox Password is required." && exit 1
[[ -z "$ssh_password" ]] && echo "The SSH Password is required." && exit 1

## download ISO and Ansible role
printf "\n=> Downloading and checking ISO\n\n"
iso_filename=$(basename $iso_url)
wget -P $iso_directory -N $iso_url                  # only re-download when newer on the server
wget --no-verbose $iso_sha256_url -O $iso_directory/SHA256SUMS  # always download and overwrite
(cd $iso_directory && cat $iso_directory/SHA256SUMS | grep $iso_filename | sha256sum --check)
if [ $? -eq 1 ]; then echo "ISO checksum does not match!"; exit 1; fi

printf "\n=> Downloading Ansible role\n\n"
# will always overwrite role to get latest version from Github
ansible-galaxy install --force -p playbook/roles -r playbook/requirements.yml
[[ -f playbook/roles/ansible-initial-server/tasks/main.yml ]] || { echo "Ansible role not found."; exit 1; }

mkdir -p http

# Debian & Ubuntu
## Insert the password hashes for root and default user into preseed.cfg using a Jinja2 template
if [[ -f preseed.cfg.j2 ]]; then
    password_hash1=$(mkpasswd -R 1000000 -m sha-512 $ssh_password)
    password_hash2=$(mkpasswd -R 1000000 -m sha-512 $ssh_password)
    printf "\n=> Customizing auto preseed.cfg\n"
    j2 preseed.cfg.j2 > http/preseed.cfg
    [[ -f http/preseed.cfg ]] || { echo "Customized preseed.cfg file not found."; exit 1; }
fi

# OpenBSD
## Insert the password hashes for root and default user into install.conf using a Jinja2 template
if [[ -f install.conf.j2 ]]; then
    password_hash1=$(python3 -c "import os, bcrypt; print(bcrypt.hashpw(os.environ['ssh_password'], bcrypt.gensalt(10)))")
    password_hash2=$(python3 -c "import os, bcrypt; print(bcrypt.hashpw(os.environ['ssh_password'], bcrypt.gensalt(10)))")
    printf "\n=> Customizing install.conf\n"
    j2 install.conf.j2 > http/install.conf
    [[ -f http/install.conf ]] || { echo "Customized install.conf file not found."; exit 1; }
fi

vm_ver=$(git describe --tags)


## Call Packer build with the provided data
case $target in
    proxmox)
        printf "\n==> Build and create a Proxmox template.\n\n"
        ansible_verbosity="-v"
        packer build $template_name
        ;;
    debug)
        printf "\n==> DEBUG: Build and create a Proxmox template.\n\n"
        ansible_verbosity="-vvvv"
        PACKER_LOG=1 packer build -debug -on-error=ask $template_name
        ;;
    *)
        help
        ;;
esac

## remove file which has the hashed passwords
[[ -f http/preseed.cfg ]] && printf "=> " && rm -v http/preseed.cfg
[[ -f http/install.conf ]] && printf "=> " && rm -v http/install.conf


================================================
FILE: check-functionality.md
================================================
# Check the functionality of features

###

### Check that services are enabled

```
# Debian/Ubuntu
systemctl list-unit-files | grep -E 'autogrowpart|ssh-host-keygen'

systemctl status ssh-host-keygen
systemctl status autogrowpart
pstree

# Alpine
rc-status | grep 'local '
pstree

# OpenBSD
rcctl ls on
rcctl ls started
pstree
```


### Check that autogrow partition works (all OS)

- check disk space
```
df -h
poweroff
```

- increase disk size in Proxmox and check disk space again
```
df-h
```

### Check ssh-host-keygen and fingerprint & IP display

- create two clones in Proxmox
- check fingerprints and IP before login on console


###
- check ssh login

`ssh -p 3XX22 christian@proxmox.lightinasia.site`

### Ansible Playbook

- run the playbook again separately on a clone

### Default VM Numbers
- 10000 Debian 8
- 11000 Debian 9
- 12000 Debian 10
- 20000 Ubuntu 18.04
- 21000 Ubuntu 20.04
- 22000 Ubuntu 22.04
- 31000 Centos 7
- 40000 Alpine 3.11
- 42000 Arch
- 44000 RancherOS 1.5.5
- 46000 CoreOS/Flatcar
- 47000 OpenBSD

### Default [Cloud VM](https://gist.github.com/chriswayg/43fbea910e024cbe608d7dcb12cb8466) Numbers
- 51000 Debian 8
- 51100 Debian 9
- 51200 Debian 10
- 52000 Ubuntu 18.04
- 52100 Ubuntu 20.04
- 52200 Ubuntu 22.04
- 53100 Centos 7
- 54000 Alpine 3.11
- 54200 Arch
- 54400 RancherOS 1.5.5
- 54600 CoreOS/Flatcar


================================================
FILE: debian-10-amd64-proxmox/README.md
================================================
## [Debian ](http://debian.org) v10.0 (buster) Packer Template using [Packer Proxmox Builder](https://www.packer.io/docs/builders/proxmox.html) to build a Proxmox KVM image template

Status: **working well**

- downloads the ISO and places it in Proxmox
- creates a Proxmox VM
- builds the image using preseed.cfg and Ansible
- stores it as a Proxmox Template

### Configurations
- qemu-guest-agent for Packer SSH and in Proxmox for shutdown and backups
- haveged random number generator to speed up boot
- passwordless sudo for default user 'deploy' (name can be changed in build.conf)
- SSH public key installed for default user
- display IP and SSH fingerprint before console login
- generates new SSH host keys on first boot to avoid duplicates in cloned VMs
- automatically grow partition after resize by Proxmox

### Instructions

- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)


================================================
FILE: debian-10-amd64-proxmox/build.conf
================================================
vm_default_user=christian
vm_memory=1024
default_vm_id=12000 # default VM ID for Debian
proxmox_url=https://proxmox.lightinasia.site:8006/api2/json
proxmox_host=proxmox

# latest version: http://cdimage.debian.org/cdimage/release/current/amd64/iso-cd/
iso_url=http://cdimage.debian.org/cdimage/release/current/amd64/iso-cd/debian-10.4.0-amd64-netinst.iso
iso_sha256_url=https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA256SUMS
iso_directory=/var/lib/vz/template/iso


================================================
FILE: debian-10-amd64-proxmox/debian-10-amd64-proxmox.json
================================================
{
    "description": "Build Debian 10 (buster) x86_64 Proxmox template",
    "variables": {
        "proxmox_url": "{{env `proxmox_url`}}",
        "proxmox_username": "root@pam",
        "proxmox_password": "{{env `proxmox_password`}}",
        "proxmox_host": "{{env `proxmox_host`}}",
        "iso_filename": "{{env `iso_filename`}}",
        "vm_id": "{{env `vm_id`}}",
        "vm_name": "deb10-tmpl",
        "template_description": "Debian 10 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}",
        "vm_default_user": "{{env `vm_default_user`}}",
        "vm_memory": "{{env `vm_memory`}}",
        "ssh_username": "root",
        "ssh_password": "{{env `ssh_password`}}"
    },
    "sensitive-variables": ["proxmox_password", "ssh_password" ],
    "provisioners": [
      {
        "type": "ansible",
        "playbook_file": "./playbook/server-template.yml",
        "extra_arguments": [
          "{{user `ansible_verbosity`}}",
          "--extra-vars", "vm_default_user={{user `vm_default_user`}}",
          "--tags", "all,is_template",
          "--skip-tags", "openbsd,alpine"
        ],
        "ansible_env_vars": [ "ANSIBLE_CONFIG=./playbook/ansible.cfg", "ANSIBLE_FORCE_COLOR=True" ]
      }
    ],
    "builders": [
        {
            "type": "proxmox",
            "proxmox_url":  "{{user `proxmox_url`}}",
            "insecure_skip_tls_verify": true,
            "username": "{{user `proxmox_username`}}",
            "password": "{{user `proxmox_password`}}",
            "vm_id":  "{{user `vm_id`}}",
            "vm_name": "{{user `vm_name`}}",
            "template_description":"{{user `template_description`}}",
            "memory": "{{user `vm_memory`}}",
            "cores": "2",
            "os": "l26",
            "http_directory": "http",
            "node": "{{user `proxmox_host`}}",
            "network_adapters": [
              {
                "model": "virtio",
                "bridge": "vmbr1"
              }
            ],
            "disks": [
              {
                "type": "scsi",
                "disk_size": "8G",
                "storage_pool": "local",
                "storage_pool_type": "directory",
                "format": "qcow2"
              }
            ],
            "ssh_username": "{{user `ssh_username`}}",
            "ssh_password": "{{user `ssh_password`}}",
            "ssh_timeout": "15m",
            "iso_file": "local:iso/{{user `iso_filename`}}",
            "unmount_iso": true,
            "boot_wait": "10s",
            "boot_command": [
              "<esc><wait>",
              "auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<enter>"
            ]
        }
    ],
    "post-processors": [
      {
        "type": "shell-local",
        "inline_shebang": "/bin/bash -e",
        "inline": ["qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0"]
      }
  ]
}


================================================
FILE: debian-10-amd64-proxmox/playbook/ansible.cfg
================================================
[defaults]
deprecation_warnings = False
host_key_checking = False
callback_whitelist = timer, profile_roles
stdout_callback = yaml
roles_path = ./roles
log_path = ./logs/server-template.log


================================================
FILE: debian-10-amd64-proxmox/playbook/requirements.yml
================================================
- src: https://github.com/chriswayg/ansible-initial-server.git
  #version: v1.7


================================================
FILE: debian-10-amd64-proxmox/playbook/server-template-vars.yml
================================================
---

iserver_hostname: deb10-kvm
iserver_sshkey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local"

iserver_debian_repos:
  - deb http://repo.myloc.de/debian buster main non-free contrib
  - deb-src http://repo.myloc.de/debian buster main non-free contrib
  - deb http://security.debian.org/debian-security buster/updates main contrib non-free
  - deb-src http://security.debian.org/debian-security buster/updates main contrib non-free
  - deb http://deb.debian.org/debian buster-updates main contrib non-free
  - deb-src http://deb.debian.org/debian buster-updates main contrib non-free


================================================
FILE: debian-10-amd64-proxmox/playbook/server-template.yml
================================================
---
# Any remote_user defined in tasks will be ignored.
# Packer will always connect with the user given in the json config for this provisioner.
# https://www.packer.io/docs/provisioners/ansible.html

# TODO: For unclear reasons, I could only get it to work with the root user in Packer
# 'become' in playbook or role tasks seem to be ignored by Packer Ansible

- name: Initial configuration of a server.
  hosts: all
  vars_files:
    - server-template-vars.yml
  roles:
    - role: ansible-initial-server
      vars:
        iserver_user: "{{ vm_default_user }}"


================================================
FILE: debian-10-amd64-proxmox/preseed.cfg.j2
================================================
#### Preseed template-file for Debian 10 buster
# Docs: - https://www.debian.org/releases/stable/amd64/apb.en.html
#       - https://www.debian.org/releases/buster/example-preseed.txt
#       - Notes: Debian 10 auto-install from ISO using preseed.cfg

### Localization
# Locale sets language and country.
d-i debian-installer/locale string en_US.utf8
# Keyboard selection.
d-i keyboard-configuration/xkb-keymap select us

### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string

### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# see ls -R  /usr/share/zoneinfo/ for valid values.
d-i time/zone string UTC

### Partitioning
# This creates an unencrypted primary ext4 partition without swap.
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select unencrypted-install
d-i partman-basicfilesystems/no_swap boolean false
d-i partman-auto/expert_recipe string \
        root :: \
                8190 100000 -1 ext4 \
                        $primary{ } $bootable{ } \
                        method{ format } format{ } \
                        use_filesystem{ } filesystem{ ext4 } \
                        mountpoint{ / } \
                .
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

### Account setup
# Default user '{{ env("vm_default_user") }}'
d-i passwd/root-login boolean true
d-i passwd/user-fullname string {{ env("vm_default_user") }}
d-i passwd/username string {{ env("vm_default_user") }}
d-i user-setup/encrypt-home boolean false
# Encrypted root and user passwords
d-i passwd/root-password-crypted password {{ env("password_hash1") }}
d-i passwd/user-password-crypted password {{ env("password_hash2") }}

### Apt setup
# prevent the installer from asking about scanning another CD
apt-cdrom-setup apt-setup/cdrom/set-first boolean false

### Package selection
tasksel tasksel/first multiselect ssh-server, standard system utilities
# Full upgrade packages after debootstrap and unattended upgrades
d-i pkgsel/upgrade select full-upgrade
d-i pkgsel/update-policy select unattended-upgrades
# Individual additional packages to install
# - qemu-guest-agent for Packer and Proxmox; haveged random generator speeds up boot
d-i pkgsel/include string openssh-server sudo qemu-guest-agent haveged python-apt
d-i pkgsel/install-language-support boolean false
# Do not report back on what software is installed, and what software is used
popularity-contest popularity-contest/participate boolean false

### Boot loader installation
d-i grub-installer/bootdev string /dev/sda

### Run custom commands during the installation
d-i preseed/late_command string sed -i '/^deb cdrom:/s/^/#/' /target/etc/apt/sources.list
# Enable passwordless sudo for default user and permit root login for Packer Ansible provisioner to work
d-i preseed/late_command string \
    echo '{{ env("vm_default_user") }}  ALL=(ALL:ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/default-user && chmod 440 /target/etc/sudoers.d/default-user && \
    sed -i "/^#PermitRootLogin/c\PermitRootLogin yes" /target/etc/ssh/sshd_config

### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note


================================================
FILE: openbsd-6-amd64-proxmox/README.md
================================================
## OpenBSD 6.6 Packer Template using [Packer Proxmox Builder](https://www.packer.io/docs/builders/proxmox.html) to build a Proxmox KVM image template

Status: **working well**

- downloads the ISO and places it in Proxmox
- creates a Proxmox VM
- builds the image using install.conf and Ansible
- stores it as a Proxmox Template

### Configurations
- there is no qemu guest agent for Packer SSH, therefore we use a static local IP during installation via Packer
- passwordless doas for default user 'deploy' (name can be changed in build.conf)
- SSH public key installed for default user
- display IP and SSH fingerprint before console login (not yet implemented)
- generates new SSH host keys on first boot to avoid duplicates in cloned VMs
- OpenBSD has no cloud utils with growpart to automatically grow partition after resize by Proxmox

### Instructions

- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)


================================================
FILE: openbsd-6-amd64-proxmox/build.conf
================================================
vm_default_user=christian
vm_memory=1024
default_vm_id=47000 # default VM ID for OpenBSD
proxmox_url=https://proxmox.lightinasia.site:8006/api2/json
proxmox_host=proxmox

iso_url=https://cloudflare.cdn.openbsd.org/pub/OpenBSD/6.6/amd64/install66.iso
iso_sha256_url=https://cloudflare.cdn.openbsd.org/pub/OpenBSD/6.6/amd64/SHA256
iso_directory=/var/lib/vz/template/iso


================================================
FILE: openbsd-6-amd64-proxmox/install.conf.j2
================================================
System hostname = openbsd
IPv4 address for vio0 = 10.10.10.252
Default IPv4 route = 10.10.10.1
DNS nameservers = 1.1.1.1 1.0.0.1
Password for root account = {{ env("password_hash1") }}
Do you expect to run the X Window System = no
Setup a user = {{ env("vm_default_user") }}
Password for user {{ env("vm_default_user") }} = {{ env("password_hash2") }}
Allow root ssh login = yes
# Set name(s) = -comp* -game* -x*
Directory does not contain SHA256.sig. Continue without verification = yes


================================================
FILE: openbsd-6-amd64-proxmox/install.conf.j2.test
================================================
System hostname = openbsd
IPv4 address for vio0 = 10.10.10.252
Default IPv4 route = 10.10.10.1
 DNS nameservers = 1.1.1.1 1.0.0.1
Password for root account = {{ env("password_hash1") }}
Do you expect to run the X Window System = no
Setup a user = christian
Password for user christian = {{ env("password_hash2") }}
Allow root ssh login = yes
Set name(s) = -comp* -game* -x*
Directory does not contain SHA256.sig. Continue without verification = yes

# use a static IP for SSH from packer, then switch back to dhcp for template

System hostname = openbsd
Which network interface do you wish to configure = vio0
IPv4 address for vio0 = dhcp
IPv6 address for vio0 = none
Which network interface do you wish to configure = done
Public ssh key for root account = none
Start sshd(8) by default = yes
Do you expect to run the X Window System = no
Setup a user = no
Allow root ssh login = yes
What timezone are you in = Asia/Manila
Which disk is the root disk = sd0
Use (W)hole disk MBR, whole disk (G)PT or (E)dit = whole
URL to autopartitioning template for disklabel = none
Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout = a
Location of sets = cd0
Pathname to the sets = 6.5/amd64
Set name(s) = -comp* -game* -x*
Set name(s) = done
Directory does not contain SHA256.sig. Continue without verification = yes
Location of sets = done


================================================
FILE: openbsd-6-amd64-proxmox/openbsd-6-amd64-proxmox.json
================================================
{
    "description": "Build OpenBSD 6 x86_64 Proxmox template",
    "variables": {
        "proxmox_url": "{{env `proxmox_url`}}",
        "proxmox_username": "root@pam",
        "proxmox_password": "{{env `proxmox_password`}}",
        "proxmox_host": "{{env `proxmox_host`}}",
        "iso_filename": "{{env `iso_filename`}}",
        "vm_id": "{{env `vm_id`}}",
        "vm_name": "openbsd6-tmpl",
        "template_description": "OpenBSD 6 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}",
        "vm_default_user": "{{env `vm_default_user`}}",
        "vm_memory": "{{env `vm_memory`}}",
        "ssh_username": "root",
        "ssh_password": "{{env `ssh_password`}}",
        "ansible_verbosity":"{{env `ansible_verbosity`}}"
    },
    "sensitive-variables": ["proxmox_password", "ssh_password" ],
    "provisioners": [
      {
        "type": "ansible",
        "playbook_file": "./playbook/server-template.yml",
        "extra_arguments": [
          "{{user `ansible_verbosity`}}",
          "--extra-vars", "vm_default_user={{user `vm_default_user`}}",
          "--tags", "all,is_template",
          "--skip-tags", "debuntu,alpine"
        ],
        "ansible_env_vars": [ "ANSIBLE_CONFIG=./playbook/ansible.cfg", "ANSIBLE_FORCE_COLOR=True" ]
      }
    ],
    "builders": [
        {
            "type": "proxmox",
            "proxmox_url":  "{{user `proxmox_url`}}",
            "insecure_skip_tls_verify": true,
            "username": "{{user `proxmox_username`}}",
            "password": "{{user `proxmox_password`}}",
            "vm_id":  "{{user `vm_id`}}",
            "vm_name": "{{user `vm_name`}}",
            "template_description":"{{user `template_description`}}",
            "memory": "{{user `vm_memory`}}",
            "cores": "2",
            "os": "other",
            "http_directory": "http",

            "node": "{{user `proxmox_host`}}",
            "network_adapters": [
              {
                "model": "virtio",
                "bridge": "vmbr1"
              }
            ],
            "disks": [
              {
                "type": "scsi",
                "disk_size": "8G",
                "storage_pool": "local",
                "storage_pool_type": "directory",
                "format": "qcow2"
              }
            ],
            "ssh_username": "{{user `ssh_username`}}",
            "ssh_password": "{{user `ssh_password`}}",
            "ssh_timeout": "15m",
            "ssh_host": "10.10.10.252",
            "qemu_agent": false,
            "iso_file": "local:iso/{{user `iso_filename`}}",
            "unmount_iso": true,
            "boot_wait": "30s",
            "boot_command": [
              "a<enter><wait>",
              "<wait5>",
              "http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.conf<enter><wait>",
              "<wait5>",
              "i<enter><wait>"
            ]
        }
    ],
    "post-processors": [
      {
        "type": "shell-local",
        "inline_shebang": "/bin/bash -e",
        "inline": ["qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0"]
      }
  ]
}


================================================
FILE: openbsd-6-amd64-proxmox/playbook/ansible.cfg
================================================
[defaults]
deprecation_warnings = False
host_key_checking = False
callback_whitelist = timer, profile_roles
stdout_callback = yaml
roles_path = ./roles
log_path = ./logs/server-template.log
inventory = ./hosts


================================================
FILE: openbsd-6-amd64-proxmox/playbook/hosts
================================================
[servers]

OpenBSD ansible_host=10.10.10.252 ansible_port=22


================================================
FILE: openbsd-6-amd64-proxmox/playbook/requirements.yml
================================================
- src: https://github.com/chriswayg/ansible-initial-server.git
  #version: v1.7


================================================
FILE: openbsd-6-amd64-proxmox/playbook/server-template-vars.yml
================================================
---

iserver_hostname: openbsd6
iserver_sshkey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local"


================================================
FILE: openbsd-6-amd64-proxmox/playbook/server-template.yml
================================================
---
# Any remote_user defined in tasks will be ignored.
# Packer will always connect with the user given in the json config for this provisioner.
# https://www.packer.io/docs/provisioners/ansible.html

# TODO: For unclear reasons, I could only get it to work with the root user in Packer
# 'become' in playbook or role tasks seem to be ignored by Packer Ansible

- name: Prepare OpenBSD for Ansible.
  hosts: all
  gather_facts: False
  tasks:
    - name: Ensure, that python is installed.
      raw: pkg_add -z python-2.7

    - name: Ensure that python 2 is linked to /usr/bin/python.
      raw: ln -sf /usr/local/bin/python2.7 /usr/bin/python

- name: Initial configuration of a server.
  hosts: all
  vars_files:
    - server-template-vars.yml
  roles:
    - role: ansible-initial-server
      vars:
        iserver_user: "{{ vm_default_user }}"
        iserver_become: su


================================================
FILE: ubuntu-18.04-amd64-proxmox/README.md
================================================
## [Ubuntu ](http://releases.ubuntu.com/18.04/) 18.04 (bionic) Packer Template using [Packer Proxmox Builder](https://www.packer.io/docs/builders/proxmox.html) to build a Proxmox KVM image template

Status: **working well** 

- downloads the ISO and places it in Proxmox
- creates a Proxmox VM
- builds the image using preseed.cfg and Ansible
- stores it as a Proxmox Template

### Configurations
- qemu-guest-agent for Packer SSH and in Proxmox for shutdown and backups
- haveged random number generator to speed up boot
- passwordless sudo for default user 'deploy' (name can be changed in build.conf)
- SSH public key installed for default user
- display IP and SSH fingerprint before console login
- generates new SSH host keys on first boot to avoid duplicates in cloned VMs
- automatically grow partition after resize by Proxmox

### Instructions

- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)


================================================
FILE: ubuntu-18.04-amd64-proxmox/build.conf
================================================
vm_default_user=christian
vm_memory=1024
default_vm_id=20000 # default VM ID for Ubuntu
proxmox_url=https://proxmox.lightinasia.site:8006/api2/json
proxmox_host=proxmox

iso_url=http://cdimage.ubuntu.com/releases/18.04.4/release/ubuntu-18.04.4-server-amd64.iso
iso_sha256_url=http://cdimage.ubuntu.com/releases/18.04.4/release/SHA256SUMS
iso_directory=/var/lib/vz/template/iso


================================================
FILE: ubuntu-18.04-amd64-proxmox/playbook/ansible.cfg
================================================
[defaults]
deprecation_warnings = False
host_key_checking = False
callback_whitelist = timer, profile_roles
stdout_callback = yaml
roles_path = ./roles
log_path = ./logs/server-template.log

[ssh_connection]
pipelining = True


================================================
FILE: ubuntu-18.04-amd64-proxmox/playbook/requirements.yml
================================================
- src: https://github.com/chriswayg/ansible-initial-server.git
  #version: v1.7


================================================
FILE: ubuntu-18.04-amd64-proxmox/playbook/server-template-vars.yml
================================================
---

iserver_hostname: ubuntu1804-kvm
iserver_sshkey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local"

iserver_ubuntu_repos:
  - deb http://repo.myloc.de/ubuntu/ bionic main restricted universe multiverse
  - deb-src http://repo.myloc.de/ubuntu/ bionic main restricted universe multiverse
  - deb http://repo.myloc.de/ubuntu/ bionic-updates main restricted universe multiverse
  - deb-src http://repo.myloc.de/ubuntu/ bionic-updates main restricted universe multiverse
  - deb http://repo.myloc.de/ubuntu/ bionic-backports main restricted universe multiverse
  - deb-src http://repo.myloc.de/ubuntu/ bionic-backports main restricted universe multiverse
  - deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
  - deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse


================================================
FILE: ubuntu-18.04-amd64-proxmox/playbook/server-template.yml
================================================
---
# Any remote_user defined in tasks will be ignored.
# Packer will always connect with the user given in the json config for this provisioner.
# https://www.packer.io/docs/provisioners/ansible.html

# TODO: For unclear reasons, I could only get it to work with the root user in Packer.
# 'become' in playbook or role tasks seems to be ignored by Packer Ansible

- name: Initial configuration of a server.
  hosts: all
  vars_files:
    - server-template-vars.yml
  roles:
    - role: ansible-initial-server
      vars:
        iserver_user: "{{ vm_default_user }}"


================================================
FILE: ubuntu-18.04-amd64-proxmox/preseed.cfg.j2
================================================
#### Preseed file for Ubuntu 18.04 bionic
# Docs: - https://help.ubuntu.com/lts/installation-guide/amd64/apbs01.html
#       - https://help.ubuntu.com/18.04/installation-guide/example-preseed.txt

### Localization
# Locale sets language and country.
d-i debian-installer/locale string en_US.utf8
# Keyboard selection.
d-i keyboard-configuration/xkb-keymap select us

### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string

### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# see ls -R  /usr/share/zoneinfo/ for valid values.
d-i time/zone string UTC

### Partitioning
# This creates an unencrypted primary ext4 partition without swap.
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select unencrypted-install
d-i partman-basicfilesystems/no_swap boolean false
d-i partman-auto/expert_recipe string \
        root :: \
                8190 100000 -1 ext4 \
                        $primary{ } $bootable{ } \
                        method{ format } format{ } \
                        use_filesystem{ } filesystem{ ext4 } \
                        mountpoint{ / } \
                .
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

### Account setup
# Default user '{{ env("vm_default_user") }}'
d-i passwd/root-login boolean true
d-i passwd/user-fullname string {{ env("vm_default_user") }}
d-i passwd/username string {{ env("vm_default_user") }}
d-i user-setup/encrypt-home boolean false
# Encrypted root and user passwords
d-i passwd/root-password-crypted password {{ env("password_hash1") }}
d-i passwd/user-password-crypted password {{ env("password_hash2") }}

### Package selection
tasksel tasksel/first multiselect standard, server
# Full upgrade packages after debootstrap and unattended upgrades
d-i pkgsel/upgrade select full-upgrade
d-i pkgsel/update-policy select unattended-upgrades
# Individual additional packages to install
# - qemu-guest-agent needed for packer; better random generator speeds up boot
d-i pkgsel/include string openssh-server sudo qemu-guest-agent haveged python-apt
d-i pkgsel/install-language-support boolean false
# Do not report back on what software is installed, and what software is used
popularity-contest popularity-contest/participate boolean false

### Boot loader installation
d-i grub-installer/bootdev string /dev/sda

### Run custom commands during the installation
# Enable passwordless sudo for default user and permit root login for Packer Ansible provisioner to work
d-i preseed/late_command string \
    echo '{{ env("vm_default_user") }}  ALL=(ALL:ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/default-user && chmod 440 /target/etc/sudoers.d/default-user && \
    sed -i "/^#PermitRootLogin/c\PermitRootLogin yes" /target/etc/ssh/sshd_config

### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note


================================================
FILE: ubuntu-18.04-amd64-proxmox/ubuntu-18.04-amd64-proxmox.json
================================================
{
    "description": "Build Ubuntu 18.04 (bionic) x86_64 Proxmox template",
    "variables": {
        "proxmox_url": "{{env `proxmox_url`}}",
        "proxmox_username": "root@pam",
        "proxmox_password": "{{env `proxmox_password`}}",
        "proxmox_host": "{{env `proxmox_host`}}",
        "iso_filename": "{{env `iso_filename`}}",
        "vm_id": "{{env `vm_id`}}",
        "vm_name": "ubuntu1804-tmpl",
        "template_description": "Ubuntu 18.04 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}",
        "vm_default_user": "{{env `vm_default_user`}}",
        "vm_memory": "{{env `vm_memory`}}",
        "ssh_username": "root",
        "ssh_password": "{{env `ssh_password`}}"
    },
    "sensitive-variables": ["proxmox_password", "ssh_password" ],
    "provisioners": [
      {
        "type": "ansible",
        "playbook_file": "./playbook/server-template.yml",
        "extra_arguments": [
          "{{user `ansible_verbosity`}}",
          "--extra-vars", "vm_default_user={{user `vm_default_user`}}",
          "--tags", "all,is_template",
          "--skip-tags", "openbsd,alpine"
        ],
        "ansible_env_vars": [ "ANSIBLE_CONFIG=./playbook/ansible.cfg", "ANSIBLE_FORCE_COLOR=True" ]
      }
    ],
    "builders": [
        {
            "type": "proxmox",
            "proxmox_url":  "{{user `proxmox_url`}}",
            "insecure_skip_tls_verify": true,
            "username": "{{user `proxmox_username`}}",
            "password": "{{user `proxmox_password`}}",
            "vm_id":  "{{user `vm_id`}}",
            "vm_name": "{{user `vm_name`}}",
            "template_description":"{{user `template_description`}}",
            "memory": "{{user `vm_memory`}}",
            "cores": "2",
            "os": "l26",
            "http_directory": "http",

            "node": "{{user `proxmox_host`}}",
            "network_adapters": [
              {
                "model": "virtio",
                "bridge": "vmbr1"
              }
            ],
            "disks": [
              {
                "type": "scsi",
                "disk_size": "8G",
                "storage_pool": "local",
                "storage_pool_type": "directory",
                "format": "qcow2"
              }
            ],
            "ssh_username": "{{user `ssh_username`}}",
            "ssh_password": "{{user `ssh_password`}}",
            "ssh_timeout": "15m",
            "iso_file": "local:iso/{{user `iso_filename`}}",
            "unmount_iso": true,
            "boot_wait": "10s",
            "boot_command": [
              "<esc><wait>",
              "<esc><wait>",
              "<enter><wait>",
              "/install/vmlinuz initrd=/install/initrd.gz",
              " auto=true priority=critical",
              " url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
              "<enter>"
            ]
        }
    ],
    "post-processors": [
      {
        "type": "shell-local",
        "inline_shebang": "/bin/bash -e",
        "inline": ["qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0"]
      }
  ]
}


================================================
FILE: ubuntu-20.04-amd64-proxmox/README.md
================================================
## [Ubuntu ](http://releases.ubuntu.com/20.04/) 20.04 (focal) Packer Template using [Packer Proxmox Builder](https://www.packer.io/docs/builders/proxmox.html) to build a Proxmox KVM image template

Status: **working well** 

- downloads the ISO and places it in Proxmox
- creates a Proxmox VM
- builds the image using preseed.cfg and Ansible
- stores it as a Proxmox Template

### Configurations
- qemu-guest-agent for Packer SSH and in Proxmox for shutdown and backups
- haveged random number generator to speed up boot
- passwordless sudo for default user 'deploy' (name can be changed in build.conf)
- SSH public key installed for default user
- display IP and SSH fingerprint before console login
- generates new SSH host keys on first boot to avoid duplicates in cloned VMs
- automatically grow partition after resize by Proxmox

### Instructions

- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)


================================================
FILE: ubuntu-20.04-amd64-proxmox/build.conf
================================================
vm_default_user=christian
vm_memory=1024
default_vm_id=21000 # default VM ID for Ubuntu
proxmox_url=https://proxmox.lightinasia.site:8006/api2/json
proxmox_host=proxmox

iso_url=http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/ubuntu-20.04-legacy-server-amd64.iso
iso_sha256_url=http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/SHA256SUMS
iso_directory=/var/lib/vz/template/iso


================================================
FILE: ubuntu-20.04-amd64-proxmox/playbook/ansible.cfg
================================================
[defaults]
deprecation_warnings = False
host_key_checking = False
callback_whitelist = timer, profile_roles
stdout_callback = yaml
roles_path = ./roles
log_path = ./logs/server-template.log

[ssh_connection]
pipelining = True


================================================
FILE: ubuntu-20.04-amd64-proxmox/playbook/requirements.yml
================================================
- src: https://github.com/chriswayg/ansible-initial-server.git
  #version: v1.7


================================================
FILE: ubuntu-20.04-amd64-proxmox/playbook/server-template-vars.yml
================================================
---

iserver_hostname: ubuntu2004-kvm
iserver_sshkey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local"

iserver_ubuntu_repos:
  - deb http://repo.myloc.de/ubuntu/ focal main restricted universe multiverse
  - deb-src http://repo.myloc.de/ubuntu/ focal main restricted universe multiverse
  - deb http://repo.myloc.de/ubuntu/ focal-updates main restricted universe multiverse
  - deb-src http://repo.myloc.de/ubuntu/ focal-updates main restricted universe multiverse
  - deb http://repo.myloc.de/ubuntu/ focal-backports main restricted universe multiverse
  - deb-src http://repo.myloc.de/ubuntu/ focal-backports main restricted universe multiverse
  - deb http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse
  - deb-src http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse


================================================
FILE: ubuntu-20.04-amd64-proxmox/playbook/server-template.yml
================================================
---
# Any remote_user defined in tasks will be ignored.
# Packer will always connect with the user given in the json config for this provisioner.
# https://www.packer.io/docs/provisioners/ansible.html

# TODO: For unclear reasons, I could only get it to work with the root user in Packer.
# 'become' in playbook or role tasks seems to be ignored by Packer Ansible

- name: Initial configuration of a server.
  hosts: all
  vars_files:
    - server-template-vars.yml
  roles:
    - role: ansible-initial-server
      vars:
        iserver_user: "{{ vm_default_user }}"


================================================
FILE: ubuntu-20.04-amd64-proxmox/preseed.cfg.j2
================================================
#### Preseed file for Ubuntu 20.04 focal
# Docs: - https://help.ubuntu.com/lts/installation-guide/amd64/apbs01.html
#       - https://help.ubuntu.com/20.04/installation-guide/example-preseed.txt

### Localization
# Locale sets language and country.
d-i debian-installer/locale string en_US.utf8
# Keyboard selection.
d-i keyboard-configuration/xkb-keymap select us

### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string

### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# see ls -R  /usr/share/zoneinfo/ for valid values.
d-i time/zone string UTC

### Partitioning
# This creates an unencrypted primary ext4 partition without swap.
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select unencrypted-install
d-i partman-basicfilesystems/no_swap boolean false
d-i partman-auto/expert_recipe string \
        root :: \
                8190 100000 -1 ext4 \
                        $primary{ } $bootable{ } \
                        method{ format } format{ } \
                        use_filesystem{ } filesystem{ ext4 } \
                        mountpoint{ / } \
                .
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

### Account setup
# Default user '{{ env("vm_default_user") }}'
d-i passwd/root-login boolean true
d-i passwd/user-fullname string {{ env("vm_default_user") }}
d-i passwd/username string {{ env("vm_default_user") }}
d-i user-setup/encrypt-home boolean false
# Encrypted root and user passwords
d-i passwd/root-password-crypted password {{ env("password_hash1") }}
d-i passwd/user-password-crypted password {{ env("password_hash2") }}

### Package selection
tasksel tasksel/first multiselect standard, server
# Full upgrade packages after debootstrap and unattended upgrades
d-i pkgsel/upgrade select full-upgrade
d-i pkgsel/update-policy select unattended-upgrades
# Individual additional packages to install
# - qemu-guest-agent needed for packer; better random generator speeds up boot
d-i pkgsel/include string openssh-server sudo qemu-guest-agent haveged python-apt
d-i pkgsel/install-language-support boolean false
# Do not report back on what software is installed, and what software is used
popularity-contest popularity-contest/participate boolean false

### Boot loader installation
d-i grub-installer/bootdev string /dev/sda

### Run custom commands during the installation
# Enable passwordless sudo for default user and permit root login for Packer Ansible provisioner to work
d-i preseed/late_command string \
    echo '{{ env("vm_default_user") }}  ALL=(ALL:ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/default-user && chmod 440 /target/etc/sudoers.d/default-user && \
    sed -i "/^#PermitRootLogin/c\PermitRootLogin yes" /target/etc/ssh/sshd_config

### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note


================================================
FILE: ubuntu-20.04-amd64-proxmox/ubuntu-20.04-amd64-proxmox.json
================================================
{
    "description": "Build Ubuntu 20.04 (focal) x86_64 Proxmox template",
    "variables": {
        "proxmox_url": "{{env `proxmox_url`}}",
        "proxmox_username": "root@pam",
        "proxmox_password": "{{env `proxmox_password`}}",
        "proxmox_host": "{{env `proxmox_host`}}",
        "iso_filename": "{{env `iso_filename`}}",
        "vm_id": "{{env `vm_id`}}",
        "vm_name": "ubuntu2004-tmpl",
        "template_description": "Ubuntu 20.04 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}",
        "vm_default_user": "{{env `vm_default_user`}}",
        "vm_memory": "{{env `vm_memory`}}",
        "ssh_username": "root",
        "ssh_password": "{{env `ssh_password`}}"
    },
    "sensitive-variables": ["proxmox_password", "ssh_password" ],
    "provisioners": [
      {
        "type": "ansible",
        "playbook_file": "./playbook/server-template.yml",
        "extra_arguments": [
          "{{user `ansible_verbosity`}}",
          "--extra-vars", "vm_default_user={{user `vm_default_user`}}",
          "--tags", "all,is_template",
          "--skip-tags", "openbsd,alpine"
        ],
        "ansible_env_vars": [ "ANSIBLE_CONFIG=./playbook/ansible.cfg", "ANSIBLE_FORCE_COLOR=True" ]
      }
    ],
    "builders": [
        {
            "type": "proxmox",
            "proxmox_url":  "{{user `proxmox_url`}}",
            "insecure_skip_tls_verify": true,
            "username": "{{user `proxmox_username`}}",
            "password": "{{user `proxmox_password`}}",
            "vm_id":  "{{user `vm_id`}}",
            "vm_name": "{{user `vm_name`}}",
            "template_description":"{{user `template_description`}}",
            "memory": "{{user `vm_memory`}}",
            "cores": "2",
            "os": "l26",
            "http_directory": "http",

            "node": "{{user `proxmox_host`}}",
            "network_adapters": [
              {
                "model": "virtio",
                "bridge": "vmbr1"
              }
            ],
            "disks": [
              {
                "type": "scsi",
                "disk_size": "8G",
                "storage_pool": "local",
                "storage_pool_type": "directory",
                "format": "qcow2"
              }
            ],
            "ssh_username": "{{user `ssh_username`}}",
            "ssh_password": "{{user `ssh_password`}}",
            "ssh_timeout": "15m",
            "iso_file": "local:iso/{{user `iso_filename`}}",
            "unmount_iso": true,
            "boot_wait": "10s",
            "boot_command": [
              "<esc><wait>",
              "<esc><wait>",
              "<enter><wait>",
              "/install/vmlinuz initrd=/install/initrd.gz",
              " auto=true priority=critical",
              " url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
              "<enter>"
            ]
        }
    ],
    "post-processors": [
      {
        "type": "shell-local",
        "inline_shebang": "/bin/bash -e",
        "inline": ["qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0"]
      }
  ]
}
Download .txt
gitextract__gjslv1q/

├── .gitignore
├── README.md
├── alpine-3-amd64-proxmox/
│   ├── LICENSE
│   ├── README.md
│   ├── alpine-3-amd64-proxmox.json
│   ├── build.conf
│   ├── http/
│   │   └── answers
│   ├── notes.md
│   └── playbook/
│       ├── ansible.cfg
│       ├── requirements.yml
│       ├── server-template-vars.yml
│       └── server-template.yml
├── alpine-3-amd64-qemu/
│   ├── LICENSE
│   ├── README.md
│   ├── alpine-3-amd64-qemu.json
│   ├── alpine_id_rsa
│   ├── alpine_id_rsa.ppk
│   ├── alpine_id_rsa.pub
│   ├── http/
│   │   └── answers
│   ├── meta-data
│   ├── notes-commands.md
│   ├── output/
│   │   ├── cloud-data.iso
│   │   └── qemu_4.2.0-1_amd64.deb
│   ├── scripts/
│   │   ├── 00base.sh
│   │   ├── 01alpine.sh
│   │   ├── 01networking.sh
│   │   ├── 02sshd.sh
│   │   ├── 04sudoers.sh
│   │   ├── 70random.sh
│   │   ├── 80cloudinit.sh
│   │   ├── 90showip.sh
│   │   └── 99minimize.sh
│   └── user-data
├── build.sh
├── check-functionality.md
├── debian-10-amd64-proxmox/
│   ├── README.md
│   ├── build.conf
│   ├── debian-10-amd64-proxmox.json
│   ├── playbook/
│   │   ├── ansible.cfg
│   │   ├── requirements.yml
│   │   ├── server-template-vars.yml
│   │   └── server-template.yml
│   └── preseed.cfg.j2
├── openbsd-6-amd64-proxmox/
│   ├── README.md
│   ├── build.conf
│   ├── install.conf.j2
│   ├── install.conf.j2.test
│   ├── openbsd-6-amd64-proxmox.json
│   └── playbook/
│       ├── ansible.cfg
│       ├── hosts
│       ├── requirements.yml
│       ├── server-template-vars.yml
│       └── server-template.yml
├── ubuntu-18.04-amd64-proxmox/
│   ├── README.md
│   ├── build.conf
│   ├── playbook/
│   │   ├── ansible.cfg
│   │   ├── requirements.yml
│   │   ├── server-template-vars.yml
│   │   └── server-template.yml
│   ├── preseed.cfg.j2
│   └── ubuntu-18.04-amd64-proxmox.json
└── ubuntu-20.04-amd64-proxmox/
    ├── README.md
    ├── build.conf
    ├── playbook/
    │   ├── ansible.cfg
    │   ├── requirements.yml
    │   ├── server-template-vars.yml
    │   └── server-template.yml
    ├── preseed.cfg.j2
    └── ubuntu-20.04-amd64-proxmox.json
Condensed preview — 69 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (105K chars).
[
  {
    "path": ".gitignore",
    "chars": 270,
    "preview": "*.img\n*.qcow2\n*.bz2\n*.zip\n*.bak\n*.bak2\n*.log\n*.log.*\n.DS_Store\n\n# ignore directories\ntest/\nroles/\ncrash_logs/\nlogs/\ndebu"
  },
  {
    "path": "README.md",
    "chars": 5557,
    "preview": "# packer-proxmox-templates\n:package: Packer templates for building Proxmox KVM images from ISO\n\n- use the latest tagged "
  },
  {
    "path": "alpine-3-amd64-proxmox/LICENSE",
    "chars": 11358,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "alpine-3-amd64-proxmox/README.md",
    "chars": 1051,
    "preview": "## [Alpine Linux](http://alpinelinux.org) Packer Template using [Packer Proxmox Builder](https://www.packer.io/docs/buil"
  },
  {
    "path": "alpine-3-amd64-proxmox/alpine-3-amd64-proxmox.json",
    "chars": 4439,
    "preview": "{\n    \"description\": \"Build Alpine Linux 3 x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{{env `p"
  },
  {
    "path": "alpine-3-amd64-proxmox/build.conf",
    "chars": 418,
    "preview": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=40000 # default VM ID for Alpine\nproxmox_url=https://proxmox.ligh"
  },
  {
    "path": "alpine-3-amd64-proxmox/http/answers",
    "chars": 407,
    "preview": "KEYMAPOPTS=\"us us\"\nHOSTNAMEOPTS=\"-n alpine3\"\nINTERFACESOPTS=\"auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet d"
  },
  {
    "path": "alpine-3-amd64-proxmox/notes.md",
    "chars": 787,
    "preview": "# scratchpad\n\n\n### Docker\n```\napk add docker-engine@edgecommunity docker-openrc@edgecommunity docker-cli@edgecommunity d"
  },
  {
    "path": "alpine-3-amd64-proxmox/playbook/ansible.cfg",
    "chars": 190,
    "preview": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callb"
  },
  {
    "path": "alpine-3-amd64-proxmox/playbook/requirements.yml",
    "chars": 80,
    "preview": "- src: https://github.com/chriswayg/ansible-initial-server.git\n  #version: v1.7\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/playbook/server-template-vars.yml",
    "chars": 781,
    "preview": "---\n\niserver_hostname: alpine3-kvm\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1d"
  },
  {
    "path": "alpine-3-amd64-proxmox/playbook/server-template.yml",
    "chars": 566,
    "preview": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json con"
  },
  {
    "path": "alpine-3-amd64-qemu/LICENSE",
    "chars": 11358,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "alpine-3-amd64-qemu/README.md",
    "chars": 3785,
    "preview": "## [Alpine Linux](http://alpinelinux.org) Packer Template using QEMU Builder to build a KVM cloud image usable in Proxmo"
  },
  {
    "path": "alpine-3-amd64-qemu/alpine-3-amd64-qemu.json",
    "chars": 2424,
    "preview": "{\n  \"description\": \"Build base Alpine Linux x86_64\",\n\n  \"variables\": {\n      \"disk_size\": \"2048\",\n      \"memory\": \"1024\""
  },
  {
    "path": "alpine-3-amd64-qemu/alpine_id_rsa",
    "chars": 1679,
    "preview": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEArvZdvBLBAsidAnJ3ZKtNb2pFigEzr+P9KArOVV5futoZFWpI\nHo74XJ1E7bith29MQpsovWu"
  },
  {
    "path": "alpine-3-amd64-qemu/alpine_id_rsa.ppk",
    "chars": 1438,
    "preview": "PuTTY-User-Key-File-2: ssh-rsa\nEncryption: none\nComment: imported-openssh-key\nPublic-Lines: 6\nAAAAB3NzaC1yc2EAAAADAQABAA"
  },
  {
    "path": "alpine-3-amd64-qemu/alpine_id_rsa.pub",
    "chars": 398,
    "preview": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu9l28EsECyJ0Ccndkq01vakWKATOv4/0oCs5VXl+62hkVakgejvhcnUTtuK2Hb0xCmyi9a5QaIGqgYoMg"
  },
  {
    "path": "alpine-3-amd64-qemu/http/answers",
    "chars": 363,
    "preview": "KEYMAPOPTS=\"us us\"\nHOSTNAMEOPTS=\"-n alpine3\"\nINTERFACESOPTS=\"auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet d"
  },
  {
    "path": "alpine-3-amd64-qemu/meta-data",
    "chars": 50,
    "preview": "instance-id: 12fb410a-6652-46e9-8b32-db6698678ddc\n"
  },
  {
    "path": "alpine-3-amd64-qemu/notes-commands.md",
    "chars": 138,
    "preview": "## Misc. Notes\n\n- Alpine boot kernel 'virt' with randomness from CPU & info during boot for testing\n```\nvirt random.trus"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/00base.sh",
    "chars": 129,
    "preview": "set -ux\n\napk upgrade -U --available\n\nsource /etc/os-release\n\nprintf \"\\n $PRETTY_NAME ($VERSION_ID) Cloud Server\\n\\n\" > /"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/01alpine.sh",
    "chars": 470,
    "preview": "set -ux\n\n# adding repositories needed for cloud-init\necho \"http://nl.alpinelinux.org/alpine/v3.11/community\" >> /etc/apk"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/01networking.sh",
    "chars": 43,
    "preview": "set -ux\n\n# nothing special required\n\nexit 0"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/02sshd.sh",
    "chars": 345,
    "preview": "set -eux\n\n# RootLogin without password was permitted in order to allow packer ssh access\n# to provision the system. Its "
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/04sudoers.sh",
    "chars": 726,
    "preview": "set -eux\n\n# this configuration allows the alpine account to sudo su - without needing a password\n\n# Install sudo\napk add"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/70random.sh",
    "chars": 166,
    "preview": "set -eux\n\n# Fixes: Boot delay/issues because of limited entropy\n# https://gitlab.alpinelinux.org/alpine/aports/issues/99"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/80cloudinit.sh",
    "chars": 1115,
    "preview": "set -eux\n\napk add cloud-init@testing\n\n# install missing dependencies\napk add eudev\n\n# needed for 'growpart'\napk add clou"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/90showip.sh",
    "chars": 657,
    "preview": "# show SSH key fingerprint and IP address on console\n\ncp /etc/issue /etc/issue-standard\n\n# Creates a script which will r"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/99minimize.sh",
    "chars": 213,
    "preview": "set -ux\n\ndd if=/dev/zero of=/EMPTY bs=1M\nrm -f /EMPTY\n# Block until the empty file has been removed, otherwise, Packer\n#"
  },
  {
    "path": "alpine-3-amd64-qemu/user-data",
    "chars": 522,
    "preview": "#cloud-config\nhostname: alpine3\nssh_authorized_keys:\n  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu9l28EsECyJ0Ccndkq01vakW"
  },
  {
    "path": "build.sh",
    "chars": 5682,
    "preview": "#!/usr/bin/env bash\n\n# Many variables are sourced from build.conf and passed as environment variables to Packer.\n# The v"
  },
  {
    "path": "check-functionality.md",
    "chars": 1349,
    "preview": "# Check the functionality of features\n\n###\n\n### Check that services are enabled\n\n```\n# Debian/Ubuntu\nsystemctl list-unit"
  },
  {
    "path": "debian-10-amd64-proxmox/README.md",
    "chars": 954,
    "preview": "## [Debian ](http://debian.org) v10.0 (buster) Packer Template using [Packer Proxmox Builder](https://www.packer.io/docs"
  },
  {
    "path": "debian-10-amd64-proxmox/build.conf",
    "chars": 478,
    "preview": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=12000 # default VM ID for Debian\nproxmox_url=https://proxmox.ligh"
  },
  {
    "path": "debian-10-amd64-proxmox/debian-10-amd64-proxmox.json",
    "chars": 2945,
    "preview": "{\n    \"description\": \"Build Debian 10 (buster) x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{{en"
  },
  {
    "path": "debian-10-amd64-proxmox/playbook/ansible.cfg",
    "chars": 190,
    "preview": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callb"
  },
  {
    "path": "debian-10-amd64-proxmox/playbook/requirements.yml",
    "chars": 80,
    "preview": "- src: https://github.com/chriswayg/ansible-initial-server.git\n  #version: v1.7\n"
  },
  {
    "path": "debian-10-amd64-proxmox/playbook/server-template-vars.yml",
    "chars": 951,
    "preview": "---\n\niserver_hostname: deb10-kvm\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBN"
  },
  {
    "path": "debian-10-amd64-proxmox/playbook/server-template.yml",
    "chars": 566,
    "preview": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json con"
  },
  {
    "path": "debian-10-amd64-proxmox/preseed.cfg.j2",
    "chars": 3528,
    "preview": "#### Preseed template-file for Debian 10 buster\n# Docs: - https://www.debian.org/releases/stable/amd64/apb.en.html\n#    "
  },
  {
    "path": "openbsd-6-amd64-proxmox/README.md",
    "chars": 977,
    "preview": "## OpenBSD 6.6 Packer Template using [Packer Proxmox Builder](https://www.packer.io/docs/builders/proxmox.html) to build"
  },
  {
    "path": "openbsd-6-amd64-proxmox/build.conf",
    "chars": 368,
    "preview": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=47000 # default VM ID for OpenBSD\nproxmox_url=https://proxmox.lig"
  },
  {
    "path": "openbsd-6-amd64-proxmox/install.conf.j2",
    "chars": 488,
    "preview": "System hostname = openbsd\nIPv4 address for vio0 = 10.10.10.252\nDefault IPv4 route = 10.10.10.1\nDNS nameservers = 1.1.1.1"
  },
  {
    "path": "openbsd-6-amd64-proxmox/install.conf.j2.test",
    "chars": 1344,
    "preview": "System hostname = openbsd\nIPv4 address for vio0 = 10.10.10.252\nDefault IPv4 route = 10.10.10.1\n DNS nameservers = 1.1.1."
  },
  {
    "path": "openbsd-6-amd64-proxmox/openbsd-6-amd64-proxmox.json",
    "chars": 3157,
    "preview": "{\n    \"description\": \"Build OpenBSD 6 x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{{env `proxmo"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/ansible.cfg",
    "chars": 210,
    "preview": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callb"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/hosts",
    "chars": 61,
    "preview": "[servers]\n\nOpenBSD ansible_host=10.10.10.252 ansible_port=22\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/requirements.yml",
    "chars": 80,
    "preview": "- src: https://github.com/chriswayg/ansible-initial-server.git\n  #version: v1.7\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/server-template-vars.yml",
    "chars": 461,
    "preview": "---\n\niserver_hostname: openbsd6\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNB"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/server-template.yml",
    "chars": 877,
    "preview": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json con"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/README.md",
    "chars": 971,
    "preview": "## [Ubuntu ](http://releases.ubuntu.com/18.04/) 18.04 (bionic) Packer Template using [Packer Proxmox Builder](https://ww"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/build.conf",
    "chars": 377,
    "preview": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=20000 # default VM ID for Ubuntu\nproxmox_url=https://proxmox.ligh"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/playbook/ansible.cfg",
    "chars": 226,
    "preview": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callb"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/playbook/requirements.yml",
    "chars": 80,
    "preview": "- src: https://github.com/chriswayg/ansible-initial-server.git\n  #version: v1.7\n"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/playbook/server-template-vars.yml",
    "chars": 1210,
    "preview": "---\n\niserver_hostname: ubuntu1804-kvm\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROs"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/playbook/server-template.yml",
    "chars": 568,
    "preview": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json con"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/preseed.cfg.j2",
    "chars": 3223,
    "preview": "#### Preseed file for Ubuntu 18.04 bionic\n# Docs: - https://help.ubuntu.com/lts/installation-guide/amd64/apbs01.html\n#  "
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/ubuntu-18.04-amd64-proxmox.json",
    "chars": 3137,
    "preview": "{\n    \"description\": \"Build Ubuntu 18.04 (bionic) x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/README.md",
    "chars": 970,
    "preview": "## [Ubuntu ](http://releases.ubuntu.com/20.04/) 20.04 (focal) Packer Template using [Packer Proxmox Builder](https://www"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/build.conf",
    "chars": 420,
    "preview": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=21000 # default VM ID for Ubuntu\nproxmox_url=https://proxmox.ligh"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/playbook/ansible.cfg",
    "chars": 226,
    "preview": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callb"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/playbook/requirements.yml",
    "chars": 80,
    "preview": "- src: https://github.com/chriswayg/ansible-initial-server.git\n  #version: v1.7\n"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/playbook/server-template-vars.yml",
    "chars": 1202,
    "preview": "---\n\niserver_hostname: ubuntu2004-kvm\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROs"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/playbook/server-template.yml",
    "chars": 568,
    "preview": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json con"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/preseed.cfg.j2",
    "chars": 3222,
    "preview": "#### Preseed file for Ubuntu 20.04 focal\n# Docs: - https://help.ubuntu.com/lts/installation-guide/amd64/apbs01.html\n#   "
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/ubuntu-20.04-amd64-proxmox.json",
    "chars": 3136,
    "preview": "{\n    \"description\": \"Build Ubuntu 20.04 (focal) x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{{"
  }
]

// ... and 2 more files (download for full content)

About this extraction

This page contains the full source code of the chriswayg/packer-proxmox-templates GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 69 files (17.0 MB), approximately 29.2k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!