├── .gitignore ├── README.md ├── ansible-roles ├── inventory.toml ├── playbook.yml └── roles │ ├── k3s-common │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── handlers │ │ └── main.yml │ ├── meta │ │ └── main.yml │ ├── tasks │ │ ├── install_deps.yml │ │ └── main.yml │ ├── tests │ │ ├── inventory │ │ └── test.yml │ └── vars │ │ └── main.yml │ ├── k3s-master │ ├── README.md │ ├── defaults │ │ └── main.yml │ ├── files │ │ └── k3s-server.service │ ├── handlers │ │ └── main.yml │ ├── meta │ │ └── main.yml │ ├── tasks │ │ ├── install_deps.yml │ │ └── main.yml │ ├── tests │ │ ├── inventory │ │ └── test.yml │ └── vars │ │ └── main.yml │ └── k3s-worker │ ├── README.md │ ├── defaults │ └── main.yml │ ├── handlers │ └── main.yml │ ├── meta │ └── main.yml │ ├── tasks │ ├── install_deps.yml │ └── main.yml │ ├── templates │ └── k3s-agent.service.j2 │ ├── tests │ ├── inventory │ └── test.yml │ └── vars │ └── main.yml └── proxmox-tf ├── .terraform └── plugins │ └── linux_amd64 │ └── lock.json ├── kubeconfig.conf ├── modules ├── generic-cluster │ ├── main.tf │ └── variables.tf └── generic-vm │ ├── main.tf │ └── variables.tf └── prod ├── .terraform └── plugins │ └── linux_amd64 │ └── lock.json └── main.tf /.gitignore: -------------------------------------------------------------------------------- 1 | terraform.tfstate* 2 | playbook.retry 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # k3s on Proxmox 2 | 3 | Check out my post for background: 4 | http://pawa.lt/posts/2019/07/automating-k3s-deployment-on-proxmox/ 5 | -------------------------------------------------------------------------------- /ansible-roles/inventory.toml: -------------------------------------------------------------------------------- 1 | [all] 2 | k3s-node-0 ansible_host=172.30.100.80 3 | k3s-node-1 ansible_host=172.30.100.81 4 | k3s-node-2 ansible_host=172.30.100.82 5 | k3s-node-3 ansible_host=172.30.100.83 6 | 7 | [masters] 8 | k3s-node-0 9 | 10 | [workers] 11 | k3s-node-1 12 | k3s-node-2 13 | k3s-node-3 14 | -------------------------------------------------------------------------------- /ansible-roles/playbook.yml: -------------------------------------------------------------------------------- 1 | - hosts: all 2 | remote_user: ubuntu 3 | gather_facts: false 4 | tasks: 5 | - name: Check for Python 6 | raw: test -e /usr/bin/python 7 | changed_when: false 8 | failed_when: false 9 | register: check_python 10 | 11 | - name: Install Python 12 | raw: sudo apt -y update && sudo apt install -y python 13 | when: check_python.rc != 0 14 | become: true 15 | 16 | - hosts: all 17 | roles: 18 | - k3s-common 19 | 20 | - hosts: masters 21 | roles: 22 | - k3s-master 23 | 24 | - hosts: workers 25 | roles: 26 | - k3s-worker 27 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-common/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-common/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | k3s_version: v0.7.0 3 | 4 | k3s_bin_url: "https://github.com/rancher/k3s/releases/download/{{ k3s_version }}/k3s" 5 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-common/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for k3s-master -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-common/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Some suggested licenses: 11 | # - BSD (default) 12 | # - MIT 13 | # - GPLv2 14 | # - GPLv3 15 | # - Apache 16 | # - CC-BY 17 | license: license (GPLv2, CC-BY, etc) 18 | 19 | min_ansible_version: 1.2 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # Optionally specify the branch Galaxy will use when accessing the GitHub 25 | # repo for this role. During role install, if no tags are available, 26 | # Galaxy will use this branch. During import Galaxy will access files on 27 | # this branch. If Travis integration is configured, only notifications for this 28 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 29 | # (usually master) will be used. 30 | #github_branch: 31 | 32 | # 33 | # platforms is a list of platforms, and each platform has a name and a list of versions. 34 | # 35 | # platforms: 36 | # - name: Fedora 37 | # versions: 38 | # - all 39 | # - 25 40 | # - name: SomePlatform 41 | # versions: 42 | # - all 43 | # - 1.0 44 | # - 7 45 | # - 99.99 46 | 47 | galaxy_tags: [] 48 | # List tags for your role here, one per line. A tag is a keyword that describes 49 | # and categorizes the role. Users find roles by searching for tags. Be sure to 50 | # remove the '[]' above, if you add tags to this list. 51 | # 52 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 53 | # Maximum 20 tags per role. 54 | 55 | dependencies: [] 56 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 57 | # if you add dependencies to this list. -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-common/tasks/install_deps.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install k3s binaries 4 | get_url: 5 | url: "{{ k3s_bin_url }}" 6 | dest: "/usr/local/bin/k3s" 7 | mode: 0755 8 | become: true 9 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-common/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - include_tasks: install_deps.yml 3 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-common/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-common/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - k3s-master -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-common/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for k3s-master -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | kubectl_version: v1.15.1 3 | 4 | kubectl_bin_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kubectl_version }}/bin/linux/amd64/kubectl" 5 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/files/k3s-server.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Lightweight Kubernetes 3 | Documentation=https://k3s.io 4 | After=network-online.target 5 | 6 | [Service] 7 | Type=notify 8 | ExecStart=/usr/local/bin/k3s server 9 | KillMode=process 10 | Delegate=yes 11 | LimitNOFILE=infinity 12 | LimitNPROC=infinity 13 | LimitCORE=infinity 14 | TasksMax=infinity 15 | TimeoutStartSec=0 16 | Restart=always 17 | 18 | [Install] 19 | WantedBy=multi-user.target 20 | 21 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for k3s-master -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Some suggested licenses: 11 | # - BSD (default) 12 | # - MIT 13 | # - GPLv2 14 | # - GPLv3 15 | # - Apache 16 | # - CC-BY 17 | license: license (GPLv2, CC-BY, etc) 18 | 19 | min_ansible_version: 1.2 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # Optionally specify the branch Galaxy will use when accessing the GitHub 25 | # repo for this role. During role install, if no tags are available, 26 | # Galaxy will use this branch. During import Galaxy will access files on 27 | # this branch. If Travis integration is configured, only notifications for this 28 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 29 | # (usually master) will be used. 30 | #github_branch: 31 | 32 | # 33 | # platforms is a list of platforms, and each platform has a name and a list of versions. 34 | # 35 | # platforms: 36 | # - name: Fedora 37 | # versions: 38 | # - all 39 | # - 25 40 | # - name: SomePlatform 41 | # versions: 42 | # - all 43 | # - 1.0 44 | # - 7 45 | # - 99.99 46 | 47 | galaxy_tags: [] 48 | # List tags for your role here, one per line. A tag is a keyword that describes 49 | # and categorizes the role. Users find roles by searching for tags. Be sure to 50 | # remove the '[]' above, if you add tags to this list. 51 | # 52 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 53 | # Maximum 20 tags per role. 54 | 55 | dependencies: [] 56 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 57 | # if you add dependencies to this list. -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/tasks/install_deps.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install kubectl 3 | get_url: 4 | url: "{{ kubectl_bin_url }}" 5 | dest: /usr/local/bin/kubectl 6 | mode: 0755 7 | become: true 8 | 9 | - name: Install k3s-server service 10 | copy: 11 | src: k3s-server.service 12 | dest: /etc/systemd/system/k3s-server.service 13 | become: true 14 | 15 | - name: Start and enable k3s-server 16 | systemd: 17 | name: k3s-server 18 | state: started 19 | enabled: true 20 | daemon_reload: true 21 | become: true 22 | 23 | - name: Get join token 24 | command: cat /var/lib/rancher/k3s/server/node-token 25 | register: found_join_token 26 | retries: 30 27 | delay: 5 28 | until: found_join_token.rc == 0 29 | become: true 30 | 31 | - name: Save join token 32 | set_fact: 33 | k3s_join_token: "{{ found_join_token.stdout }}" 34 | 35 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - include_tasks: install_deps.yml 3 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - k3s-master -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-master/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for k3s-master -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for k3s-worker -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for k3s-worker -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Some suggested licenses: 11 | # - BSD (default) 12 | # - MIT 13 | # - GPLv2 14 | # - GPLv3 15 | # - Apache 16 | # - CC-BY 17 | license: license (GPLv2, CC-BY, etc) 18 | 19 | min_ansible_version: 1.2 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # Optionally specify the branch Galaxy will use when accessing the GitHub 25 | # repo for this role. During role install, if no tags are available, 26 | # Galaxy will use this branch. During import Galaxy will access files on 27 | # this branch. If Travis integration is configured, only notifications for this 28 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 29 | # (usually master) will be used. 30 | #github_branch: 31 | 32 | # 33 | # platforms is a list of platforms, and each platform has a name and a list of versions. 34 | # 35 | # platforms: 36 | # - name: Fedora 37 | # versions: 38 | # - all 39 | # - 25 40 | # - name: SomePlatform 41 | # versions: 42 | # - all 43 | # - 1.0 44 | # - 7 45 | # - 99.99 46 | 47 | galaxy_tags: [] 48 | # List tags for your role here, one per line. A tag is a keyword that describes 49 | # and categorizes the role. Users find roles by searching for tags. Be sure to 50 | # remove the '[]' above, if you add tags to this list. 51 | # 52 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 53 | # Maximum 20 tags per role. 54 | 55 | dependencies: [] 56 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 57 | # if you add dependencies to this list. -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/tasks/install_deps.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Set k3s master facts 3 | set_fact: 4 | master_node_ip: "{{ hostvars[groups['masters'][0]]['ansible_host'] }}" 5 | node_join_token: "{{ hostvars[groups['masters'][0]]['k3s_join_token'] }}" 6 | 7 | - name: Create k3s agent service 8 | template: 9 | src: k3s-agent.service.j2 10 | dest: /etc/systemd/system/k3s-agent.service 11 | become: true 12 | 13 | - name: Start and enable k3s-agent 14 | systemd: 15 | name: k3s-agent 16 | state: restarted 17 | enabled: true 18 | daemon_reload: true 19 | become: true 20 | 21 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - include_tasks: install_deps.yml 3 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/templates/k3s-agent.service.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Lightweight Kubernetes 3 | Documentation=https://k3s.io 4 | After=network-online.target 5 | 6 | [Service] 7 | Type=notify 8 | ExecStart=/usr/local/bin/k3s agent --server https://{{ master_node_ip }}:6443 --token "{{ node_join_token }}" 9 | KillMode=process 10 | Delegate=yes 11 | LimitNOFILE=infinity 12 | LimitNPROC=infinity 13 | LimitCORE=infinity 14 | TasksMax=infinity 15 | TimeoutStartSec=0 16 | Restart=always 17 | 18 | [Install] 19 | WantedBy=multi-user.target 20 | 21 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - k3s-worker -------------------------------------------------------------------------------- /ansible-roles/roles/k3s-worker/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for k3s-worker -------------------------------------------------------------------------------- /proxmox-tf/.terraform/plugins/linux_amd64/lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "proxmox": "f75ee95388ccafcca748b7ca6e283ef2984f040245eb6130e2edc84768e0b377" 3 | } -------------------------------------------------------------------------------- /proxmox-tf/kubeconfig.conf: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | clusters: 3 | - cluster: 4 | certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJXRENCL3FBREFnRUNBZ0VBTUFvR0NDcUdTTTQ5QkFNQ01DTXhJVEFmQmdOVkJBTU1HR3N6Y3kxelpYSjIKWlhJdFkyRkFNVFUyTkRBeU1EVTBNekFlRncweE9UQTNNalV3TWpBNU1ETmFGdzB5T1RBM01qSXdNakE1TUROYQpNQ014SVRBZkJnTlZCQU1NR0dzemN5MXpaWEoyWlhJdFkyRkFNVFUyTkRBeU1EVTBNekJaTUJNR0J5cUdTTTQ5CkFnRUdDQ3FHU000OUF3RUhBMElBQkRpSlZwQzBJOXhoY3UxV2d4aHlsSi9hME5GMExQY2h3bXB6S1NoQjlPQ2kKMC8vS0hIc0VJakVYMUdCcXBYSGdQS2NBd3lpTCtYUmRHb1MwSm5ycGxIcWpJekFoTUE0R0ExVWREd0VCL3dRRQpBd0lDcERBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUFvR0NDcUdTTTQ5QkFNQ0Ewa0FNRVlDSVFDMWxwbUxZdk5nCjFWZjBzWENoTk54OWxMamlTSUJZenovMDcvcCtTTHFhandJaEFQK2xiTXhla3p5d1JHZVpIMTlHcnpoSk1yTEwKTUdhd2xnMXUxS2ZGY3ZhMQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== 5 | server: https://172.30.100.70:6443 6 | name: default 7 | contexts: 8 | - context: 9 | cluster: default 10 | user: default 11 | name: default 12 | current-context: default 13 | kind: Config 14 | preferences: {} 15 | users: 16 | - name: default 17 | user: 18 | password: 2affcb95c123fb36b732da5cf6eecacc 19 | username: admin 20 | -------------------------------------------------------------------------------- /proxmox-tf/modules/generic-cluster/main.tf: -------------------------------------------------------------------------------- 1 | resource "proxmox_vm_qemu" "generic-vm" { 2 | count = length(var.ips) 3 | 4 | name = "${var.name_prefix}-${count.index}" 5 | desc = "generic terraform-created vm" 6 | target_node = var.target_node 7 | 8 | clone = "ubuntu-ci" 9 | 10 | cores = var.cores 11 | sockets = 1 12 | memory = var.memory 13 | 14 | disk { 15 | id = 0 16 | type = "scsi" 17 | storage = var.storage_pool 18 | size = var.storage_size 19 | } 20 | 21 | network { 22 | id = 0 23 | model = "virtio" 24 | bridge = var.bridge 25 | } 26 | 27 | ssh_user = var.ssh_user 28 | 29 | os_type = "cloud-init" 30 | ipconfig0 = "ip=${var.ips[count.index]}/24,gw=${var.gateway}" 31 | 32 | sshkeys = var.sshkeys 33 | } 34 | 35 | -------------------------------------------------------------------------------- /proxmox-tf/modules/generic-cluster/variables.tf: -------------------------------------------------------------------------------- 1 | variable "ips" { 2 | description = "List of IPs for cluster nodes" 3 | type = list(string) 4 | } 5 | 6 | variable "name_prefix" { 7 | description = "Prefix for node names" 8 | type = string 9 | } 10 | 11 | variable "cores" { 12 | description = "number of cores to give each vm" 13 | type = number 14 | default = 2 15 | } 16 | 17 | variable "memory" { 18 | description = "amount of memory in MB give each vm" 19 | type = number 20 | default = 2048 21 | } 22 | 23 | variable "sshkeys" { 24 | description = "ssh keys to drop onto each vm" 25 | type = string 26 | } 27 | 28 | variable "ssh_user" { 29 | description = "user to put ssh keys under" 30 | type = string 31 | default = "ubuntu" 32 | } 33 | 34 | variable "gateway" { 35 | description = "gateway for cluster" 36 | type = string 37 | } 38 | 39 | variable "bridge" { 40 | description = "bridge to use for network" 41 | type = string 42 | default = "vmbr0" 43 | } 44 | 45 | variable "storage_size" { 46 | description = "amount of storage to give nodes" 47 | type = string 48 | default = "8G" 49 | } 50 | 51 | variable "storage_pool" { 52 | description = "storage pool to use for disk" 53 | type = string 54 | default = "local" 55 | } 56 | 57 | variable "target_node" { 58 | description = "node to deploy on" 59 | type = string 60 | } 61 | 62 | variable "template_name" { 63 | description = "template to use" 64 | type = string 65 | default = "ubuntu-ci" 66 | } 67 | -------------------------------------------------------------------------------- /proxmox-tf/modules/generic-vm/main.tf: -------------------------------------------------------------------------------- 1 | resource "proxmox_vm_qemu" "generic-vm" { 2 | count = length(var.ips) 3 | 4 | name = "${var.node_name}" 5 | desc = "generic terraform-created vm" 6 | target_node = "hermes" 7 | 8 | clone = "ubuntu-ci" 9 | 10 | cores = 2 11 | sockets = 1 12 | memory = 2048 13 | 14 | disk { 15 | id = 0 16 | type = "scsi" 17 | storage = "hermes_data" 18 | size = "32G" 19 | } 20 | 21 | network { 22 | id = 0 23 | model = "virtio" 24 | bridge = "vmbr100" 25 | } 26 | 27 | ssh_user = "ubuntu" 28 | 29 | os_type = "cloud-init" 30 | ipconfig0 = "ip=${var.main_ip}/24,gw=172.30.100.1" 31 | 32 | sshkeys = <