[
  {
    "path": ".gitignore",
    "content": "*.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/\ndebug/\nreleases/\n\n# ignore packer_cache\npacker_cache\noutput-qemu\npacker-qemu\n\n# created from template\npreseed.cfg\ninstall.conf\n\n# others\ncloud-config.yml\n"
  },
  {
    "path": "README.md",
    "content": "# packer-proxmox-templates\n:package: Packer templates for building Proxmox KVM images from ISO\n\n- use the latest tagged version which has been tested more thoroughly than 'master'\n\n#### [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\n\n#### [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\n\n#### [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\n\n#### [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\n\n#### [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\n\n#### [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\n\n## Proxmox KVM image templates\n\n- downloads the ISO and places it in Proxmox\n- creates a Proxmox VM\n- builds the image with Packer using automated installs\n- configures the image with Packer using Ansible\n- stores it as a Proxmox Template\n- see specific README.md for details about each template\n\n### Check Prerequisites\n\nThe 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:\n\n- Ensure that [Proxmox 6](https://www.proxmox.com/en/downloads) is installed\n- 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).\n\n```\nprintf  \"Proxmox $(pveversion)\\n\"\n```\n\n- Install [Packer](https://www.packer.io/downloads.html) on the Proxmox server\n\n```\napt -y install unzip\npacker_ver=1.5.5\nwget https://releases.hashicorp.com/packer/${packer_ver}/packer_${packer_ver}_linux_amd64.zip\nsudo unzip packer_${packer_ver}_linux_amd64.zip -d /usr/local/bin\npacker --version\n```\n\n- Install [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) on the Proxmox server\n\n```\napt -y install python3-pip\npip3 install ansible==2.9.7\npip3 install py-bcrypt\n```\n\n- Install [j2cli](https://github.com/kolypto/j2cli) on the Proxmox server\n\n```\npip3 install j2cli[yaml]\n```\n\n### Download the latest tagged release of packer-proxmox-templates onto the Proxmox server\n\n`wget https://github.com/chriswayg/packer-proxmox-templates/archive/v1.7.zip && unzip v1.7.zip && cd packer-proxmox-templates-*`\n\n### Usage\n\nOn the Proxmox Server with Packer installed:\n\n```\ncd OSname-xy-amd64-proxmox\n\n# for example\ncd debian-10-amd64-proxmox\ncd ubuntu-18.04-amd64-proxmox\ncd openbsd-6-amd64-proxmox\n\n```\n\n- edit `build.conf`, including the default user and especially the Proxmox URL and the ISO download links for the latest distro version\n- edit `playbook/server-template-vars.yml`, especially the SSH Key & regional repositories\n\n```sh\n../build.sh proxmox\n```\n\n- The template creation can be observed in the Proxmox GUI\n- Login via SSH using the default username as set in `build.conf`, or login as root via console (if not disabled)\n\n### Build Options\n\n```sh\n../build.sh (proxmox|debug [new_VM_ID])\n\nproxmox    - Build and create a Proxmox VM template\ndebug      - Debug Mode: Build and create a Proxmox VM template\n\nVM_ID     - VM ID for new VM template (or use default from build.conf)\n\nEnter Passwords when prompted or provide them via ENV variables:\n(use a space in front of ' export' to keep passwords out of bash_history)\n export proxmox_password=MyLoginPassword\n export ssh_password=MyPasswordInVM\n```\n\n#### Build environment\n\nThe 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.\n\n```sh\nprintf  \"$(lsb_release -d) $(cat /etc/debian_version)\\n\" && \\\n  printf  \"Proxmox $(pveversion)\\n\" &&\n  packer version && \\\n  ansible --version |  sed -n '1p' && \\\n  ansible --version |  sed -n '6p' && \\\n  j2 --version\n\n        Description:\tDebian GNU/Linux 10 (buster) 10.3\n        Proxmox pve-manager/6.1-8/806edfe1 (running kernel: 5.3.18-3-pve)\n        Packer v1.5.5\n        ansible 2.9.7\n          python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]\n        j2cli 0.3.10, Jinja2 2.11.2\n```\n\n**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).\n\nIt 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.\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/README.md",
    "content": "## [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\n\nStatus: **working**\n\n### Features\n- downloads the ISO and places it in Proxmox\n- creates a Proxmox VM\n- builds the image using an answers file and bash scripts\n- stores it as a Proxmox Template\n\n### Configurations\n- passwordless sudo for default user 'christian'\n- SSH public key installed for default user\n- display IP and SSH fingerprint before console login\n- automatically grow partition after resize by Proxmox\n\n### Instructions\n- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)\n\n### Docs\n- [Semi-Automatic Installation - Alpine Linux Documentation](https://beta.docs.alpinelinux.org/user-handbook/0.1a/Installing/manual.html)\n\n\n### License and Credits\n- Apache 2.0 Copyright 2019 Christian Wagner\n- partially based on Matt Maier's [Packer Alpine Templates](https://github.com/maier/packer-templates)\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/alpine-3-amd64-proxmox.json",
    "content": "{\n    \"description\": \"Build Alpine Linux 3 x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{{env `proxmox_url`}}\",\n        \"proxmox_username\": \"root@pam\",\n        \"proxmox_password\": \"{{env `proxmox_password`}}\",\n        \"proxmox_host\": \"{{env `proxmox_host`}}\",\n        \"iso_filename\": \"{{env `iso_filename`}}\",\n        \"vm_id\": \"{{env `vm_id`}}\",\n        \"vm_name\": \"alpine3-tmpl\",\n        \"template_description\": \"Alpine Linux 3.11 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}\",\n        \"vm_default_user\": \"{{env `vm_default_user`}}\",\n        \"vm_memory\": \"{{env `vm_memory`}}\",\n        \"ssh_username\": \"root\",\n        \"ssh_password\": \"{{env `ssh_password`}}\"\n    },\n    \"sensitive-variables\": [\"proxmox_password\", \"ssh_password\" ],\n    \"provisioners\": [\n      {\n        \"type\": \"ansible\",\n        \"playbook_file\": \"./playbook/server-template.yml\",\n        \"extra_arguments\": [\n          \"{{user `ansible_verbosity`}}\",\n          \"--extra-vars\", \"vm_default_user={{user `vm_default_user`}}\",\n          \"--tags\", \"all,is_template\",\n          \"--skip-tags\", \"debuntu,openbsd\"\n        ],\n        \"ansible_env_vars\": [ \"ANSIBLE_CONFIG=./playbook/ansible.cfg\", \"ANSIBLE_FORCE_COLOR=True\" ]\n      }\n    ],\n    \"builders\": [\n        {\n            \"type\": \"proxmox\",\n            \"proxmox_url\":  \"{{user `proxmox_url`}}\",\n            \"insecure_skip_tls_verify\": true,\n            \"username\": \"{{user `proxmox_username`}}\",\n            \"password\": \"{{user `proxmox_password`}}\",\n            \"vm_id\":  \"{{user `vm_id`}}\",\n            \"vm_name\": \"{{user `vm_name`}}\",\n            \"template_description\":\"{{user `template_description`}}\",\n            \"memory\": \"{{user `vm_memory`}}\",\n            \"cores\": \"2\",\n            \"os\": \"l26\",\n            \"http_directory\": \"http\",\n\n            \"node\": \"{{user `proxmox_host`}}\",\n            \"network_adapters\": [\n              {\n                \"model\": \"virtio\",\n                \"bridge\": \"vmbr1\"\n              }\n            ],\n            \"disks\": [\n              {\n                \"type\": \"sata\",\n                \"disk_size\": \"8G\",\n                \"storage_pool\": \"local\",\n                \"storage_pool_type\": \"directory\",\n                \"format\": \"qcow2\"\n              }\n            ],\n            \"ssh_username\": \"{{user `ssh_username`}}\",\n            \"ssh_password\": \"{{user `ssh_password`}}\",\n            \"ssh_timeout\": \"15m\",\n            \"iso_file\": \"local:iso/{{user `iso_filename`}}\",\n            \"unmount_iso\": true,\n            \"boot_wait\": \"10s\",\n            \"boot_command\": [\n                \"root<enter><wait>\",\n                \"ifconfig eth0 up && udhcpc -i eth0<enter><wait5>\",\n                \"wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers<enter><wait>\",\n                \"setup-alpine -f $PWD/answers<enter><wait5>\",\n                \"{{user `ssh_password`}}<enter><wait>\",\n                \"{{user `ssh_password`}}<enter><wait>\",\n                \"<wait10><wait5>\",\n                \"y<enter>\",\n                \"<wait10><wait10>\",\n                \"rc-service sshd stop <enter>\",\n                \"mount /dev/sda2 /mnt <enter>\",\n                \"mount /dev/ /mnt/dev/ --bind <enter>\",\n                \"mount -t proc none /mnt/proc <enter>\",\n                \"mount -o bind /sys /mnt/sys <enter>\",\n                \"chroot /mnt /bin/sh -l <enter><wait>\",\n                \"echo '@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories <enter>\",\n                \"echo -e 'nameserver 1.1.1.1' > /etc/resolv.conf <enter>\",\n                \"apk update <enter><wait10>\",\n                \"apk add 'qemu-guest-agent@edgecommunity' 'python' <enter><wait>\",\n                \"echo -e GA_PATH=\\\"/dev/vport1p1\\\" >> /etc/conf.d/qemu-guest-agent <enter>\",\n                \"rc-update add qemu-guest-agent <enter>\",\n                \"echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config <enter>\",\n                \"exit <enter><wait>\",\n                \"umount /mnt/sys <enter><wait>\",\n                \"umount /mnt/proc <enter><wait>\",\n                \"umount /mnt/dev <enter><wait>\",\n                \"umount /mnt <enter>\",\n                \"reboot <enter>\"\n            ]\n        }\n    ],\n    \"post-processors\": [\n      {\n        \"type\": \"shell-local\",\n        \"inline_shebang\": \"/bin/bash -e\",\n        \"inline\": [\"qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0\"]\n      }\n  ]\n}\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/build.conf",
    "content": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=40000 # default VM ID for Alpine\nproxmox_url=https://proxmox.lightinasia.site:8006/api2/json\nproxmox_host=proxmox\n\niso_url=http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/x86_64/alpine-virt-3.11.6-x86_64.iso\niso_sha256_url=http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/x86_64/alpine-virt-3.11.6-x86_64.iso.sha256\n\niso_directory=/var/lib/vz/template/iso\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/http/answers",
    "content": "KEYMAPOPTS=\"us us\"\nHOSTNAMEOPTS=\"-n alpine3\"\nINTERFACESOPTS=\"auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet dhcp\n    hostname alpine3\n\"\nDNSOPTS=\"-d local -n 1.1.1.1 1.0.0.1\"\nTIMEZONEOPTS=\"-z UTC\"\nPROXYOPTS=\"none\"\nAPKREPOSOPTS=\"http://nl.alpinelinux.org/alpine/v3.11/main\nhttp://nl.alpinelinux.org/alpine/v3.11/community\n\"\nSSHDOPTS=\"-c openssh\"\nNTPOPTS=\"-c chrony\"\nDISKOPTS=\"-s 0 -m sys /dev/sda\"\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/notes.md",
    "content": "# scratchpad\n\n\n### Docker\n```\napk add docker-engine@edgecommunity docker-openrc@edgecommunity docker-cli@edgecommunity docker@edgecommunity\ndocker --version\n\napk add py3-setuptools python3-dev libffi-dev openssl-dev gcc libc-dev make\npip3 install --upgrade pip\npip3 install docker-compose\ndocker-compose --version\n```\nor\n\n```\napk add docker-compose@edgecommunity\ndocker-compose --version\n```\n\n### boot command:\n`openntpd` missing (error)\n\n### qemu guest\n\n```\nhost:~# cat /etc/conf.d/qemu-guest-agent\n# Specifies the transport method used to communicate to QEMU on the host side\n# Default: virtio-serial\n#GA_METHOD=\"virtio-serial\"\n\n# Specifies the device path for the communications back to QEMU on the host\n# Default: /dev/virtio-ports/org.qemu.guest_agent.0\nGA_PATH=\"/dev/vport1p1\"\n```\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/playbook/ansible.cfg",
    "content": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callback = yaml\nroles_path = ./roles\nlog_path = ./logs/server-template.log\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/playbook/requirements.yml",
    "content": "- src: https://github.com/chriswayg/ansible-initial-server.git\n  #version: v1.7\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/playbook/server-template-vars.yml",
    "content": "---\n\niserver_hostname: alpine3-kvm\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local\"\n\niserver_alpine_repos:\n  - 'http://nl.alpinelinux.org/alpine/v3.11/main'\n  - 'http://nl.alpinelinux.org/alpine/v3.11/community'\n  - '@edge http://nl.alpinelinux.org/alpine/edge/main'\n  - '@testing http://nl.alpinelinux.org/alpine/edge/testing'\n  - '@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community'\n"
  },
  {
    "path": "alpine-3-amd64-proxmox/playbook/server-template.yml",
    "content": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json config for this provisioner.\n# https://www.packer.io/docs/provisioners/ansible.html\n\n# TODO: For unclear reasons, I could only get it to work with the root user in Packer\n# 'become' in playbook or role tasks seem to be ignored by Packer Ansible\n\n- name: Initial configuration of a server.\n  hosts: all\n  vars_files:\n    - server-template-vars.yml\n  roles:\n    - role: ansible-initial-server\n      vars:\n        iserver_user: \"{{ vm_default_user }}\"\n"
  },
  {
    "path": "alpine-3-amd64-qemu/LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n"
  },
  {
    "path": "alpine-3-amd64-qemu/README.md",
    "content": "## [Alpine Linux](http://alpinelinux.org) Packer Template using QEMU Builder to build a KVM cloud image usable in Proxmox or Openstack\n\nStatus: **working**\n\n* this creates a cloud image with cloud-init to be used on Proxmox and possibly Openstack\n\n### Prerequisites\n\n1) 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.\n\n- Install qemu build dependencies\n\n```\nsudo apt autoremove\nsudo apt purge qemu\n\n#sudo apt-get install build-essential pkg-config libglib2.0-dev  libpixman-1-dev libgtk-3-dev\nsudo apt-get build-dep qemu\nsudo apt-get install libgtk-3-dev checkinstall\n```\n\n- Build and install qemu 4.2.0\n\n```\nwget https://download.qemu.org/qemu-4.2.0.tar.xz\ntar xvJf qemu-4.2.0\ncd qemu-4.2.0\n./configure --target-list=x86_64-softmmu --enable-gtk\nmake\nsudo checkinstall\n```\n\n2) Install packer (see pre-reqs in main README)\n\n### Usage notes\n\n```sh\ncd alpine-3-amd64-qemu\nsudo packer build alpine-3-amd64-qemu.json\n```\n- The image is saved as `alpine-311-cloudimg-amd64.qcow2` in the `output` directory\n\n- Test the image locally:\n  - adapt `user-data` and `meta-data` as needed\n  - login as root on the console. Password: alpineqemu\n  - login via ssh\n\n```sh\ngenisoimage -output output/cloud-data.iso -volid cidata -joliet -rock user-data meta-data\n\nsudo 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\n\nssh -i alpine_id_rsa -p 2222 alpine@localhost\n```\n- To install the image as a template on Proxmox, the following script can be used:\n- [Script to download a cloud image and create a Proxmox 6 template](https://gist.github.com/chriswayg/43fbea910e024cbe608d7dcb12cb8466)\n\n### Features\n- default user alpine\n- add user-data via image drive\n- SSH login only via SHH key\n- passwordless sudo\n- no root login via ssh\n  - optional root login via console\n\n### cloud-init features on Alpine\n- the fuctionality is not quite complete on Alpine\n\n#### Working\n- getting user and metadata from image drive\n- setting hostname (1st boot)\n- setting up user (1st boot)\n- copying SSH authorized keys (1st boot)\n- automatically growing the disk drive with growpart\n  - `qm resize 8000 scsi0 +30G` upon restart\n\n#### Not working (apparently)\n- writing of network config\n- password for user (not entered into `/etc/shadow`)\n- changed data on image-drive is not applied after 1st boot\n- serial console appears to be buggy, making it hard to log in\n\n### Fulfills most Openstack requirements\n\nFor 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.\n\n* Disk partitions and resize root partition on boot (cloud-init)\n* No hard-coded MAC address information\n* SSH server running\n* Disable firewall\n* Access instance using ssh public key (cloud-init)\n* Process user data and other metadata (cloud-init)\n\n[OpenStack Docs: Image requirements](https://docs.openstack.org/image-guide/openstack-images.html)\n\n### Docs\n- [Semi-Automatic Installation - Alpine Linux Documentation](https://beta.docs.alpinelinux.org/user-handbook/0.1a/Installing/manual.html)\n- [OpenStack Docs: Create images manually](https://docs.openstack.org/image-guide/create-images-manually.html)\n\n### Build environment\n\n```sh\npacker version && qemu-system-x86_64 -version && lsb_release -d\n\n      Packer v1.5.5\n      QEMU emulator version 4.2.0\n      Ubuntu 18.04.4 LTS\n```\n\n### License and Credits\n- Apache 2.0 Copyright 2019 Christian Wagner\n- partially based on Matt Maier's [Packer Alpine Templates](https://github.com/maier/packer-templates)\n"
  },
  {
    "path": "alpine-3-amd64-qemu/alpine-3-amd64-qemu.json",
    "content": "{\n  \"description\": \"Build base Alpine Linux x86_64\",\n\n  \"variables\": {\n      \"disk_size\": \"2048\",\n      \"memory\": \"1024\",\n      \"cpus\": \"1\"\n  },\n  \"provisioners\": [\n    {\n      \"type\": \"shell\",\n      \"scripts\": [\n        \"scripts/00base.sh\",\n        \"scripts/01alpine.sh\",\n        \"scripts/01networking.sh\",\n        \"scripts/02sshd.sh\",\n        \"scripts/04sudoers.sh\",\n        \"scripts/70random.sh\",\n        \"scripts/80cloudinit.sh\",\n        \"scripts/90showip.sh\",\n        \"scripts/99minimize.sh\"\n      ]\n    }\n  ],\n  \"builders\": [\n    {\n      \"type\": \"qemu\",\n      \"qemu_binary\": \"qemu-system-x86_64\",\n      \"format\": \"qcow2\",\n      \"accelerator\": \"kvm\",\n      \"qemuargs\": [\n        [ \"-device\", \"virtio-rng-pci\" ],\n        [ \"-device\", \"virtio-scsi-pci,id=scsi0\" ],\n        [ \"-device\", \"scsi-hd,bus=scsi0.0,drive=drive0\" ],\n        [ \"-device\", \"virtio-net,netdev=user.0\" ]\n      ],\n      \"disk_interface\": \"virtio-scsi\",\n      \"headless\": false,\n      \"disk_size\": \"{{user `disk_size`}}\",\n      \"memory\": \"{{user `memory`}}\",\n      \"cpus\": \"{{user `cpus`}}\",\n      \"http_directory\": \"http\",\n\n      \"iso_urls\": [\"isos/alpine-virt-3.11.5-x86_64.iso\",\n                   \"http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/x86_64/alpine-virt-3.11.5-x86_64.iso\"],\n      \"iso_checksum\": \"8e14a8f23d1d0a3772d486a94a7d707df65a942e605617ed6431fcb1ede387e4\",\n      \"iso_checksum_type\": \"sha256\",\n\n      \"communicator\": \"ssh\",\n      \"ssh_username\": \"root\",\n      \"ssh_password\": \"alpineqemu\",\n      \"ssh_wait_timeout\": \"10m\",\n      \"shutdown_command\": \"poweroff\",\n      \"boot_wait\": \"30s\",\n      \"boot_command\": [\n        \"root<enter><wait>\",\n        \"ifconfig eth0 up && udhcpc -i eth0<enter><wait5>\",\n        \"wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers<enter><wait>\",\n        \"setup-alpine -f $PWD/answers<enter><wait5>\",\n        \"alpineqemu<enter><wait>\",\n        \"alpineqemu<enter><wait>\",\n        \"<wait10><wait10>\",\n        \"y<enter>\",\n        \"<wait10><wait10><wait10>\",\n        \"<wait10><wait10><wait10>\",\n        \"rc-service sshd stop<enter>\",\n        \"mount /dev/sda2 /mnt<enter>\",\n        \"echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config<enter>\",\n        \"umount /mnt<enter>\",\n        \"reboot<enter>\"\n      ]\n    }\n  ],\n  \"post-processors\": [\n    {\n      \"type\": \"shell-local\",\n      \"inline\": [\"mv -fv output-qemu/packer-qemu output/alpine-311-cloudimg-amd64.qcow2 && rmdir -v output-qemu\"]\n    }\n  ]\n}\n"
  },
  {
    "path": "alpine-3-amd64-qemu/alpine_id_rsa",
    "content": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEArvZdvBLBAsidAnJ3ZKtNb2pFigEzr+P9KArOVV5futoZFWpI\nHo74XJ1E7bith29MQpsovWuUGiBqoGKDIFXxarpGQjs0NcTeO+gPjM3bYLnQrdh5\n3V8n5iU8HoE27OHUj/+jtt3Ofe1spu7le6Vn5oRdOZEV/3ysK0YuNoXcHcJ2+1Ye\nYsOY7D7J8zVXYkT8UgaDJTUaaIg8YIGFI7Fx16zVY2V72qbG3AYzLCWi15CdFEvV\nO/S6lPOqrK1mHvznYt5jXiLnagyxQW95jeFO2Ux9GsFDQqB9cr9l/5ahGcdmYF8J\nKsCqvW8j0gb94RGn0P/tHv/tyokHUd23gIc6kQIDAQABAoIBAQCLysar/WP/oGBq\n0yB367LMIWH8WOd+UrAzrSac6PGd7qJ6DNggqmTgQrwPIC5t9sw8r5IGfozvrxTi\nnrNcQ67HcpuuUXVuvKQ/wzOhcd0lVHHaZQtBh8TuSrPVP7Kt4+YdQ8j/1AsnbGsS\nme/7MfZpJTsDQtwLrQY28TT9VUjA8QuCdz/1XFAq7eEqoOvQVfC+ulj5YwDqueHr\nzC6ewZ4GFp7tpj66qYM0YR3jZXjqQCeqiFyxTbTxcErhlihcE499uIUoedb7GS4W\ndOlTvfmZdxCM8xitXTDWrnmF3P+woXowE0gl8EcPmGcN+gsNUYgwnGF1YZM4/8Cd\n0g7hKHIBAoGBAOJEtySti50urzrXF5hQ8/p6Kos/0IVgqBUQ1tcOWUZ2Ln9uuhpU\nF+Esx3TQV2ET6MIh3DIGzqahcPMdaVuw5WwLxW5RBPZ+I6G2vgsXEfF2oQspiKH+\nM49LFjK+XKIeTQpGc4/r8RDwlPsO5K3HsezCdfCDJPN0r0sIL0V515qhAoGBAMXz\nzW7al+blz66XmI85H5qem/Vz8KioBNtLZK2SAazdtrDKhB7wR9ADKs4eOkWUOkeY\ne/Oh6AV0a9cPSZ/KiYiGO1Y/manZ51MAUjmlRepMJKCbckNAJLgzfFuXg5EtqYY7\nQ9mcPxae3U313H0hI77mGEd9NhcaoD0LlWaavwnxAoGBANsY9s6JTbuyTPOI+8v9\n94H/cdrMvDmq0pczaxVrS38zSOsUaRi9fTIJjknKxBG4mZYB+5plhQ1NHnYLcM3c\niQsKiu67fTbCBfa9YWCTwkgyOtb4LNnPsFV8u83/Duvcs3TTq2sdaJyimWBRl5W+\n3McJtfJiyxEDWAorrrpztRaBAoGAIW79KpT3BQOZoTZviPkv8lCJrNpJMmM2dsd0\nGLDJYaYM3i1GRWd16ZcvWqLWWrwfX8pMXSjiZFF2iVtGpxtxQULSsM2LKZnpLSan\nvJ7CgUEdCpdWpC8oRIhFn76mdRXORSKrYgy2xx5L6If3FpdLT0nTnfdy9FIF8GmN\ncUf/rjECgYBfGI7fUm6E98xuuQGDOMiP4VPGm4aOznCnyXF3fI+Uw0ke/kI+Wvm+\nLEeEHGlbOiS7x8nV5usm9j1DDrOFBhMWIC9Rasn6NZbcMYoQpiYABPJHBBGaqa19\nPX9Dt8IssWUIhX1fFQdTJrzMo1VPZMu5NR3Axfp+z3ubosrTuplS1A==\n-----END RSA PRIVATE KEY-----\n"
  },
  {
    "path": "alpine-3-amd64-qemu/alpine_id_rsa.ppk",
    "content": "PuTTY-User-Key-File-2: ssh-rsa\nEncryption: none\nComment: imported-openssh-key\nPublic-Lines: 6\nAAAAB3NzaC1yc2EAAAADAQABAAABAQCu9l28EsECyJ0Ccndkq01vakWKATOv4/0o\nCs5VXl+62hkVakgejvhcnUTtuK2Hb0xCmyi9a5QaIGqgYoMgVfFqukZCOzQ1xN47\n6A+MzdtgudCt2HndXyfmJTwegTbs4dSP/6O23c597Wym7uV7pWfmhF05kRX/fKwr\nRi42hdwdwnb7Vh5iw5jsPsnzNVdiRPxSBoMlNRpoiDxggYUjsXHXrNVjZXvapsbc\nBjMsJaLXkJ0US9U79LqU86qsrWYe/Odi3mNeIudqDLFBb3mN4U7ZTH0awUNCoH1y\nv2X/lqEZx2ZgXwkqwKq9byPSBv3hEafQ/+0e/+3KiQdR3beAhzqR\nPrivate-Lines: 14\nAAABAQCLysar/WP/oGBq0yB367LMIWH8WOd+UrAzrSac6PGd7qJ6DNggqmTgQrwP\nIC5t9sw8r5IGfozvrxTinrNcQ67HcpuuUXVuvKQ/wzOhcd0lVHHaZQtBh8TuSrPV\nP7Kt4+YdQ8j/1AsnbGsSme/7MfZpJTsDQtwLrQY28TT9VUjA8QuCdz/1XFAq7eEq\noOvQVfC+ulj5YwDqueHrzC6ewZ4GFp7tpj66qYM0YR3jZXjqQCeqiFyxTbTxcErh\nlihcE499uIUoedb7GS4WdOlTvfmZdxCM8xitXTDWrnmF3P+woXowE0gl8EcPmGcN\n+gsNUYgwnGF1YZM4/8Cd0g7hKHIBAAAAgQDiRLckrYudLq861xeYUPP6eiqLP9CF\nYKgVENbXDllGdi5/broaVBfhLMd00FdhE+jCIdwyBs6moXDzHWlbsOVsC8VuUQT2\nfiOhtr4LFxHxdqELKYih/jOPSxYyvlyiHk0KRnOP6/EQ8JT7DuStx7HswnXwgyTz\ndK9LCC9FedeaoQAAAIEAxfPNbtqX5uXPrpeYjzkfmp6b9XPwqKgE20tkrZIBrN22\nsMqEHvBH0AMqzh46RZQ6R5h786HoBXRr1w9Jn8qJiIY7Vj+ZqdnnUwBSOaVF6kwk\noJtyQ0AkuDN8W5eDkS2phjtD2Zw/Fp7dTfXcfSEjvuYYR302FxqgPQuVZpq/CfEA\nAACAXxiO31JuhPfMbrkBgzjIj+FTxpuGjs5wp8lxd3yPlMNJHv5CPlr5vixHhBxp\nWzoku8fJ1ebrJvY9Qw6zhQYTFiAvUWrJ+jWW3DGKEKYmAATyRwQRmqmtfT1/Q7fC\nLLFlCIV9XxUHUya8zKNVT2TLuTUdwMX6fs97m6LK07qZUtQ=\nPrivate-MAC: cc9bd253b5cab2859e8324323fa108e5308d8108\n"
  },
  {
    "path": "alpine-3-amd64-qemu/alpine_id_rsa.pub",
    "content": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu9l28EsECyJ0Ccndkq01vakWKATOv4/0oCs5VXl+62hkVakgejvhcnUTtuK2Hb0xCmyi9a5QaIGqgYoMgVfFqukZCOzQ1xN476A+MzdtgudCt2HndXyfmJTwegTbs4dSP/6O23c597Wym7uV7pWfmhF05kRX/fKwrRi42hdwdwnb7Vh5iw5jsPsnzNVdiRPxSBoMlNRpoiDxggYUjsXHXrNVjZXvapsbcBjMsJaLXkJ0US9U79LqU86qsrWYe/Odi3mNeIudqDLFBb3mN4U7ZTH0awUNCoH1yv2X/lqEZx2ZgXwkqwKq9byPSBv3hEafQ/+0e/+3KiQdR3beAhzqR christian@ubuntu\n"
  },
  {
    "path": "alpine-3-amd64-qemu/http/answers",
    "content": "KEYMAPOPTS=\"us us\"\nHOSTNAMEOPTS=\"-n alpine3\"\nINTERFACESOPTS=\"auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet dhcp\n    hostname alpine3\n\"\nDNSOPTS=\"-d local -n 1.1.1.1 1.0.0.1\"\nTIMEZONEOPTS=\"-z UTC\"\nPROXYOPTS=\"none\"\nAPKREPOSOPTS=\"http://dl-cdn.alpinelinux.org/alpine/v3.11/main\"\nSSHDOPTS=\"-c openssh\"\nNTPOPTS=\"-c openntpd\"\nDISKOPTS=\"-s 0 -m sys /dev/sda\"\n"
  },
  {
    "path": "alpine-3-amd64-qemu/meta-data",
    "content": "instance-id: 12fb410a-6652-46e9-8b32-db6698678ddc\n"
  },
  {
    "path": "alpine-3-amd64-qemu/notes-commands.md",
    "content": "## Misc. Notes\n\n- Alpine boot kernel 'virt' with randomness from CPU & info during boot for testing\n```\nvirt random.trust_cpu=1 debug\n```\n"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/00base.sh",
    "content": "set -ux\n\napk upgrade -U --available\n\nsource /etc/os-release\n\nprintf \"\\n $PRETTY_NAME ($VERSION_ID) Cloud Server\\n\\n\" > /etc/motd\n"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/01alpine.sh",
    "content": "set -ux\n\n# adding repositories needed for cloud-init\necho \"http://nl.alpinelinux.org/alpine/v3.11/community\" >> /etc/apk/repositories\necho \"@edge http://nl.alpinelinux.org/alpine/edge/main\" >> /etc/apk/repositories\necho \"@testing http://nl.alpinelinux.org/alpine/edge/testing\" >> /etc/apk/repositories\necho \"@edgecommunity http://dl-cdn.alpinelinux.org/alpine/edge/community\" >> /etc/apk/repositories\n\n# update all packages, including the kernel.\napk update\napk upgrade\n"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/01networking.sh",
    "content": "set -ux\n\n# nothing special required\n\nexit 0"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/02sshd.sh",
    "content": "set -eux\n\n# RootLogin without password was permitted in order to allow packer ssh access\n# to provision the system. Its removed here to make the server more secure.\nsed -i '/^PermitRootLogin no/d' /etc/ssh/sshd_config\n\n# disable ssh password authentication\nsed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config\n"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/04sudoers.sh",
    "content": "set -eux\n\n# this configuration allows the alpine account to sudo su - without needing a password\n\n# Install sudo\napk add sudo shadow\n\n# Create Initial User\nadduser -D alpine -G wheel\n\n# allow sudo without password\necho \"Defaults exempt_group=wheel\" > /etc/sudoers\necho \"%wheel ALL=NOPASSWD:ALL\" >> /etc/sudoers\n\n# allows ssh login without the user being locked\n# https://unix.stackexchange.com/questions/193066/how-to-unlock-account-for-public-key-ssh-authorization-but-not-for-password-aut\nusermod -p '*' alpine\n\n# the root user is also being blocked from ssh login in sshd_config\n# remove root password (optional - makes it impossible to login as root from console)\n#usermod -p '*' root\n\n# lock root account\n#passwd -l root\n"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/70random.sh",
    "content": "set -eux\n\n# Fixes: Boot delay/issues because of limited entropy\n# https://gitlab.alpinelinux.org/alpine/aports/issues/9960\napk add haveged\nrc-update add haveged boot\n"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/80cloudinit.sh",
    "content": "set -eux\n\napk add cloud-init@testing\n\n# install missing dependencies\napk add eudev\n\n# needed for 'growpart'\napk add cloud-utils@testing\n\n# install utils\napk add acpi\napk add nano\n\n# make sure CD drive with cloud-init config data gets mounted\n# /dev/sr0        /media/cdrom    iso9660 ro 0 0\nsed -i 's/\\/dev\\/cdrom/\\/dev\\/sr0/g' /etc/fstab\nsed -i 's/noauto,ro/ro/g' /etc/fstab\n\n# writing of network config is not implemented in alpine cloud-init\n#apk add iproute2 ifupdown\necho \"network: {config: disabled}\" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg\n\n# Start Cloud-Init on Boot\nrc-update add cloud-init default\n\n# enable automatically growing the partition\ncat > /etc/cloud/cloud.cfg.d/10_growpart.cfg << \"EOF\"\ngrowpart:\n  mode: growpart\n  devices: [\"/dev/sda2\"]\n  ignore_growroot_disabled: false\n\n# the above settings do not seem to get used, thus run growpart here\nbootcmd:\n - growpart /dev/sda 2\nEOF\n\n# activate serial console\n# it is buggy, as it makes it hard to log in\n\n# sed -i 's/quiet/console=ttyS0,9600/g' /etc/update-extlinux.conf\n# update-extlinux\n#\n# sed -i 's/#ttyS0/ttyS0/g' /etc/inittab\n"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/90showip.sh",
    "content": "# show SSH key fingerprint and IP address on console\n\ncp /etc/issue /etc/issue-standard\n\n# Creates a script which will run when the network comes up\ncat > /etc/network/if-up.d/show-ip-address << \"EOF\"\n#!/bin/sh\nif [ \"$METHOD\" = loopback ]; then\n    exit 0\nfi\n\n# Only run from ifup.\nif [ \"$MODE\" != start ]; then\n    exit 0\nfi\n\ncp /etc/issue-standard /etc/issue\nprintf \"ECDSA key fingerprint:\\n$(ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub)\\n\" >> /etc/issue\nprintf \"\\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\n\nEOF\n\nchmod +x /etc/network/if-up.d/show-ip-address\n"
  },
  {
    "path": "alpine-3-amd64-qemu/scripts/99minimize.sh",
    "content": "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# will try to kill the box while the disk is still full and that's bad\nsync\nsync\nsync\n\nexit 0\n"
  },
  {
    "path": "alpine-3-amd64-qemu/user-data",
    "content": "#cloud-config\nhostname: alpine3\nssh_authorized_keys:\n  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu9l28EsECyJ0Ccndkq01vakWKATOv4/0oCs5VXl+62hkVakgejvhcnUTtuK2Hb0xCmyi9a5QaIGqgYoMgVfFqukZCOzQ1xN476A+MzdtgudCt2HndXyfmJTwegTbs4dSP/6O23c597Wym7uV7pWfmhF05kRX/fKwrRi42hdwdwnb7Vh5iw5jsPsnzNVdiRPxSBoMlNRpoiDxggYUjsXHXrNVjZXvapsbcBjMsJaLXkJ0US9U79LqU86qsrWYe/Odi3mNeIudqDLFBb3mN4U7ZTH0awUNCoH1yv2X/lqEZx2ZgXwkqwKq9byPSBv3hEafQ/+0e/+3KiQdR3beAhzqR christian@ubuntu\nchpasswd:\n  expire: False\nusers:\n  - default\npackage_upgrade: true\n"
  },
  {
    "path": "build.sh",
    "content": "#!/usr/bin/env bash\n\n# Many variables are sourced from build.conf and passed as environment variables to Packer.\n# The vm_default_user name will be used by Packer and Ansible.\n# (j2 is a better solution than 'envsubst' which messes up '$' in the text unless you specify each variable)\n# vm_default_user\n# vm_memory\n# proxmox_host\n# iso_filename\n# vm_ver\n# vm_id\n# proxmox_password\n# ssh_password\n\nset -o allexport\nbuild_conf=\"build.conf\"\n\nfunction help {\n    printf \"\\n\"\n    echo \"$0 (proxmox|debug [VM_ID])\"\n    echo\n    echo \"proxmox   - Build and create a Proxmox VM template\"\n    echo \"debug     - Debug Mode: Build and create a Proxmox VM template\"\n    echo\n    echo \"VM_ID     - VM ID for new VM template (overrides default from build.conf)\"\n    echo\n    echo \"Enter Passwwords when prompted or provide them via ENV variables:\"\n    echo \"(use a space in front of ' export' to keep passwords out of bash_history)\"\n    echo \" export proxmox_password=MyLoginPassword\"\n    echo \" export ssh_password=MyPasswordInVM\"\n    printf \"\\n\"\n    exit 0\n}\n\nfunction die_var_unset {\n    echo \"ERROR: Variable '$1' is required to be set. Please edit '${build_conf}' and set.\"\n    exit 1\n}\n\n## check that data in build_conf is complete\n[[ -f $build_conf ]] || { echo \"User variables file '$build_conf' not found.\"; exit 1; }\nsource $build_conf\n\n[[ -z \"$vm_default_user\" ]] && die_var_unset \"vm_default_user\"\n[[ -z \"$vm_memory\" ]] && die_var_unset \"vm_memory\"\n[[ -z \"$proxmox_host\" ]] && die_var_unset \"proxmox_host\"\n[[ -z \"$default_vm_id\" ]] && die_var_unset \"default_vm_id\"\n[[ -z \"$iso_url\" ]] && die_var_unset \"iso_url\"\n[[ -z \"$iso_sha256_url\" ]] && die_var_unset \"iso_sha256_url\"\n[[ -z \"$iso_directory\" ]] && die_var_unset \"iso_directory\"\n\n## check that build-mode (proxmox|debug) is passed to script\ntarget=${1:-}\n[[ \"${1}\" == \"proxmox\" ]] || [[ \"${1}\" == \"debug\" ]] || help\n\n## VM ID for new VM template (overrides default from build.conf)\nvm_id=${2:-$default_vm_id}\nprintf \"\\n==> Using VM ID: $vm_id with default user: '$vm_default_user'\\n\"\n\n## template_name is based on name of current directory, check it exists\ntemplate_name=\"${PWD##*/}.json\"\n\n[[ -f $template_name ]] || { echo \"Template (${template_name}) not found.\"; exit 1; }\n\n## check that prerequisites are installed\n[[ $(packer --version)  ]] || { echo \"Please install 'Packer'\"; exit 1; }\n[[ $(ansible --version)  ]] || { echo \"Please install 'Ansible'\"; exit 1; }\n[[ $(j2 --version)  ]] || { echo \"Please install 'j2cli'\"; exit 1; }\n\n## If passwords are not set in env variable, prompt for them\n[[ -z \"$proxmox_password\" ]] && printf \"\\n\" && read -s -p \"Existing PROXMOX Login Password: \" proxmox_password && printf \"\\n\"\nprintf \"\\n\"\n\nif [[ -z \"$ssh_password\" ]]; then\n    while true; do\n        read -s -p \"Enter  new SSH Password: \" ssh_password\n        printf \"\\n\"\n        read -s -p \"Repeat new SSH Password: \" ssh_password2\n        printf \"\\n\"\n        [ \"$ssh_password\" = \"$ssh_password2\" ] && break\n        printf \"Passwords do not match. Please try again!\\n\\n\"\n    done\nfi\n\n[[ -z \"$proxmox_password\" ]] && echo \"The Proxmox Password is required.\" && exit 1\n[[ -z \"$ssh_password\" ]] && echo \"The SSH Password is required.\" && exit 1\n\n## download ISO and Ansible role\nprintf \"\\n=> Downloading and checking ISO\\n\\n\"\niso_filename=$(basename $iso_url)\nwget -P $iso_directory -N $iso_url                  # only re-download when newer on the server\nwget --no-verbose $iso_sha256_url -O $iso_directory/SHA256SUMS  # always download and overwrite\n(cd $iso_directory && cat $iso_directory/SHA256SUMS | grep $iso_filename | sha256sum --check)\nif [ $? -eq 1 ]; then echo \"ISO checksum does not match!\"; exit 1; fi\n\nprintf \"\\n=> Downloading Ansible role\\n\\n\"\n# will always overwrite role to get latest version from Github\nansible-galaxy install --force -p playbook/roles -r playbook/requirements.yml\n[[ -f playbook/roles/ansible-initial-server/tasks/main.yml ]] || { echo \"Ansible role not found.\"; exit 1; }\n\nmkdir -p http\n\n# Debian & Ubuntu\n## Insert the password hashes for root and default user into preseed.cfg using a Jinja2 template\nif [[ -f preseed.cfg.j2 ]]; then\n    password_hash1=$(mkpasswd -R 1000000 -m sha-512 $ssh_password)\n    password_hash2=$(mkpasswd -R 1000000 -m sha-512 $ssh_password)\n    printf \"\\n=> Customizing auto preseed.cfg\\n\"\n    j2 preseed.cfg.j2 > http/preseed.cfg\n    [[ -f http/preseed.cfg ]] || { echo \"Customized preseed.cfg file not found.\"; exit 1; }\nfi\n\n# OpenBSD\n## Insert the password hashes for root and default user into install.conf using a Jinja2 template\nif [[ -f install.conf.j2 ]]; then\n    password_hash1=$(python3 -c \"import os, bcrypt; print(bcrypt.hashpw(os.environ['ssh_password'], bcrypt.gensalt(10)))\")\n    password_hash2=$(python3 -c \"import os, bcrypt; print(bcrypt.hashpw(os.environ['ssh_password'], bcrypt.gensalt(10)))\")\n    printf \"\\n=> Customizing install.conf\\n\"\n    j2 install.conf.j2 > http/install.conf\n    [[ -f http/install.conf ]] || { echo \"Customized install.conf file not found.\"; exit 1; }\nfi\n\nvm_ver=$(git describe --tags)\n\n\n## Call Packer build with the provided data\ncase $target in\n    proxmox)\n        printf \"\\n==> Build and create a Proxmox template.\\n\\n\"\n        ansible_verbosity=\"-v\"\n        packer build $template_name\n        ;;\n    debug)\n        printf \"\\n==> DEBUG: Build and create a Proxmox template.\\n\\n\"\n        ansible_verbosity=\"-vvvv\"\n        PACKER_LOG=1 packer build -debug -on-error=ask $template_name\n        ;;\n    *)\n        help\n        ;;\nesac\n\n## remove file which has the hashed passwords\n[[ -f http/preseed.cfg ]] && printf \"=> \" && rm -v http/preseed.cfg\n[[ -f http/install.conf ]] && printf \"=> \" && rm -v http/install.conf\n"
  },
  {
    "path": "check-functionality.md",
    "content": "# Check the functionality of features\n\n###\n\n### Check that services are enabled\n\n```\n# Debian/Ubuntu\nsystemctl list-unit-files | grep -E 'autogrowpart|ssh-host-keygen'\n\nsystemctl status ssh-host-keygen\nsystemctl status autogrowpart\npstree\n\n# Alpine\nrc-status | grep 'local '\npstree\n\n# OpenBSD\nrcctl ls on\nrcctl ls started\npstree\n```\n\n\n### Check that autogrow partition works (all OS)\n\n- check disk space\n```\ndf -h\npoweroff\n```\n\n- increase disk size in Proxmox and check disk space again\n```\ndf-h\n```\n\n### Check ssh-host-keygen and fingerprint & IP display\n\n- create two clones in Proxmox\n- check fingerprints and IP before login on console\n\n\n###\n- check ssh login\n\n`ssh -p 3XX22 christian@proxmox.lightinasia.site`\n\n### Ansible Playbook\n\n- run the playbook again separately on a clone\n\n### Default VM Numbers\n- 10000 Debian 8\n- 11000 Debian 9\n- 12000 Debian 10\n- 20000 Ubuntu 18.04\n- 21000 Ubuntu 20.04\n- 22000 Ubuntu 22.04\n- 31000 Centos 7\n- 40000 Alpine 3.11\n- 42000 Arch\n- 44000 RancherOS 1.5.5\n- 46000 CoreOS/Flatcar\n- 47000 OpenBSD\n\n### Default [Cloud VM](https://gist.github.com/chriswayg/43fbea910e024cbe608d7dcb12cb8466) Numbers\n- 51000 Debian 8\n- 51100 Debian 9\n- 51200 Debian 10\n- 52000 Ubuntu 18.04\n- 52100 Ubuntu 20.04\n- 52200 Ubuntu 22.04\n- 53100 Centos 7\n- 54000 Alpine 3.11\n- 54200 Arch\n- 54400 RancherOS 1.5.5\n- 54600 CoreOS/Flatcar\n"
  },
  {
    "path": "debian-10-amd64-proxmox/README.md",
    "content": "## [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\n\nStatus: **working well**\n\n- downloads the ISO and places it in Proxmox\n- creates a Proxmox VM\n- builds the image using preseed.cfg and Ansible\n- stores it as a Proxmox Template\n\n### Configurations\n- qemu-guest-agent for Packer SSH and in Proxmox for shutdown and backups\n- haveged random number generator to speed up boot\n- passwordless sudo for default user 'deploy' (name can be changed in build.conf)\n- SSH public key installed for default user\n- display IP and SSH fingerprint before console login\n- generates new SSH host keys on first boot to avoid duplicates in cloned VMs\n- automatically grow partition after resize by Proxmox\n\n### Instructions\n\n- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)\n"
  },
  {
    "path": "debian-10-amd64-proxmox/build.conf",
    "content": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=12000 # default VM ID for Debian\nproxmox_url=https://proxmox.lightinasia.site:8006/api2/json\nproxmox_host=proxmox\n\n# latest version: http://cdimage.debian.org/cdimage/release/current/amd64/iso-cd/\niso_url=http://cdimage.debian.org/cdimage/release/current/amd64/iso-cd/debian-10.4.0-amd64-netinst.iso\niso_sha256_url=https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA256SUMS\niso_directory=/var/lib/vz/template/iso\n"
  },
  {
    "path": "debian-10-amd64-proxmox/debian-10-amd64-proxmox.json",
    "content": "{\n    \"description\": \"Build Debian 10 (buster) x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{{env `proxmox_url`}}\",\n        \"proxmox_username\": \"root@pam\",\n        \"proxmox_password\": \"{{env `proxmox_password`}}\",\n        \"proxmox_host\": \"{{env `proxmox_host`}}\",\n        \"iso_filename\": \"{{env `iso_filename`}}\",\n        \"vm_id\": \"{{env `vm_id`}}\",\n        \"vm_name\": \"deb10-tmpl\",\n        \"template_description\": \"Debian 10 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}\",\n        \"vm_default_user\": \"{{env `vm_default_user`}}\",\n        \"vm_memory\": \"{{env `vm_memory`}}\",\n        \"ssh_username\": \"root\",\n        \"ssh_password\": \"{{env `ssh_password`}}\"\n    },\n    \"sensitive-variables\": [\"proxmox_password\", \"ssh_password\" ],\n    \"provisioners\": [\n      {\n        \"type\": \"ansible\",\n        \"playbook_file\": \"./playbook/server-template.yml\",\n        \"extra_arguments\": [\n          \"{{user `ansible_verbosity`}}\",\n          \"--extra-vars\", \"vm_default_user={{user `vm_default_user`}}\",\n          \"--tags\", \"all,is_template\",\n          \"--skip-tags\", \"openbsd,alpine\"\n        ],\n        \"ansible_env_vars\": [ \"ANSIBLE_CONFIG=./playbook/ansible.cfg\", \"ANSIBLE_FORCE_COLOR=True\" ]\n      }\n    ],\n    \"builders\": [\n        {\n            \"type\": \"proxmox\",\n            \"proxmox_url\":  \"{{user `proxmox_url`}}\",\n            \"insecure_skip_tls_verify\": true,\n            \"username\": \"{{user `proxmox_username`}}\",\n            \"password\": \"{{user `proxmox_password`}}\",\n            \"vm_id\":  \"{{user `vm_id`}}\",\n            \"vm_name\": \"{{user `vm_name`}}\",\n            \"template_description\":\"{{user `template_description`}}\",\n            \"memory\": \"{{user `vm_memory`}}\",\n            \"cores\": \"2\",\n            \"os\": \"l26\",\n            \"http_directory\": \"http\",\n            \"node\": \"{{user `proxmox_host`}}\",\n            \"network_adapters\": [\n              {\n                \"model\": \"virtio\",\n                \"bridge\": \"vmbr1\"\n              }\n            ],\n            \"disks\": [\n              {\n                \"type\": \"scsi\",\n                \"disk_size\": \"8G\",\n                \"storage_pool\": \"local\",\n                \"storage_pool_type\": \"directory\",\n                \"format\": \"qcow2\"\n              }\n            ],\n            \"ssh_username\": \"{{user `ssh_username`}}\",\n            \"ssh_password\": \"{{user `ssh_password`}}\",\n            \"ssh_timeout\": \"15m\",\n            \"iso_file\": \"local:iso/{{user `iso_filename`}}\",\n            \"unmount_iso\": true,\n            \"boot_wait\": \"10s\",\n            \"boot_command\": [\n              \"<esc><wait>\",\n              \"auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<enter>\"\n            ]\n        }\n    ],\n    \"post-processors\": [\n      {\n        \"type\": \"shell-local\",\n        \"inline_shebang\": \"/bin/bash -e\",\n        \"inline\": [\"qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0\"]\n      }\n  ]\n}\n"
  },
  {
    "path": "debian-10-amd64-proxmox/playbook/ansible.cfg",
    "content": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callback = yaml\nroles_path = ./roles\nlog_path = ./logs/server-template.log\n"
  },
  {
    "path": "debian-10-amd64-proxmox/playbook/requirements.yml",
    "content": "- src: https://github.com/chriswayg/ansible-initial-server.git\n  #version: v1.7\n"
  },
  {
    "path": "debian-10-amd64-proxmox/playbook/server-template-vars.yml",
    "content": "---\n\niserver_hostname: deb10-kvm\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local\"\n\niserver_debian_repos:\n  - deb http://repo.myloc.de/debian buster main non-free contrib\n  - deb-src http://repo.myloc.de/debian buster main non-free contrib\n  - deb http://security.debian.org/debian-security buster/updates main contrib non-free\n  - deb-src http://security.debian.org/debian-security buster/updates main contrib non-free\n  - deb http://deb.debian.org/debian buster-updates main contrib non-free\n  - deb-src http://deb.debian.org/debian buster-updates main contrib non-free\n"
  },
  {
    "path": "debian-10-amd64-proxmox/playbook/server-template.yml",
    "content": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json config for this provisioner.\n# https://www.packer.io/docs/provisioners/ansible.html\n\n# TODO: For unclear reasons, I could only get it to work with the root user in Packer\n# 'become' in playbook or role tasks seem to be ignored by Packer Ansible\n\n- name: Initial configuration of a server.\n  hosts: all\n  vars_files:\n    - server-template-vars.yml\n  roles:\n    - role: ansible-initial-server\n      vars:\n        iserver_user: \"{{ vm_default_user }}\"\n"
  },
  {
    "path": "debian-10-amd64-proxmox/preseed.cfg.j2",
    "content": "#### Preseed template-file for Debian 10 buster\n# Docs: - https://www.debian.org/releases/stable/amd64/apb.en.html\n#       - https://www.debian.org/releases/buster/example-preseed.txt\n#       - Notes: Debian 10 auto-install from ISO using preseed.cfg\n\n### Localization\n# Locale sets language and country.\nd-i debian-installer/locale string en_US.utf8\n# Keyboard selection.\nd-i keyboard-configuration/xkb-keymap select us\n\n### Mirror settings\nd-i mirror/country string manual\nd-i mirror/http/hostname string http.us.debian.org\nd-i mirror/http/directory string /debian\nd-i mirror/http/proxy string\n\n### Clock and time zone setup\n# Controls whether or not the hardware clock is set to UTC.\nd-i clock-setup/utc boolean true\n# see ls -R  /usr/share/zoneinfo/ for valid values.\nd-i time/zone string UTC\n\n### Partitioning\n# This creates an unencrypted primary ext4 partition without swap.\nd-i partman-auto/disk string /dev/sda\nd-i partman-auto/method string regular\nd-i partman-auto/choose_recipe select unencrypted-install\nd-i partman-basicfilesystems/no_swap boolean false\nd-i partman-auto/expert_recipe string \\\n        root :: \\\n                8190 100000 -1 ext4 \\\n                        $primary{ } $bootable{ } \\\n                        method{ format } format{ } \\\n                        use_filesystem{ } filesystem{ ext4 } \\\n                        mountpoint{ / } \\\n                .\nd-i partman-partitioning/confirm_write_new_label boolean true\nd-i partman/choose_partition select finish\nd-i partman/confirm boolean true\nd-i partman/confirm_nooverwrite boolean true\n\n### Account setup\n# Default user '{{ env(\"vm_default_user\") }}'\nd-i passwd/root-login boolean true\nd-i passwd/user-fullname string {{ env(\"vm_default_user\") }}\nd-i passwd/username string {{ env(\"vm_default_user\") }}\nd-i user-setup/encrypt-home boolean false\n# Encrypted root and user passwords\nd-i passwd/root-password-crypted password {{ env(\"password_hash1\") }}\nd-i passwd/user-password-crypted password {{ env(\"password_hash2\") }}\n\n### Apt setup\n# prevent the installer from asking about scanning another CD\napt-cdrom-setup apt-setup/cdrom/set-first boolean false\n\n### Package selection\ntasksel tasksel/first multiselect ssh-server, standard system utilities\n# Full upgrade packages after debootstrap and unattended upgrades\nd-i pkgsel/upgrade select full-upgrade\nd-i pkgsel/update-policy select unattended-upgrades\n# Individual additional packages to install\n# - qemu-guest-agent for Packer and Proxmox; haveged random generator speeds up boot\nd-i pkgsel/include string openssh-server sudo qemu-guest-agent haveged python-apt\nd-i pkgsel/install-language-support boolean false\n# Do not report back on what software is installed, and what software is used\npopularity-contest popularity-contest/participate boolean false\n\n### Boot loader installation\nd-i grub-installer/bootdev string /dev/sda\n\n### Run custom commands during the installation\nd-i preseed/late_command string sed -i '/^deb cdrom:/s/^/#/' /target/etc/apt/sources.list\n# Enable passwordless sudo for default user and permit root login for Packer Ansible provisioner to work\nd-i preseed/late_command string \\\n    echo '{{ env(\"vm_default_user\") }}  ALL=(ALL:ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/default-user && chmod 440 /target/etc/sudoers.d/default-user && \\\n    sed -i \"/^#PermitRootLogin/c\\PermitRootLogin yes\" /target/etc/ssh/sshd_config\n\n### Finishing up the installation\n# Avoid that last message about the install being complete.\nd-i finish-install/reboot_in_progress note\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/README.md",
    "content": "## OpenBSD 6.6 Packer Template using [Packer Proxmox Builder](https://www.packer.io/docs/builders/proxmox.html) to build a Proxmox KVM image template\n\nStatus: **working well**\n\n- downloads the ISO and places it in Proxmox\n- creates a Proxmox VM\n- builds the image using install.conf and Ansible\n- stores it as a Proxmox Template\n\n### Configurations\n- there is no qemu guest agent for Packer SSH, therefore we use a static local IP during installation via Packer\n- passwordless doas for default user 'deploy' (name can be changed in build.conf)\n- SSH public key installed for default user\n- display IP and SSH fingerprint before console login (not yet implemented)\n- generates new SSH host keys on first boot to avoid duplicates in cloned VMs\n- OpenBSD has no cloud utils with growpart to automatically grow partition after resize by Proxmox\n\n### Instructions\n\n- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/build.conf",
    "content": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=47000 # default VM ID for OpenBSD\nproxmox_url=https://proxmox.lightinasia.site:8006/api2/json\nproxmox_host=proxmox\n\niso_url=https://cloudflare.cdn.openbsd.org/pub/OpenBSD/6.6/amd64/install66.iso\niso_sha256_url=https://cloudflare.cdn.openbsd.org/pub/OpenBSD/6.6/amd64/SHA256\niso_directory=/var/lib/vz/template/iso\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/install.conf.j2",
    "content": "System hostname = openbsd\nIPv4 address for vio0 = 10.10.10.252\nDefault IPv4 route = 10.10.10.1\nDNS nameservers = 1.1.1.1 1.0.0.1\nPassword for root account = {{ env(\"password_hash1\") }}\nDo you expect to run the X Window System = no\nSetup a user = {{ env(\"vm_default_user\") }}\nPassword for user {{ env(\"vm_default_user\") }} = {{ env(\"password_hash2\") }}\nAllow root ssh login = yes\n# Set name(s) = -comp* -game* -x*\nDirectory does not contain SHA256.sig. Continue without verification = yes\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/install.conf.j2.test",
    "content": "System hostname = openbsd\nIPv4 address for vio0 = 10.10.10.252\nDefault IPv4 route = 10.10.10.1\n DNS nameservers = 1.1.1.1 1.0.0.1\nPassword for root account = {{ env(\"password_hash1\") }}\nDo you expect to run the X Window System = no\nSetup a user = christian\nPassword for user christian = {{ env(\"password_hash2\") }}\nAllow root ssh login = yes\nSet name(s) = -comp* -game* -x*\nDirectory does not contain SHA256.sig. Continue without verification = yes\n\n# use a static IP for SSH from packer, then switch back to dhcp for template\n\nSystem hostname = openbsd\nWhich network interface do you wish to configure = vio0\nIPv4 address for vio0 = dhcp\nIPv6 address for vio0 = none\nWhich network interface do you wish to configure = done\nPublic ssh key for root account = none\nStart sshd(8) by default = yes\nDo you expect to run the X Window System = no\nSetup a user = no\nAllow root ssh login = yes\nWhat timezone are you in = Asia/Manila\nWhich disk is the root disk = sd0\nUse (W)hole disk MBR, whole disk (G)PT or (E)dit = whole\nURL to autopartitioning template for disklabel = none\nUse (A)uto layout, (E)dit auto layout, or create (C)ustom layout = a\nLocation of sets = cd0\nPathname to the sets = 6.5/amd64\nSet name(s) = -comp* -game* -x*\nSet name(s) = done\nDirectory does not contain SHA256.sig. Continue without verification = yes\nLocation of sets = done\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/openbsd-6-amd64-proxmox.json",
    "content": "{\n    \"description\": \"Build OpenBSD 6 x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{{env `proxmox_url`}}\",\n        \"proxmox_username\": \"root@pam\",\n        \"proxmox_password\": \"{{env `proxmox_password`}}\",\n        \"proxmox_host\": \"{{env `proxmox_host`}}\",\n        \"iso_filename\": \"{{env `iso_filename`}}\",\n        \"vm_id\": \"{{env `vm_id`}}\",\n        \"vm_name\": \"openbsd6-tmpl\",\n        \"template_description\": \"OpenBSD 6 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}\",\n        \"vm_default_user\": \"{{env `vm_default_user`}}\",\n        \"vm_memory\": \"{{env `vm_memory`}}\",\n        \"ssh_username\": \"root\",\n        \"ssh_password\": \"{{env `ssh_password`}}\",\n        \"ansible_verbosity\":\"{{env `ansible_verbosity`}}\"\n    },\n    \"sensitive-variables\": [\"proxmox_password\", \"ssh_password\" ],\n    \"provisioners\": [\n      {\n        \"type\": \"ansible\",\n        \"playbook_file\": \"./playbook/server-template.yml\",\n        \"extra_arguments\": [\n          \"{{user `ansible_verbosity`}}\",\n          \"--extra-vars\", \"vm_default_user={{user `vm_default_user`}}\",\n          \"--tags\", \"all,is_template\",\n          \"--skip-tags\", \"debuntu,alpine\"\n        ],\n        \"ansible_env_vars\": [ \"ANSIBLE_CONFIG=./playbook/ansible.cfg\", \"ANSIBLE_FORCE_COLOR=True\" ]\n      }\n    ],\n    \"builders\": [\n        {\n            \"type\": \"proxmox\",\n            \"proxmox_url\":  \"{{user `proxmox_url`}}\",\n            \"insecure_skip_tls_verify\": true,\n            \"username\": \"{{user `proxmox_username`}}\",\n            \"password\": \"{{user `proxmox_password`}}\",\n            \"vm_id\":  \"{{user `vm_id`}}\",\n            \"vm_name\": \"{{user `vm_name`}}\",\n            \"template_description\":\"{{user `template_description`}}\",\n            \"memory\": \"{{user `vm_memory`}}\",\n            \"cores\": \"2\",\n            \"os\": \"other\",\n            \"http_directory\": \"http\",\n\n            \"node\": \"{{user `proxmox_host`}}\",\n            \"network_adapters\": [\n              {\n                \"model\": \"virtio\",\n                \"bridge\": \"vmbr1\"\n              }\n            ],\n            \"disks\": [\n              {\n                \"type\": \"scsi\",\n                \"disk_size\": \"8G\",\n                \"storage_pool\": \"local\",\n                \"storage_pool_type\": \"directory\",\n                \"format\": \"qcow2\"\n              }\n            ],\n            \"ssh_username\": \"{{user `ssh_username`}}\",\n            \"ssh_password\": \"{{user `ssh_password`}}\",\n            \"ssh_timeout\": \"15m\",\n            \"ssh_host\": \"10.10.10.252\",\n            \"qemu_agent\": false,\n            \"iso_file\": \"local:iso/{{user `iso_filename`}}\",\n            \"unmount_iso\": true,\n            \"boot_wait\": \"30s\",\n            \"boot_command\": [\n              \"a<enter><wait>\",\n              \"<wait5>\",\n              \"http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.conf<enter><wait>\",\n              \"<wait5>\",\n              \"i<enter><wait>\"\n            ]\n        }\n    ],\n    \"post-processors\": [\n      {\n        \"type\": \"shell-local\",\n        \"inline_shebang\": \"/bin/bash -e\",\n        \"inline\": [\"qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0\"]\n      }\n  ]\n}\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/ansible.cfg",
    "content": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callback = yaml\nroles_path = ./roles\nlog_path = ./logs/server-template.log\ninventory = ./hosts\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/hosts",
    "content": "[servers]\n\nOpenBSD ansible_host=10.10.10.252 ansible_port=22\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/requirements.yml",
    "content": "- src: https://github.com/chriswayg/ansible-initial-server.git\n  #version: v1.7\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/server-template-vars.yml",
    "content": "---\n\niserver_hostname: openbsd6\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local\"\n"
  },
  {
    "path": "openbsd-6-amd64-proxmox/playbook/server-template.yml",
    "content": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json config for this provisioner.\n# https://www.packer.io/docs/provisioners/ansible.html\n\n# TODO: For unclear reasons, I could only get it to work with the root user in Packer\n# 'become' in playbook or role tasks seem to be ignored by Packer Ansible\n\n- name: Prepare OpenBSD for Ansible.\n  hosts: all\n  gather_facts: False\n  tasks:\n    - name: Ensure, that python is installed.\n      raw: pkg_add -z python-2.7\n\n    - name: Ensure that python 2 is linked to /usr/bin/python.\n      raw: ln -sf /usr/local/bin/python2.7 /usr/bin/python\n\n- name: Initial configuration of a server.\n  hosts: all\n  vars_files:\n    - server-template-vars.yml\n  roles:\n    - role: ansible-initial-server\n      vars:\n        iserver_user: \"{{ vm_default_user }}\"\n        iserver_become: su\n"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/README.md",
    "content": "## [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\n\nStatus: **working well** \n\n- downloads the ISO and places it in Proxmox\n- creates a Proxmox VM\n- builds the image using preseed.cfg and Ansible\n- stores it as a Proxmox Template\n\n### Configurations\n- qemu-guest-agent for Packer SSH and in Proxmox for shutdown and backups\n- haveged random number generator to speed up boot\n- passwordless sudo for default user 'deploy' (name can be changed in build.conf)\n- SSH public key installed for default user\n- display IP and SSH fingerprint before console login\n- generates new SSH host keys on first boot to avoid duplicates in cloned VMs\n- automatically grow partition after resize by Proxmox\n\n### Instructions\n\n- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)\n"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/build.conf",
    "content": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=20000 # default VM ID for Ubuntu\nproxmox_url=https://proxmox.lightinasia.site:8006/api2/json\nproxmox_host=proxmox\n\niso_url=http://cdimage.ubuntu.com/releases/18.04.4/release/ubuntu-18.04.4-server-amd64.iso\niso_sha256_url=http://cdimage.ubuntu.com/releases/18.04.4/release/SHA256SUMS\niso_directory=/var/lib/vz/template/iso\n"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/playbook/ansible.cfg",
    "content": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callback = yaml\nroles_path = ./roles\nlog_path = ./logs/server-template.log\n\n[ssh_connection]\npipelining = True\n"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/playbook/requirements.yml",
    "content": "- 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",
    "content": "---\n\niserver_hostname: ubuntu1804-kvm\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local\"\n\niserver_ubuntu_repos:\n  - deb http://repo.myloc.de/ubuntu/ bionic main restricted universe multiverse\n  - deb-src http://repo.myloc.de/ubuntu/ bionic main restricted universe multiverse\n  - deb http://repo.myloc.de/ubuntu/ bionic-updates main restricted universe multiverse\n  - deb-src http://repo.myloc.de/ubuntu/ bionic-updates main restricted universe multiverse\n  - deb http://repo.myloc.de/ubuntu/ bionic-backports main restricted universe multiverse\n  - deb-src http://repo.myloc.de/ubuntu/ bionic-backports main restricted universe multiverse\n  - deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse\n  - deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse\n"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/playbook/server-template.yml",
    "content": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json config for this provisioner.\n# https://www.packer.io/docs/provisioners/ansible.html\n\n# TODO: For unclear reasons, I could only get it to work with the root user in Packer.\n# 'become' in playbook or role tasks seems to be ignored by Packer Ansible\n\n- name: Initial configuration of a server.\n  hosts: all\n  vars_files:\n    - server-template-vars.yml\n  roles:\n    - role: ansible-initial-server\n      vars:\n        iserver_user: \"{{ vm_default_user }}\"\n"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/preseed.cfg.j2",
    "content": "#### Preseed file for Ubuntu 18.04 bionic\n# Docs: - https://help.ubuntu.com/lts/installation-guide/amd64/apbs01.html\n#       - https://help.ubuntu.com/18.04/installation-guide/example-preseed.txt\n\n### Localization\n# Locale sets language and country.\nd-i debian-installer/locale string en_US.utf8\n# Keyboard selection.\nd-i keyboard-configuration/xkb-keymap select us\n\n### Mirror settings\nd-i mirror/country string manual\nd-i mirror/http/hostname string archive.ubuntu.com\nd-i mirror/http/directory string /ubuntu\nd-i mirror/http/proxy string\n\n### Clock and time zone setup\n# Controls whether or not the hardware clock is set to UTC.\nd-i clock-setup/utc boolean true\n# see ls -R  /usr/share/zoneinfo/ for valid values.\nd-i time/zone string UTC\n\n### Partitioning\n# This creates an unencrypted primary ext4 partition without swap.\nd-i partman-auto/disk string /dev/sda\nd-i partman-auto/method string regular\nd-i partman-auto/choose_recipe select unencrypted-install\nd-i partman-basicfilesystems/no_swap boolean false\nd-i partman-auto/expert_recipe string \\\n        root :: \\\n                8190 100000 -1 ext4 \\\n                        $primary{ } $bootable{ } \\\n                        method{ format } format{ } \\\n                        use_filesystem{ } filesystem{ ext4 } \\\n                        mountpoint{ / } \\\n                .\nd-i partman-partitioning/confirm_write_new_label boolean true\nd-i partman/choose_partition select finish\nd-i partman/confirm boolean true\nd-i partman/confirm_nooverwrite boolean true\n\n### Account setup\n# Default user '{{ env(\"vm_default_user\") }}'\nd-i passwd/root-login boolean true\nd-i passwd/user-fullname string {{ env(\"vm_default_user\") }}\nd-i passwd/username string {{ env(\"vm_default_user\") }}\nd-i user-setup/encrypt-home boolean false\n# Encrypted root and user passwords\nd-i passwd/root-password-crypted password {{ env(\"password_hash1\") }}\nd-i passwd/user-password-crypted password {{ env(\"password_hash2\") }}\n\n### Package selection\ntasksel tasksel/first multiselect standard, server\n# Full upgrade packages after debootstrap and unattended upgrades\nd-i pkgsel/upgrade select full-upgrade\nd-i pkgsel/update-policy select unattended-upgrades\n# Individual additional packages to install\n# - qemu-guest-agent needed for packer; better random generator speeds up boot\nd-i pkgsel/include string openssh-server sudo qemu-guest-agent haveged python-apt\nd-i pkgsel/install-language-support boolean false\n# Do not report back on what software is installed, and what software is used\npopularity-contest popularity-contest/participate boolean false\n\n### Boot loader installation\nd-i grub-installer/bootdev string /dev/sda\n\n### Run custom commands during the installation\n# Enable passwordless sudo for default user and permit root login for Packer Ansible provisioner to work\nd-i preseed/late_command string \\\n    echo '{{ env(\"vm_default_user\") }}  ALL=(ALL:ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/default-user && chmod 440 /target/etc/sudoers.d/default-user && \\\n    sed -i \"/^#PermitRootLogin/c\\PermitRootLogin yes\" /target/etc/ssh/sshd_config\n\n### Finishing up the installation\n# Avoid that last message about the install being complete.\nd-i finish-install/reboot_in_progress note\n"
  },
  {
    "path": "ubuntu-18.04-amd64-proxmox/ubuntu-18.04-amd64-proxmox.json",
    "content": "{\n    \"description\": \"Build Ubuntu 18.04 (bionic) x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{{env `proxmox_url`}}\",\n        \"proxmox_username\": \"root@pam\",\n        \"proxmox_password\": \"{{env `proxmox_password`}}\",\n        \"proxmox_host\": \"{{env `proxmox_host`}}\",\n        \"iso_filename\": \"{{env `iso_filename`}}\",\n        \"vm_id\": \"{{env `vm_id`}}\",\n        \"vm_name\": \"ubuntu1804-tmpl\",\n        \"template_description\": \"Ubuntu 18.04 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}\",\n        \"vm_default_user\": \"{{env `vm_default_user`}}\",\n        \"vm_memory\": \"{{env `vm_memory`}}\",\n        \"ssh_username\": \"root\",\n        \"ssh_password\": \"{{env `ssh_password`}}\"\n    },\n    \"sensitive-variables\": [\"proxmox_password\", \"ssh_password\" ],\n    \"provisioners\": [\n      {\n        \"type\": \"ansible\",\n        \"playbook_file\": \"./playbook/server-template.yml\",\n        \"extra_arguments\": [\n          \"{{user `ansible_verbosity`}}\",\n          \"--extra-vars\", \"vm_default_user={{user `vm_default_user`}}\",\n          \"--tags\", \"all,is_template\",\n          \"--skip-tags\", \"openbsd,alpine\"\n        ],\n        \"ansible_env_vars\": [ \"ANSIBLE_CONFIG=./playbook/ansible.cfg\", \"ANSIBLE_FORCE_COLOR=True\" ]\n      }\n    ],\n    \"builders\": [\n        {\n            \"type\": \"proxmox\",\n            \"proxmox_url\":  \"{{user `proxmox_url`}}\",\n            \"insecure_skip_tls_verify\": true,\n            \"username\": \"{{user `proxmox_username`}}\",\n            \"password\": \"{{user `proxmox_password`}}\",\n            \"vm_id\":  \"{{user `vm_id`}}\",\n            \"vm_name\": \"{{user `vm_name`}}\",\n            \"template_description\":\"{{user `template_description`}}\",\n            \"memory\": \"{{user `vm_memory`}}\",\n            \"cores\": \"2\",\n            \"os\": \"l26\",\n            \"http_directory\": \"http\",\n\n            \"node\": \"{{user `proxmox_host`}}\",\n            \"network_adapters\": [\n              {\n                \"model\": \"virtio\",\n                \"bridge\": \"vmbr1\"\n              }\n            ],\n            \"disks\": [\n              {\n                \"type\": \"scsi\",\n                \"disk_size\": \"8G\",\n                \"storage_pool\": \"local\",\n                \"storage_pool_type\": \"directory\",\n                \"format\": \"qcow2\"\n              }\n            ],\n            \"ssh_username\": \"{{user `ssh_username`}}\",\n            \"ssh_password\": \"{{user `ssh_password`}}\",\n            \"ssh_timeout\": \"15m\",\n            \"iso_file\": \"local:iso/{{user `iso_filename`}}\",\n            \"unmount_iso\": true,\n            \"boot_wait\": \"10s\",\n            \"boot_command\": [\n              \"<esc><wait>\",\n              \"<esc><wait>\",\n              \"<enter><wait>\",\n              \"/install/vmlinuz initrd=/install/initrd.gz\",\n              \" auto=true priority=critical\",\n              \" url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg\",\n              \"<enter>\"\n            ]\n        }\n    ],\n    \"post-processors\": [\n      {\n        \"type\": \"shell-local\",\n        \"inline_shebang\": \"/bin/bash -e\",\n        \"inline\": [\"qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0\"]\n      }\n  ]\n}\n"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/README.md",
    "content": "## [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\n\nStatus: **working well** \n\n- downloads the ISO and places it in Proxmox\n- creates a Proxmox VM\n- builds the image using preseed.cfg and Ansible\n- stores it as a Proxmox Template\n\n### Configurations\n- qemu-guest-agent for Packer SSH and in Proxmox for shutdown and backups\n- haveged random number generator to speed up boot\n- passwordless sudo for default user 'deploy' (name can be changed in build.conf)\n- SSH public key installed for default user\n- display IP and SSH fingerprint before console login\n- generates new SSH host keys on first boot to avoid duplicates in cloned VMs\n- automatically grow partition after resize by Proxmox\n\n### Instructions\n\n- [REAMDE with Prerequisites and Usage](https://github.com/chriswayg/packer-proxmox-templates/blob/master/README.md)\n"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/build.conf",
    "content": "vm_default_user=christian\nvm_memory=1024\ndefault_vm_id=21000 # default VM ID for Ubuntu\nproxmox_url=https://proxmox.lightinasia.site:8006/api2/json\nproxmox_host=proxmox\n\niso_url=http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/ubuntu-20.04-legacy-server-amd64.iso\niso_sha256_url=http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/SHA256SUMS\niso_directory=/var/lib/vz/template/iso\n"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/playbook/ansible.cfg",
    "content": "[defaults]\ndeprecation_warnings = False\nhost_key_checking = False\ncallback_whitelist = timer, profile_roles\nstdout_callback = yaml\nroles_path = ./roles\nlog_path = ./logs/server-template.log\n\n[ssh_connection]\npipelining = True\n"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/playbook/requirements.yml",
    "content": "- 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",
    "content": "---\n\niserver_hostname: ubuntu2004-kvm\niserver_sshkey: \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK1zNq5zsVbbN/gLdYqxlb5CROsR1dBNBgRFzzCJUL3ncU2dDHLHWi0L/FafwWt6MQ7vePu7catLDegY2fs1QB0KYvy21fD3+9ONBs7KcFlmuyqjLJ9VAoLWW5Tv3I9eZNgpd9k6CvYphKa1Owq43ye+quQRI4J+2nb7Zhl2WTQ1N2WBwZbmf0ErTHwa+mC7frTRBYh6ddyXp9KRULH89y/6cVpL6uQyFzIr6yWowUbJ8lX3fA9e7RAxkG76X54sMa65oq3Bog04ylJ4n/xZCXO449BZjAZHcJuDcFLXrwIo52t+Q6gIEnXInTiii26/ZWbnzzheggjkpQ77tCg03t christian@Chris-GigaMac.local\"\n\niserver_ubuntu_repos:\n  - deb http://repo.myloc.de/ubuntu/ focal main restricted universe multiverse\n  - deb-src http://repo.myloc.de/ubuntu/ focal main restricted universe multiverse\n  - deb http://repo.myloc.de/ubuntu/ focal-updates main restricted universe multiverse\n  - deb-src http://repo.myloc.de/ubuntu/ focal-updates main restricted universe multiverse\n  - deb http://repo.myloc.de/ubuntu/ focal-backports main restricted universe multiverse\n  - deb-src http://repo.myloc.de/ubuntu/ focal-backports main restricted universe multiverse\n  - deb http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse\n  - deb-src http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse\n"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/playbook/server-template.yml",
    "content": "---\n# Any remote_user defined in tasks will be ignored.\n# Packer will always connect with the user given in the json config for this provisioner.\n# https://www.packer.io/docs/provisioners/ansible.html\n\n# TODO: For unclear reasons, I could only get it to work with the root user in Packer.\n# 'become' in playbook or role tasks seems to be ignored by Packer Ansible\n\n- name: Initial configuration of a server.\n  hosts: all\n  vars_files:\n    - server-template-vars.yml\n  roles:\n    - role: ansible-initial-server\n      vars:\n        iserver_user: \"{{ vm_default_user }}\"\n"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/preseed.cfg.j2",
    "content": "#### Preseed file for Ubuntu 20.04 focal\n# Docs: - https://help.ubuntu.com/lts/installation-guide/amd64/apbs01.html\n#       - https://help.ubuntu.com/20.04/installation-guide/example-preseed.txt\n\n### Localization\n# Locale sets language and country.\nd-i debian-installer/locale string en_US.utf8\n# Keyboard selection.\nd-i keyboard-configuration/xkb-keymap select us\n\n### Mirror settings\nd-i mirror/country string manual\nd-i mirror/http/hostname string archive.ubuntu.com\nd-i mirror/http/directory string /ubuntu\nd-i mirror/http/proxy string\n\n### Clock and time zone setup\n# Controls whether or not the hardware clock is set to UTC.\nd-i clock-setup/utc boolean true\n# see ls -R  /usr/share/zoneinfo/ for valid values.\nd-i time/zone string UTC\n\n### Partitioning\n# This creates an unencrypted primary ext4 partition without swap.\nd-i partman-auto/disk string /dev/sda\nd-i partman-auto/method string regular\nd-i partman-auto/choose_recipe select unencrypted-install\nd-i partman-basicfilesystems/no_swap boolean false\nd-i partman-auto/expert_recipe string \\\n        root :: \\\n                8190 100000 -1 ext4 \\\n                        $primary{ } $bootable{ } \\\n                        method{ format } format{ } \\\n                        use_filesystem{ } filesystem{ ext4 } \\\n                        mountpoint{ / } \\\n                .\nd-i partman-partitioning/confirm_write_new_label boolean true\nd-i partman/choose_partition select finish\nd-i partman/confirm boolean true\nd-i partman/confirm_nooverwrite boolean true\n\n### Account setup\n# Default user '{{ env(\"vm_default_user\") }}'\nd-i passwd/root-login boolean true\nd-i passwd/user-fullname string {{ env(\"vm_default_user\") }}\nd-i passwd/username string {{ env(\"vm_default_user\") }}\nd-i user-setup/encrypt-home boolean false\n# Encrypted root and user passwords\nd-i passwd/root-password-crypted password {{ env(\"password_hash1\") }}\nd-i passwd/user-password-crypted password {{ env(\"password_hash2\") }}\n\n### Package selection\ntasksel tasksel/first multiselect standard, server\n# Full upgrade packages after debootstrap and unattended upgrades\nd-i pkgsel/upgrade select full-upgrade\nd-i pkgsel/update-policy select unattended-upgrades\n# Individual additional packages to install\n# - qemu-guest-agent needed for packer; better random generator speeds up boot\nd-i pkgsel/include string openssh-server sudo qemu-guest-agent haveged python-apt\nd-i pkgsel/install-language-support boolean false\n# Do not report back on what software is installed, and what software is used\npopularity-contest popularity-contest/participate boolean false\n\n### Boot loader installation\nd-i grub-installer/bootdev string /dev/sda\n\n### Run custom commands during the installation\n# Enable passwordless sudo for default user and permit root login for Packer Ansible provisioner to work\nd-i preseed/late_command string \\\n    echo '{{ env(\"vm_default_user\") }}  ALL=(ALL:ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/default-user && chmod 440 /target/etc/sudoers.d/default-user && \\\n    sed -i \"/^#PermitRootLogin/c\\PermitRootLogin yes\" /target/etc/ssh/sshd_config\n\n### Finishing up the installation\n# Avoid that last message about the install being complete.\nd-i finish-install/reboot_in_progress note\n"
  },
  {
    "path": "ubuntu-20.04-amd64-proxmox/ubuntu-20.04-amd64-proxmox.json",
    "content": "{\n    \"description\": \"Build Ubuntu 20.04 (focal) x86_64 Proxmox template\",\n    \"variables\": {\n        \"proxmox_url\": \"{{env `proxmox_url`}}\",\n        \"proxmox_username\": \"root@pam\",\n        \"proxmox_password\": \"{{env `proxmox_password`}}\",\n        \"proxmox_host\": \"{{env `proxmox_host`}}\",\n        \"iso_filename\": \"{{env `iso_filename`}}\",\n        \"vm_id\": \"{{env `vm_id`}}\",\n        \"vm_name\": \"ubuntu2004-tmpl\",\n        \"template_description\": \"Ubuntu 20.04 x86_64 template built with packer ({{env `vm_ver`}}). Username: {{env `vm_default_user`}}\",\n        \"vm_default_user\": \"{{env `vm_default_user`}}\",\n        \"vm_memory\": \"{{env `vm_memory`}}\",\n        \"ssh_username\": \"root\",\n        \"ssh_password\": \"{{env `ssh_password`}}\"\n    },\n    \"sensitive-variables\": [\"proxmox_password\", \"ssh_password\" ],\n    \"provisioners\": [\n      {\n        \"type\": \"ansible\",\n        \"playbook_file\": \"./playbook/server-template.yml\",\n        \"extra_arguments\": [\n          \"{{user `ansible_verbosity`}}\",\n          \"--extra-vars\", \"vm_default_user={{user `vm_default_user`}}\",\n          \"--tags\", \"all,is_template\",\n          \"--skip-tags\", \"openbsd,alpine\"\n        ],\n        \"ansible_env_vars\": [ \"ANSIBLE_CONFIG=./playbook/ansible.cfg\", \"ANSIBLE_FORCE_COLOR=True\" ]\n      }\n    ],\n    \"builders\": [\n        {\n            \"type\": \"proxmox\",\n            \"proxmox_url\":  \"{{user `proxmox_url`}}\",\n            \"insecure_skip_tls_verify\": true,\n            \"username\": \"{{user `proxmox_username`}}\",\n            \"password\": \"{{user `proxmox_password`}}\",\n            \"vm_id\":  \"{{user `vm_id`}}\",\n            \"vm_name\": \"{{user `vm_name`}}\",\n            \"template_description\":\"{{user `template_description`}}\",\n            \"memory\": \"{{user `vm_memory`}}\",\n            \"cores\": \"2\",\n            \"os\": \"l26\",\n            \"http_directory\": \"http\",\n\n            \"node\": \"{{user `proxmox_host`}}\",\n            \"network_adapters\": [\n              {\n                \"model\": \"virtio\",\n                \"bridge\": \"vmbr1\"\n              }\n            ],\n            \"disks\": [\n              {\n                \"type\": \"scsi\",\n                \"disk_size\": \"8G\",\n                \"storage_pool\": \"local\",\n                \"storage_pool_type\": \"directory\",\n                \"format\": \"qcow2\"\n              }\n            ],\n            \"ssh_username\": \"{{user `ssh_username`}}\",\n            \"ssh_password\": \"{{user `ssh_password`}}\",\n            \"ssh_timeout\": \"15m\",\n            \"iso_file\": \"local:iso/{{user `iso_filename`}}\",\n            \"unmount_iso\": true,\n            \"boot_wait\": \"10s\",\n            \"boot_command\": [\n              \"<esc><wait>\",\n              \"<esc><wait>\",\n              \"<enter><wait>\",\n              \"/install/vmlinuz initrd=/install/initrd.gz\",\n              \" auto=true priority=critical\",\n              \" url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg\",\n              \"<enter>\"\n            ]\n        }\n    ],\n    \"post-processors\": [\n      {\n        \"type\": \"shell-local\",\n        \"inline_shebang\": \"/bin/bash -e\",\n        \"inline\": [\"qm set {{user `vm_id`}} --scsihw virtio-scsi-pci --serial0 socket --vga serial0\"]\n      }\n  ]\n}\n"
  }
]