Skip to content

Commit 95fb27d

Browse files
Added proxmox configuration (#65)
1 parent 50de8ba commit 95fb27d

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
- name: Prepare Proxmox for Terraform
2+
hosts: gryffindor
3+
remote_user: root
4+
5+
tasks:
6+
- name: Remove Terraform user
7+
ansible.builtin.shell: pveum user delete terraform@pve
8+
ignore_errors: true
9+
when: force == "true"
10+
11+
- name: Setup Terraform user
12+
ansible.builtin.shell: pveum user add terraform@pve
13+
14+
- name: Remove Terraform role
15+
ansible.builtin.shell: pveum role delete Terraform
16+
ignore_errors: true
17+
when: force == "true"
18+
19+
- name: Setup Terraform role
20+
ansible.builtin.shell: |
21+
pveum role add Terraform -privs "
22+
Datastore.Allocate
23+
Datastore.AllocateSpace
24+
Datastore.AllocateTemplate
25+
Datastore.Audit
26+
Pool.Allocate
27+
Sys.Audit
28+
Sys.Console
29+
Sys.Modify
30+
SDN.Use
31+
VM.Allocate
32+
VM.Audit
33+
VM.Clone
34+
VM.Config.CDROM
35+
VM.Config.Cloudinit
36+
VM.Config.CPU
37+
VM.Config.Disk
38+
VM.Config.HWType
39+
VM.Config.Memory
40+
VM.Config.Network
41+
VM.Config.Options
42+
VM.Migrate
43+
VM.Monitor
44+
VM.PowerMgmt
45+
User.Modify"
46+
47+
- name: Assign role to user
48+
ansible.builtin.shell: pveum aclmod / -user terraform@pve -role Terraform
49+
50+
- name: Setup api token
51+
ansible.builtin.shell: |
52+
pveum user token add terraform@pve provider --privsep=0
53+
register: api_token
54+
55+
- name: Output api token
56+
debug:
57+
var: api_token.stdout_lines
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[gryffindor]
2+
192.168.50.61

shell.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
pkgs ? import <nixpkgs> { config.allowUnfree=true; }
3+
}:
4+
pkgs.mkShell {
5+
nativeBuildInputs = with pkgs.buildPackages; [terraform ansible];
6+
}

0 commit comments

Comments
 (0)