Skip to content

Commit 5450ea8

Browse files
Merge pull request #88 from pascalinthecloud/feature/add-setup-provider-config
feat: add provider configuration guide to documentation
2 parents 6aeb53a + 064f9f5 commit 5450ea8

File tree

3 files changed

+130
-8
lines changed

3 files changed

+130
-8
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module "k8s_cluster" {
3737
}
3838
3939
network = {
40-
bridge = "vmbr0"
40+
brige = "vmbr0"
4141
cidr = "10.10.100.0/24"
4242
gateway = "10.10.100.1"
4343
dns_servers = ["10.0.10.1", "1.1.1.1"]
@@ -81,7 +81,6 @@ module "k8s_cluster_override" {
8181
}
8282
8383
network = {
84-
bridge = "vmbr0"
8584
cidr = "10.10.100.0/24"
8685
gateway = "10.10.100.1"
8786
dns_servers = ["10.0.10.1", "1.1.1.1"]
@@ -137,12 +136,12 @@ module "k8s_cluster_override" {
137136

138137
## Inputs
139138

140-
| Name | Description | Type | Default | Required |
141-
|------|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|:--------:|
142-
| <a name="input_cluster"></a> [cluster](#input\_cluster) | Cluster configuration | <pre>object({<br/> name = string # The name of the cluster<br/> config_patches = optional(list(string), []) # List of configuration patches to apply to the Talos machine configuration<br/> node = string # Default node to deploy the vms on<br/> datastore = string # Default datastore to deploy the vms on<br/> vm_base_id = number # The first VM ID for Proxmox VMs, with subsequent IDs counted up from it<br/> install_disk = optional(string, "/dev/sda") # The disk to install Talos on<br/> })</pre> | n/a | yes |
139+
| Name | Description | Type | Default | Required |
140+
|------|-------------|------|---------|:--------:|
141+
| <a name="input_cluster"></a> [cluster](#input\_cluster) | Cluster configuration | <pre>object({<br/> name = string # The name of the cluster<br/> config_patches = optional(list(string), []) # List of configuration patches to apply to the Talos machine configuration<br/> node = string # Default node to deploy the vms on<br/> datastore = string # Default datastore to deploy the vms on<br/> vm_base_id = number # The first VM ID for Proxmox VMs, with subsequent IDs counted up from it<br/> install_disk = optional(string, "/dev/sda") # The disk to install Talos on<br/> })</pre> | n/a | yes |
143142
| <a name="input_controlplane"></a> [controlplane](#input\_controlplane) | Specification of controlplane nodes | <pre>object({<br/> count = number<br/> specs = object({<br/> cpu = number<br/> memory = number<br/> disk = number<br/> })<br/> overrides = optional(map(object({<br/> datastore = optional(string, null)<br/> node = optional(string, null)<br/> cpu = optional(number, null)<br/> memory = optional(number, null)<br/> disk = optional(number, null)<br/> install_disk = optional(string, null)<br/> network = optional(object({<br/> ip_address = string<br/> cidr = string<br/> gateway = string<br/> vlan_id = optional(number, null)<br/> }), null)<br/> })), {})<br/> })</pre> | n/a | yes |
144-
| <a name="input_image"></a> [image](#input\_image) | Variable to define the image configuration for Talos machines | <pre>object({<br/> version = string<br/> extensions = list(string)<br/> factory_url = optional(string, "https://factory.talos.dev")<br/> arch = optional(string, "amd64")<br/> platform = optional(string, "nocloud")<br/> proxmox_datastore = optional(string, "local")<br/> })</pre> | n/a | yes |
145-
| <a name="input_network"></a> [network](#input\_network) | Network configuration for nodes | <pre>object({<br/> bridge = string<br/> cidr = string<br/> gateway = string<br/> dns_servers = list(string)<br/> vlan_id = optional(number, null)<br/> })</pre> | n/a | yes |
143+
| <a name="input_image"></a> [image](#input\_image) | Variable to define the image configuration for Talos machines | <pre>object({<br/> version = string<br/> extensions = list(string)<br/> factory_url = optional(string, "https://factory.talos.dev")<br/> arch = optional(string, "amd64")<br/> platform = optional(string, "nocloud")<br/> proxmox_datastore = optional(string, "local")<br/> })</pre> | n/a | yes |
144+
| <a name="input_network"></a> [network](#input\_network) | Network configuration for nodes | <pre>object({<br/> bridge = optional(string, "vmbr0") # The bridge to use for the network interface<br/> cidr = string<br/> gateway = string<br/> dns_servers = list(string)<br/> vlan_id = optional(number, null)<br/> })</pre> | n/a | yes |
146145
| <a name="input_worker"></a> [worker](#input\_worker) | Specification of worker nodes | <pre>object({<br/> count = number<br/> specs = object({<br/> cpu = number<br/> memory = number<br/> disk = number<br/> })<br/> overrides = optional(map(object({<br/> datastore = optional(string, null)<br/> node = optional(string, null)<br/> cpu = optional(number, null)<br/> memory = optional(number, null)<br/> disk = optional(number, null)<br/> install_disk = optional(string, null)<br/> network = optional(object({<br/> ip_address = string<br/> cidr = string<br/> gateway = string<br/> vlan_id = optional(number, null)<br/> }), null)<br/> })), {})<br/> })</pre> | n/a | yes |
147146

148147
## Outputs
@@ -156,4 +155,4 @@ module "k8s_cluster_override" {
156155

157156
## Repo Activity
158157
![Alt](https://repobeats.axiom.co/api/embed/d5c6fd467a9febbf9bea34fbcd6eb31174975075.svg "Repobeats analytics image")
159-
<!-- END_TF_DOCS -->
158+
<!-- END_TF_DOCS -->

docs/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default defineConfig({
1515
label: 'Guides',
1616
items: [
1717
// Each item here is one entry in the navigation menu.
18+
{ label: 'Provider configuration', slug: 'guides/provider_configuration' },
1819
{ label: 'Setup talos cluster', slug: 'guides/setup' },
1920
{ label: 'Upgrade talos', slug: 'guides/upgrade_talos' },
2021
],
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
title: Setup provider configuration
3+
description: This guide provides instructions on how to configure the provider
4+
---
5+
6+
# 1. Create API Token
7+
You can create an API Token for a user via the Proxmox UI, or via the command line on the Proxmox host or cluster:
8+
9+
- Create a user:
10+
11+
```sh
12+
sudo pveum user add terraform@pve
13+
```
14+
15+
- Create a role for the user (you can skip this step if you want to use any of the existing roles):
16+
17+
```sh
18+
sudo pveum role add Terraform -privs "Mapping.Audit Mapping.Modify Mapping.Use Permissions.Modify Pool.Allocate Pool.Audit Realm.AllocateUser Realm.Allocate SDN.Allocate SDN.Audit Sys.Audit Sys.Console Sys.Incoming Sys.Modify Sys.AccessNetwork Sys.PowerMgmt Sys.Syslog User.Modify Group.Allocate SDN.Use VM.Allocate VM.Audit VM.Backup VM.Clone VM.Config.CDROM VM.Config.CPU VM.Config.Cloudinit VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Console VM.Migrate VM.Monitor VM.PowerMgmt VM.Snapshot.Rollback VM.Snapshot Datastore.Allocate Datastore.AllocateSpace Datastore.AllocateTemplate Datastore.Audit"
19+
```
20+
21+
~> The list of privileges above is only an example, please review it and adjust to your needs.
22+
Refer to the [privileges documentation](https://pve.proxmox.com/pve-docs/pveum.1.html#_privileges) for more details.
23+
24+
- Assign the role to the previously created user:
25+
26+
```sh
27+
sudo pveum aclmod / -user terraform@pve -role Terraform
28+
```
29+
30+
- Create an API token for the user:
31+
32+
```sh
33+
sudo pveum user token add terraform@pve provider --privsep=0
34+
```
35+
<br>
36+
37+
# 2. Configure SSH on Proxmox Node
38+
Since we’re using a custom image, a working SSH connection to the Proxmox node is required for the proxmox_virtual_environment_file Terraform resource.
39+
40+
🚫 Don't use the root user — instead, let’s create a dedicated user for this first. 👤✅
41+
42+
43+
-> `sudo` may not be installed by default on Proxmox VE nodes. You can install it via the command line on the Proxmox host: `apt install sudo`
44+
45+
46+
You can configure the `sudo` privilege for the user via the command line on the Proxmox host.
47+
In the example below, we create a user `terraform` and assign the `sudo` privilege to it. Run the following commands on each Proxmox node in the root shell:
48+
49+
- Create a new system user:
50+
51+
```sh
52+
useradd -m terraform
53+
```
54+
55+
56+
- Configure the `sudo` privilege for the user, by adding a new sudoers file to the `/etc/sudoers.d` directory:
57+
58+
```sh
59+
visudo -f /etc/sudoers.d/terraform
60+
```
61+
62+
Add the following lines to the file:
63+
64+
```text
65+
terraform ALL=(root) NOPASSWD: /sbin/pvesm
66+
terraform ALL=(root) NOPASSWD: /sbin/qm
67+
terraform ALL=(root) NOPASSWD: /usr/bin/tee /var/lib/vz/*
68+
```
69+
70+
If you're using a different datastore for snippets, not the default `local`, you should add the datastore's mount point to the sudoers file as well, for example:
71+
72+
```text
73+
terraform ALL=(root) NOPASSWD: /usr/bin/tee /mnt/pve/cephfs/*
74+
```
75+
76+
You can find the mount point of the datastore by running `pvesh get /storage/<name>` on the Proxmox node.
77+
<br>
78+
79+
- Copy your SSH public key to the `~/.ssh/authorized_keys` file of the `terraform` user on the target node.
80+
<br>
81+
82+
- Test the SSH connection and password-less `sudo`:
83+
84+
```sh
85+
ssh terraform@<target-node> sudo pvesm apiinfo
86+
```
87+
88+
You should be able to connect to the target node and see the output containing `APIVER <number>` on the scr
89+
90+
91+
- Before saving private key in secret store, you should replace linebreaks with \n
92+
```sh
93+
cat proxmox_homelab | awk '{printf "%s\\n", $0}'
94+
```
95+
<br>
96+
97+
# 3. Configure the providers.tf part in Terraform
98+
99+
```terraform
100+
terraform {
101+
required_providers {
102+
proxmox = {
103+
source = "bpg/proxmox"
104+
version = ">= 0.69.0, < 1.0.0"
105+
}
106+
}
107+
}
108+
109+
provider "proxmox" {
110+
endpoint = "https://your-proxmox-host.dev/api2/json"
111+
api_token = var.proxmox_api_key
112+
ssh {
113+
agent = true
114+
username = "terraform"
115+
private_key = var.terraform_proxmox_private_key
116+
117+
}
118+
}
119+
```
120+
121+
🚀 You're all set!
122+
You should now be able to deploy a cluster using the module. ✅

0 commit comments

Comments
 (0)