added readme file

parent 2662eed1
### Pre-requisites
- Internal DNS and DHCP
- Proxmox VE 6.x host (tested on PVE 6.1-8)
- Linux control host - to run Terraform, Ansible and SSH connection to Proxmox and virtual machines
- SSH with key pair authentication to Proxmox host - [Generate SSH key pair](#generate-ssh-key-pair)
- Terraform binaries - i.e. [Download](https://www.terraform.io/downloads.html) binary and copy to `/usr/bin/`
- Ansible - i.e. `sudo apt install ansible`
- Cloud-init template - [Create cloud-init template](#create-cloud-init-template)
- Terraform provider and pluging binaries - [Install Terraform provider](#install-terraform-provider--plugin)
- If using Azure Key Vault and Storage:
- Install Azure CLI - i.e. [Install Azure CLI with apt](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-apt?view=azure-cli-latest)
- Create Azure Key Vault and Secret
- Create Azure Storage account and Container
### To get started
**Make sure all pre-requisites are met or configured correctly**
- Clone this repository `git clone [email protected]:itnoobs-automation/packer/proxmox-template.git`
- Run `az login` and sign into your account
- Change `pm_api_url` value to match your environment
- Run
- `terraform init` There should be no errors
- `terraform plan -out plan` Review, change and re-run as necessary
- `terraform apply plan`
### Create cloud-init template
**follow official Proxmox [documentation](https://pve.proxmox.com/wiki/Cloud-Init_Support)**
Example below creates a cloud-init template from latest Ubuntu 20.04 image:
- copy the link to the latest Ubuntu cloud-init image file http://cloud-images.ubuntu.com/focal/current/
- SSH into your Proxmox host
- `sudo su`
- `apt-get install cloud-init`
- `wget http://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img`
- `qm importdisk 9000 focal-server-cloudimg-amd64.img local-lvm` *local-lvm* can be change to any other storage device
- `qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr0 --sockets 2 --cores 8 --vcpu 4 --numa 1 -hotplug network,disk,cpu,memory --agent 1 --pool Templates --name cloud-init-focal --ostype l26`
- `qm set 9000 --scsihw virtio-scsi-pci --virtio0 local-lvm:vm-9000-disk-0`
- `qm set 9000 --ide2 local-lvm:cloudinit`
- `qm set 9000 --boot c --bootdisk virtio0`
- `qm set 9000 --serial0 socket`
- `qm template 9000`
### Generate SSH key pair
Example below generate SSH key pair and installs public key on remote host:
- Generate key pair `ssh-keygen`
- Add public key to the remote host `ssh-copy-id -i ~/.ssh/id_rsa.pub <username>@<hostname>`
- Add private key to SSH session ```eval `ssh-agent` && ssh-add -i ~/.ssh/id_rsa```
- Log in without password authentication `ssh <username>@<hostname>`
### Install Terraform provider & plugin
**follow official Proxmox [documentation](https://github.com/Telmate/terraform-provider-proxmox/blob/master/docs/installation.md)**
For example you can do this on Ubuntu:
- Install Go `sudo apt install go`
- Clone provider repository `git clone https://github.com/Telmate/terraform-provider-proxmox.git`
- Change directory `cd terraform-provider-proxmox`
- Run:
- `go install github.com/Telmate/terraform-provider-proxmox/cmd/terraform-provider-proxmox`
- `go install github.com/Telmate/terraform-provider-proxmox/cmd/terraform-provisioner-proxmox`
- `make`
- Make plugin directory in **proxmox-template** `mkdir -p ~/.terraform.d/plugins`
- Copy provider and plugin binaries to the above directory
- `cp bin/terraform-provider-proxmox ~/.terraform.d/plugins`
- `cp bin/terraform-provisioner-proxmox ~/.terraform.d/plugins`
- Run `terraform init`
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment