Compare commits

...
Sign in to create a new pull request.

1 commit
main ... test

Author SHA1 Message Date
a88da1edc6 tests 2025-05-08 20:08:37 +02:00
31 changed files with 2267 additions and 23 deletions

View file

@ -291,3 +291,4 @@
line: "{{ server_ip }} {{ service_hosts | join(' ') }}"
state: present
create: yes
# vim: set filetype=yaml.ansible :

61
ansible/k3s_setup_back Normal file
View file

@ -0,0 +1,61 @@
---
- name: Install K3s Server
hosts: k3s_server
become: yes
gather_facts: yes
tasks:
- name: Install K3s Server using the official script
ansible.builtin.shell: >
curl -sfL https://get.k3s.io | sh -s - server \
--write-kubeconfig-mode "644" \
--node-ip "{{ ansible_default_ipv4.address }}" \
--flannel-iface eth0 # Ensure flannel uses the correct interface (check if 'eth0' is correct on your cloud image)
args:
creates: /etc/rancher/k3s/k3s.yaml
- name: Wait for K3s server node-token to be created
ansible.builtin.wait_for:
path: /var/lib/rancher/k3s/server/node-token
timeout: 60
- name: Read the K3s node-token from server
ansible.builtin.slurp:
src: /var/lib/rancher/k3s/server/node-token
register: k3s_token_content
- name: Store K3s token and server IP for agents
ansible.builtin.set_fact:
k3s_token: "{{ k3s_token_content.content | b64decode | trim }}"
k3s_server_ip: "{{ ansible_default_ipv4.address }}"
cacheable: yes
- name: Install K3s Agents
hosts: k3s_agents
become: yes
gather_facts: yes
tasks:
- name: Check if K3s server facts are available
ansible.builtin.fail:
msg: "K3s server IP or token not found. Ensure server play ran successfully."
when: hostvars[groups['k3s_server'][0]].k3s_server_ip is not defined or hostvars[groups['k3s_server'][0]].k3s_token is not defined
- name: Install K3s Agent using the official script
ansible.builtin.shell: >
curl -sfL https://get.k3s.io | K3S_URL='https://{{ hostvars[groups['k3s_server'][0]].k3s_server_ip }}:6443' \
K3S_TOKEN='{{ hostvars[groups['k3s_server'][0]].k3s_token }}' \
sh -s - agent \
--node-ip "{{ ansible_default_ipv4.address }}" \
--flannel-iface eth0 # Ensure flannel uses the correct interface
args:
creates: /etc/rancher/k3s/config.yaml
- name: Get Kubeconfig from Server (optional)
hosts: k3s_server
gather_facts: no
tasks:
- name: Fetch Kubeconfig file from K3s server
ansible.builtin.fetch:
src: /etc/rancher/k3s/k3s.yaml
dest: ../kubeconfig
flat: yes
become: yes

222
ansible/k3s_setup_back2 Normal file
View file

@ -0,0 +1,222 @@
---
- name: Prepare K3s Nodes (Disable conflicting services)
hosts: all
become: yes
gather_facts: no
tasks:
- name: Check if nm-cloud-setup service exists
ansible.builtin.systemd:
name: nm-cloud-setup.service
register: nm_cloud_setup_service_check
ignore_errors: yes
- name: Disable nm-cloud-setup service if it exists
ansible.builtin.systemd:
name: nm-cloud-setup.service
enabled: no
state: stopped
when: nm_cloud_setup_service_check.status is defined and nm_cloud_setup_service_check.status.LoadState != 'not-found'
register: nm_service_disabled
- name: Check if nm-cloud-setup timer exists
ansible.builtin.systemd:
name: nm-cloud-setup.timer
register: nm_cloud_setup_timer_check
ignore_errors: yes
- name: Disable nm-cloud-setup timer if it exists
ansible.builtin.systemd:
name: nm-cloud-setup.timer
enabled: no
state: stopped
when: nm_cloud_setup_timer_check.status is defined and nm_cloud_setup_timer_check.status.LoadState != 'not-found'
register: nm_timer_disabled
- name: Reboot node to apply changes and wait for it to come back
ansible.builtin.reboot:
msg: "Rebooting node after disabling nm-cloud-setup"
connect_timeout: 5
reboot_timeout: 600
pre_reboot_delay: 2
post_reboot_delay: 30
test_command: whoami
when: nm_service_disabled.changed or nm_timer_disabled.changed
- name: Install K3s Server
hosts: k3s_server
become: yes
gather_facts: yes
tasks:
- name: Ensure default interface fact is available
ansible.builtin.fail:
msg: "Could not determine the default network interface name (ansible_default_ipv4.interface)."
when: ansible_default_ipv4.interface is not defined
- name: Download K3s installation script
ansible.builtin.get_url:
url: https://get.k3s.io
dest: /tmp/install-k3s.sh
mode: "0755"
register: download_result
- name: Install K3s Server using the downloaded script
ansible.builtin.command: >
sh /tmp/install-k3s.sh -s - server
--write-kubeconfig-mode "644"
--node-ip "{{ ansible_default_ipv4.address }}"
--flannel-iface "{{ ansible_default_ipv4.interface }}"
args:
creates: /etc/rancher/k3s/k3s.yaml
register: k3s_install_result
changed_when: k3s_install_result.rc == 0 and ("Applying" in k3s_install_result.stdout or "Starting" in k3s_install_result.stdout)
failed_when: k3s_install_result.rc != 0
- name: Show K3s install script execution details
ansible.builtin.debug:
var: k3s_install_result
verbosity: 1
- name: Reload systemd configuration if install script ran successfully
ansible.builtin.systemd:
daemon_reload: yes
when: k3s_install_result.rc == 0 and k3s_install_result.changed
- name: Pause briefly after installation attempt if script ran successfully
ansible.builtin.pause:
seconds: 10
when: k3s_install_result.rc == 0 and k3s_install_result.changed
- name: Check K3s service status (run always after attempt)
ansible.builtin.command: systemctl is-active k3s
register: k3s_service_status
changed_when: false
failed_when: false
ignore_errors: yes
- name: Show K3s service status output
ansible.builtin.debug:
msg: "K3s service status check result: {{ k3s_service_status.stdout | default('N/A') }} (RC={{ k3s_service_status.rc | default('N/A') }})"
- name: Fail if K3s service check failed after successful install script run
ansible.builtin.fail:
msg: "K3s install script reported success (RC=0), but service check failed (RC={{ k3s_service_status.rc }}). Check logs on {{ inventory_hostname }} with 'journalctl -u k3s'."
when:
- k3s_install_result.rc == 0
- k3s_service_status.rc is defined
- k3s_service_status.rc != 0
- k3s_service_status.rc != 3
- name: Start K3s service if it is inactive
ansible.builtin.systemd:
name: k3s
state: started
when: k3s_service_status.rc is defined and k3s_service_status.rc == 3
register: k3s_start_result
- name: Re-check K3s service status after start attempt
ansible.builtin.command: systemctl is-active k3s
register: k3s_service_status_after_start
changed_when: false
failed_when: false
when: k3s_start_result.changed
- name: Show K3s service status after start attempt
ansible.builtin.debug:
msg: "K3s service status after start attempt: {{ k3s_service_status_after_start.stdout | default('N/A') }} (RC={{ k3s_service_status_after_start.rc | default('N/A') }})"
when: k3s_start_result.changed
- name: Fail if K3s service is not active after potential start
ansible.builtin.fail:
msg: "K3s service could not be started. Check logs on {{ inventory_hostname }} with 'journalctl -u k3s'."
when: >
(k3s_service_status.rc is defined and k3s_service_status.rc != 0) and
(not k3s_start_result.changed or (k3s_service_status_after_start.rc is defined and k3s_service_status_after_start.rc != 0))
- name: Set flag indicating K3s service is active
ansible.builtin.set_fact:
k3s_service_active: true
when: >
(k3s_service_status.rc is defined and k3s_service_status.rc == 0) or
(k3s_start_result.changed and k3s_service_status_after_start.rc is defined and k3s_service_status_after_start.rc == 0)
- name: Wait for K3s server node-token to be created
ansible.builtin.wait_for:
path: /var/lib/rancher/k3s/server/node-token
timeout: 120
delay: 5
when: k3s_service_active | default(false)
- name: Read the K3s node-token from server
ansible.builtin.slurp:
src: /var/lib/rancher/k3s/server/node-token
register: k3s_token_content
when: k3s_service_active | default(false)
- name: Store K3s token and server IP for agents
ansible.builtin.set_fact:
k3s_token: "{{ k3s_token_content.content | b64decode | trim }}"
k3s_server_ip: "{{ ansible_default_ipv4.address }}"
cacheable: yes
when: k3s_service_active | default(false) and k3s_token_content.content is defined
- name: Install K3s Agents
hosts: k3s_agents
become: yes
gather_facts: yes
tasks:
- name: Ensure default interface fact is available
ansible.builtin.fail:
msg: "Could not determine the default network interface name (ansible_default_ipv4.interface)."
when: ansible_default_ipv4.interface is not defined
- name: Check if K3s server facts are available
ansible.builtin.fail:
msg: "K3s server IP or token not found. Ensure server play ran successfully and the server is running."
when: hostvars[groups['k3s_server'][0]].k3s_server_ip is not defined or hostvars[groups['k3s_server'][0]].k3s_token is not defined
- name: Debug Agent Environment Variables
ansible.builtin.debug:
msg:
- "Attempting to use K3S_URL=https://{{ hostvars[groups['k3s_server'][0]].k3s_server_ip }}:6443"
- "Attempting to use K3S_TOKEN={{ hostvars[groups['k3s_server'][0]].k3s_token }}"
- name: Download K3s installation script
ansible.builtin.get_url:
url: https://get.k3s.io
dest: /tmp/install-k3s.sh
mode: "0755"
# curl -sfL https://get.k3s.io | K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -
- name: Install K3s Agent using the downloaded script
ansible.builtin.command: >
sh /tmp/install-k3s.sh agent
--node-ip "{{ ansible_default_ipv4.address }}"
--flannel-iface "{{ ansible_default_ipv4.interface }}"
--with-node-id
# --server "https://{{ hostvars[groups['k3s_server'][0]].k3s_server_ip }}:6443"
# --token "{{ hostvars[groups['k3s_server'][0]].k3s_token }}"
environment:
K3S_URL: "https://{{ hostvars[groups['k3s_server'][0]].k3s_server_ip }}:6443"
K3S_TOKEN: "{{ hostvars[groups['k3s_server'][0]].k3s_token }}"
args:
creates: /etc/rancher/k3s/config.yaml
register: k3s_agent_install_result
changed_when: k3s_agent_install_result.rc == 0
failed_when: k3s_agent_install_result.rc != 0
- name: Show K3s agent install script execution details
ansible.builtin.debug:
var: k3s_agent_install_result
verbosity: 1
- name: Get Kubeconfig from Server (optional)
hosts: k3s_server
gather_facts: no
tasks:
- name: Fetch Kubeconfig file from K3s server
ansible.builtin.fetch:
src: /etc/rancher/k3s/k3s.yaml
dest: ../kubeconfig
flat: yes
become: yes
when: hostvars[inventory_hostname].k3s_service_active | default(false)

View file

@ -0,0 +1 @@
{"version":4,"terraform_version":"1.9.1","serial":1,"lineage":"7a9cbe48-0582-f3b7-9105-7797284e5504","outputs":{},"resources":[],"check_results":null}

View file

@ -27,6 +27,13 @@ tofu apply -auto-approve
cd ..
for ip in 192.168.124.100 192.168.124.101 192.168.124.102; do
echo "Warte auf SSH auf $ip ..."
while ! nc -z $ip 22; do
sleep 2
done
done
# 3. Ansible-Playbook
if [ -f ./ansible/k3s_setup.yml ]; then
echo "Starte K3s-Ansible-Playbook..."

View file

@ -71,6 +71,8 @@
cmd: 'ansible-playbook -i {{ ansible_dir }}/inventory.ini {{ ansible_dir }}/k3s_setup.yml -e ''ansible_ssh_common_args="-o StrictHostKeyChecking=accept-new"'' --ask-become-pass'
changed_when: true
- name: Run k3s istall
ansible.builtin.stat:
# --- 4. Kubeconfig Hinweis ---
- name: Display KUBECONFIG info
ansible.builtin.debug:
@ -97,3 +99,5 @@
- name: Final Bootstrap Message
ansible.builtin.debug:
msg: "Cluster-Bootstrap mit Ansible abgeschlossen!"
# code: language=ansible
# vim: set filetype=yaml.ansible :

103
bootstrap_cluster.yaml Normal file
View file

@ -0,0 +1,103 @@
---
- name: 1. Libvirt Volumes prüfen und ggf. löschen
hosts: localhost
gather_facts: false
vars:
volumes:
- k3s-server-disk.qcow2
- k3s-agent-1-disk.qcow2
- k3s-agent-2-disk.qcow2
- k3s-common-init.iso
- fedora-cloud-base.qcow2
pool: default
tasks:
- name: Check and delete old Libvirt-Volumes
ansible.builtin.shell: |
if virsh vol-list {{ pool }} | grep -q "{{ item }}"; then
virsh vol-delete --pool {{ pool }} "{{ item }}"
fi
loop: "{{ volumes }}"
become: true
- name: 2. Initialize and apply OpenTofu
hosts: localhost
gather_facts: false
tasks:
- name: Entferne alte Terraform/Tofu-Dateien
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- ./tofu/.terraform
- ./tofu/.terraform.lock.hcl
- ./tofu/terraform.tfstate
- ./tofu/terraform.tfstate.backup
- ./tofu/tofu.tfstate
- ./tofu/tofu.tfstate.backup
- name: Initialize OpenTofu
ansible.builtin.command: tofu init
args:
chdir: ./tofu
- name: Plan Infrastruktur
ansible.builtin.command: tofu plan
args:
chdir: ./tofu
- name: Apply infrastructur
ansible.builtin.command: tofu apply -auto-approve
args:
chdir: ./tofu
- name: 3. wait for ssh on all nodes
hosts: localhost
gather_facts: false
vars:
node_ips:
- 192.168.124.100
- 192.168.124.101
- 192.168.124.102
tasks:
- name: Warte auf SSH-Port (22) auf allen Nodes
ansible.builtin.wait_for:
host: "{{ item }}"
port: 22
state: started
delay: 2
timeout: 300
loop: "{{ node_ips }}"
- name: 4. K3s-Cluster-Setup
import_playbook: ./ansible/k3s_setup.yml
- name: 5. Setze KUBECONFIG und zeige den Wert
hosts: localhost
gather_facts: false
tasks:
- name: Set KUBECONFIG Env
ansible.builtin.shell: |
export KUBECONFIG=$(realpath ./kubeconfig)
echo "KUBECONFIG is set to $KUBECONFIG"
environment:
KUBECONFIG: "{{ lookup('pipe', 'realpath ./kubeconfig') }}"
- name: 6. Flux Bootstrap
hosts: localhost
gather_facts: false
vars:
git_token: "{{ lookup('env', 'GIT_TOKEN') }}"
tasks:
- name: Start Flux-Bootstrap
ansible.builtin.shell: |
export GIT_TOKEN="{{ git_token }}"
flux bootstrap git \
--url=https://codeberg.org/Pata1704/homelab_gitops.git \
--branch=main \
--path=./clusters/production \
--token-auth
environment:
GIT_TOKEN: "{{ git_token }}"
args:
executable: /bin/bash
# vim: set filetype=yaml.ansible :

View file

@ -1,18 +0,0 @@
repositories:
- name: gitea-charts
url: https://dl.gitea.io/charts/
- name: prometheus-community
url: https://prometheus-community.github.io/helm-charts
- name: grafana
url: https://grafana.github.io/helm-charts
- name: sonarsource
url: https://SonarSource.github.io/helm-chart-sonarqube
releases:
- name: kube-prometheus-stack
namespace: monitoring
chart: prometheus-community/kube-prometheus-stack
version: "72.0.0"
createNamespace: true
values:
- ./values/kube-prometheus-stack.yaml

19
kubeconfig Normal file
View file

@ -0,0 +1,19 @@
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkekNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUzTkRZMk5UQTJNREV3SGhjTk1qVXdOVEEzTWpBME16SXhXaGNOTXpVd05UQTFNakEwTXpJeApXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUzTkRZMk5UQTJNREV3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFTUUsrNnkwSTloYXJpQ0M0Sm15V0VMdkJEY3UvTTlVUlhwSVBwblNLaXEKc0RDVVVyek8zV3R1cE9tVkwzYURXWGdvYnByZlZSQWE2U0pwQjZzU3FtWDFvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVWdkMXZadzY0WUE1aTFUN1p1dEp4Cm1LUnRZYnd3Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUloQUtMU1ZjSlp5MzM4RGJLQnN6ZDg1SjEyMGZRM2hTc2IKWmN0dFZ4VjFCRWxvQWlCYncxanpGOGY3ZHQ4Z3dTVmxGVjJTeXpTY0ZJblBENlU1T1pBMHdnRmZ5Zz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
server: https://192.168.124.100:6443
name: default
contexts:
- context:
cluster: default
user: default
name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJrVENDQVRlZ0F3SUJBZ0lJY0JBdG5vRE9SUjR3Q2dZSUtvWkl6ajBFQXdJd0l6RWhNQjhHQTFVRUF3d1kKYXpOekxXTnNhV1Z1ZEMxallVQXhOelEyTmpVd05qQXhNQjRYRFRJMU1EVXdOekl3TkRNeU1Wb1hEVEkyTURVdwpOekl3TkRNeU1Wb3dNREVYTUJVR0ExVUVDaE1PYzNsemRHVnRPbTFoYzNSbGNuTXhGVEFUQmdOVkJBTVRESE41CmMzUmxiVHBoWkcxcGJqQlpNQk1HQnlxR1NNNDlBZ0VHQ0NxR1NNNDlBd0VIQTBJQUJGVm54djlrMFRYa1JnWGUKcFQ5RktIb25ZRXBCU3k2QWQ0bXMvUXVNMGxHL3QwUE9ET3JJVS9GRjRHY09ENFQ0YmNhWERmT3RzY1ZsdU5TZgp3aWdVR25halNEQkdNQTRHQTFVZER3RUIvd1FFQXdJRm9EQVRCZ05WSFNVRUREQUtCZ2dyQmdFRkJRY0RBakFmCkJnTlZIU01FR0RBV2dCVEZ4eDlLQW1tSW41ZDFwWUV1MVJJTDdZWmc5REFLQmdncWhrak9QUVFEQWdOSUFEQkYKQWlBL0R6SXgwdy81aUhCN2dJN2ZOKzgzbFRaZ0M4VE5lazd3L2FWMG4rZ1ljZ0loQU1MWGFGbXFNbWY4c2N0RQo4NzFTdVU0Q1p2N0ZocEM1TXpDNlpuQ1hBQ2ovCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KLS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkekNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdFkyeHAKWlc1MExXTmhRREUzTkRZMk5UQTJNREV3SGhjTk1qVXdOVEEzTWpBME16SXhXaGNOTXpVd05UQTFNakEwTXpJeApXakFqTVNFd0h3WURWUVFEREJock0zTXRZMnhwWlc1MExXTmhRREUzTkRZMk5UQTJNREV3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFTelR2QnNxV0g5emM1VWJUNUJRcFcxRXJyVTlLRENIaUpvTVhwN09PNDcKZCs1L2NGSVVidnhhbG9aMTlGaytVbFZzYitBdkoxdjh6SG9TaDF2RlZ5VGNvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVXhjY2ZTZ0pwaUorWGRhV0JMdFVTCkMrMkdZUFF3Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUlnWm0rQUQ5QStZOGF2RzN1RkttZDUxaDV3SzlhU2t6MEEKNHYvUFR1VWZjdm9DSVFETmR1bC8vSjUvdnZ1RVRhcVBRWlZIS1FHc3JTaURlQTluaHVvSVd5UVV1UT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
client-key-data: LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSU9kcjZxUWk2RUR5NXp5RHRjSjUxMXBjK0VvMCtRYVdGMWpVT3NQamx4MzhvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFVldmRy8yVFJOZVJHQmQ2bFAwVW9laWRnU2tGTExvQjNpYXo5QzR6U1ViKzNRODRNNnNoVAo4VVhnWnc0UGhQaHR4cGNOODYyeHhXVzQxSi9DS0JRYWRnPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=

58
tofu/.terraform.lock.hcl generated Normal file
View file

@ -0,0 +1,58 @@
# This file is maintained automatically by "tofu init".
# Manual edits may be lost in future updates.
provider "registry.opentofu.org/dmacvicar/libvirt" {
version = "0.8.3"
constraints = "0.8.3"
hashes = [
"h1:Tttxr3E9O75MM+dDmq5sYHQEw29PwtIj+XDj/5drdfE=",
"zh:06ff0169beafd1891dc5a30616983abd32004a4f570d1d3dbb5851d84bd1c007",
"zh:2dbdd726d0987cda73b56ecdfbcb98a67485e86a7a44aec976c0081b7239d89d",
"zh:2e195a7bbdfcc13c45460571a5ba848a5c1e746b477c8381058767560f0ac93b",
"zh:3952da13080018c5aec498b73e343c4c22ad884afb8c983138fb7255617aa991",
"zh:478841bcf57df938726ddb90f55c7953fad09db4f6348747519afe7fc84b403b",
"zh:53bce78b03a82c4782acfe1f32c2b46a68fa5fb2fb90d4a5392c90b436b44244",
"zh:5c157f23e9768c67cddf9e847a571adca441607cb5adfb96dbfdd626ceadf92c",
"zh:6bc78d631959fb695664966851308e140c38f3f5cf648dd89756320c2d91765d",
"zh:8605d7d6915190836802654920a8eea3d751ae437273c4f4476dc0ebb9167a1d",
"zh:8b66a22b97331c2a56aed092fd39152d06ad957fd4810aa3f0c4ade0f9b15755",
"zh:92586a47a04082f70bb33f722672127a287caeed109beaaca2668e2e1d6a9caf",
"zh:99a9ee414f5c4268e287660ce8edec2efcba1f79351f83791b64c7e5ab04f569",
"zh:b7cff09fe74b0eb63b5b9aa94de5b33dadbd006d6d5b9578ac476039ea20b062",
"zh:d4188a343ff32c0e03ff28c7e84abce0f43cad2fdbcd9046eaafc247429039ff",
]
}
provider "registry.opentofu.org/hashicorp/cloudinit" {
version = "2.3.7"
hashes = [
"h1:dkGeAxGbAGgglocp0fl1OzvT6O4KKsJTEsCW0ixdQJs=",
"zh:2d48b8452eae9bac2e62273e8f535f73694d8cb05ea38f4b27ee735dcc38eed4",
"zh:4add11b87e48d0e6ecd19243a06ecfc42fc07d0a3748fe568c2971d5f4767486",
"zh:4c9c4e3319cf3328595ea2d68eba7c604325fbcba38cd443e39e982b0b4e29f2",
"zh:503dd83a05b0421ecbcb140d5fdbe3a6b82f163495a82587a1390cf66d7a27be",
"zh:7dd34de7e68036dbbb70c249968a2a10bccba1cb92d3b4dccbc0eb65a3fc58ea",
"zh:a4d7b4480d38446b8da96ce4ecbc2e5a081c4ddc3da2bad97d7b228821b77895",
"zh:bdec6329c3d2d5f034080d9cd6f9a15a2c052faacd716f981e247b48e6845c01",
"zh:e1519544ae3f67196d144e18c21ad681dc29da3133a537ffdd5c2c6271b8db0c",
"zh:e58cd6b05ed51a6fa072e5de2208ba36a58557c3fb414d50c42b3d40a11366b7",
"zh:fafc4a49c297516f2a40490f9a7e6d2b437d77a94330797d4eead178c987ccb5",
]
}
provider "registry.opentofu.org/hashicorp/local" {
version = "2.5.2"
hashes = [
"h1:6lS+5A/4WFAqY3/RHWFRBSiFVLPRjvLaUgxPQvjXLHU=",
"zh:25b95b76ceaa62b5c95f6de2fa6e6242edbf51e7fc6c057b7f7101aa4081f64f",
"zh:3c974fdf6b42ca6f93309cf50951f345bfc5726ec6013b8832bcd3be0eb3429e",
"zh:5de843bf6d903f5cca97ce1061e2e06b6441985c68d013eabd738a9e4b828278",
"zh:86beead37c7b4f149a54d2ae633c99ff92159c748acea93ff0f3603d6b4c9f4f",
"zh:8e52e81d3dc50c3f79305d257da7fde7af634fed65e6ab5b8e214166784a720e",
"zh:9882f444c087c69559873b2d72eec406a40ede21acb5ac334d6563bf3a2387df",
"zh:a4484193d110da4a06c7bffc44cc6b61d3b5e881cd51df2a83fdda1a36ea25d2",
"zh:a53342426d173e29d8ee3106cb68abecdf4be301a3f6589e4e8d42015befa7da",
"zh:d25ef2aef6a9004363fc6db80305d30673fc1f7dd0b980d41d863b12dacd382a",
"zh:fa2d522fb323e2121f65b79709fd596514b293d816a1d969af8f72d108888e4c",
]
}

View file

@ -0,0 +1,95 @@
## 0.5.1 (December 14, 2018)
### HIGHLIGHTS:
- The provider will retry HTTP downloads if they were caused by server errors (https://github.com/dmacvicar/terraform-provider-libvirt/pull/479)
- XSLT can be used to transform the libvirt XML definition before creating resources, allowing to enable features the provider does not support (https://github.com/dmacvicar/terraform-provider-libvirt/pull/431)
- volumes: when the _HEAD_ method is forbidden, the provider will try a body-less _GET_ instead (https://github.com/dmacvicar/terraform-provider-libvirt/pull/472)
- network: add support for updating _dns.hosts_ (https://github.com/dmacvicar/terraform-provider-libvirt/pull/469)
- network: add support for setting _SRV_ entries (https://github.com/dmacvicar/terraform-provider-libvirt/pull/460)
- qemu-agent: do not contact the qemu agent if the domain is shutdown (https://github.com/dmacvicar/terraform-provider-libvirt/pull/474)
- cli: add `-version` flag (https://github.com/dmacvicar/terraform-provider-libvirt/pull/444)
## 0.5 (October 10, 2018)
### HIGHLIGHTS:
#### libvirt Domain
* _cloud_init_ resource is obsolete and replaced with _cloud_init_disk_ (https://github.com/dmacvicar/terraform-provider-libvirt/pull/410)
The resource does not allow individual fields anymore, and directly takes the _user_data_, _network_config_ and _meta_data_ fields, which you can provide directly or reading from a file, optionally using a _template_ resource and the rendered function. See the [updated documentation](https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r/cloudinit.html.markdown).
#### Volumes/Disk/Storage
* Allow to set the size of a volume larger than its backing volume, which allows to resize the partition then using _cloud-init_, and not be limited by the backing image (#369 and #357).
## 0.4.4 (September 16, 2018)
### HIGHLIGHTS:
#### libvirt Domain
* `TF_USE_QEMU_AGENT` variable is deprecated and replaced by a domain property `qemu_agent`.
Because variables can be interpolated into properties, and variables can be [passed via environment variables](https://www.terraform.io/docs/configuration/environment-variables.html#tf_var_name), the old behavior can be emulated.
#### Volumes/Disk/Storage
* Automatic disk driver selection based on volume format and automatic volume format detection(https://github.com/dmacvicar/terraform-provider-libvirt/commit/676b5a3fec75664990e5a91f24859f35becdee6a)
#### Networking
* `dhcp` paramater is an optional parameter now, disabled by default. (https://github.com/dmacvicar/terraform-provider-libvirt/pull/385)
* DNS forwarders were reworked. `localonly` option was added to libvirt-network (https://github.com/dmacvicar/terraform-provider-libvirt/commit/7651ee5824f77f0c7485736315d5a24762f85e60)
* A datasource called `libvirt_network_dns_hosts_template` can be used to populate the `dns_host` attribute in `libvirt_network` resources. (https://github.com/dmacvicar/terraform-provider-libvirt/commit/a4d0ba6a319d8728cb5d6c10aae593bdd27da516)
___
#### General improvements
* Acceptance tests are now idempotent (no dependency between resource of various tests), which avoids cascade failures. (several PRs and commits)
* Project dependencies were updated ( https://github.com/dmacvicar/terraform-provider-libvirt/commit/1347e7cabbe68d93f7cc065339636854d7c7d340)
* The error message when uploading a volume fails was improved (https://github.com/dmacvicar/terraform-provider-libvirt/commit/1aec44e0c990c4edb22578125bae33f92c4a4f39)
___
#### Bugs
* `netIface["bridge"]` now uses the correct value (https://github.com/dmacvicar/terraform-provider-libvirt/commit/2e93c78b2aea17b48639b3d613f12bfad851fd52)
## 0.4.3 (August 14, 2018)
HIGHLIGHTS:
* *IMPORTANT* qemu-agent is not used by default to gather network
interface information anymore. If you need to use, please set
the TF_USE_QEMU_AGENT environment variable.
* Handle gracefully out-of-band destruction of volume and cloud-init
resources. Should provide a better end-user experience in day to day
operations.
## 0.4.2 (August 3, 2018)
HIGHLIGHTS:
* Fix crashes when using network devices not associated with a
network name (regression introduced in 0.4)
## 0.4.1 (July 28, 2018)
HIGHLIGHTS:
* Fix broken ip address detection bug that was introduced in 0.4
* Add support for importing domain, network, volumes (#336)
## 0.4 (July 25, 2018)
HIGHLIGHTS:
* Support for multiple provider instances (ie: hypervisors) with different URIs
* Support for keyword-less and nested equal signs in kernel parameters
* Adds the `running` attribute when creating a domain
* Fix a bug with UEFI/OVMF booting on remote hypervisors
* Update the project dependencies to more recent versions
* The project now provides builds
* The project now has a gitter.im channel
* Integration tests are fixed and working again

View file

@ -0,0 +1,174 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

View file

@ -0,0 +1,168 @@
> [!NOTE]
> This project is maintained on a best effort basis. I am not actively working on it.
>
> From time to time I go over interesting PRs and do minor improvements.
>
> New features are, by default not welcomed or accepted unless discussed and agreed upon.
>
> If you are willing to contribute, this is what the project accepts as contributions:
>
> - maintainers, who take over an area and actively keep the code in good shape
> - improvements to testing, including enabling the acceptance testsuite in CI
> - modernizing the codebase and removing exceptions from the linters
> - writing v2, simplified versions of the resources
# Terraform provider for libvirt
- [![Gitter chat](https://badges.gitter.im/terraform-provider-libvirt/Lobby.png)](https://gitter.im/terraform-provider-libvirt/Lobby) ([IRC gateway](https://irc.gitter.im/))
- Planning board: [Github Projects](https://github.com/dmacvicar/terraform-provider-libvirt/projects/1)
![alpha](https://img.shields.io/badge/stability%3F-beta-yellow.svg) [![Tests](https://github.com/dmacvicar/terraform-provider-libvirt/actions/workflows/test.yml/badge.svg)](https://github.com/dmacvicar/terraform-provider-libvirt/actions/workflows/test.yml) [![Registry](https://img.shields.io/badge/libvirt-Terraform%20Registry-blue)](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs)
___
This is a terraform provider that lets you provision
servers on a [libvirt](https://libvirt.org/) host via [Terraform](https://terraform.io/).
## Introduction & Goals
This project exists:
* To allow teams to get the benefits [Software Defined Infrastructure](https://en.wikipedia.org/wiki/Software-defined_infrastructure) Terraform provides, on top of classical and cheap virtualization infrastructure provided by Linux and [KVM](https://www.linux-kvm.org)
This helps in very dynamic [DevOps](https://en.wikipedia.org/wiki/DevOps), Development and Testing activities.
* To allow for mixing KVM resources with other infrastructure Terraform is able to manage
What is *NOT* in scope:
* To support every advanced feature [libvirt](https://libvirt.org/) supports
This would make the mapping from terraform complicated and not maintainable. See the [How to contribute](CONTRIBUTING.md) section to understand how to approach new features.
## Getting started
The provider is available for auto-installation from the [Terraform Registry](https://registry.terraform.io/providers/dmacvicar/libvirt/latest).
In your `main.tf` file, specify the version you want to use:
```hcl
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
}
}
}
provider "libvirt" {
# Configuration options
}
```
And now run terraform init:
```console
$ terraform init
```
### Creating your first virtual machine
Here is an example that will setup the following:
+ A virtual server resource
(create this as main.tf and run terraform commands from this directory):
```hcl
provider "libvirt" {
uri = "qemu:///system"
}
```
You can also set the URI in the LIBVIRT_DEFAULT_URI environment variable.
Now, define a libvirt domain:
```hcl
resource "libvirt_domain" "terraform_test" {
name = "terraform_test"
}
```
Now you can see the plan, apply it, and then destroy the infrastructure:
```console
$ terraform init
$ terraform plan
$ terraform apply
$ terraform destroy
```
Look at more advanced examples [here](examples/) and check the [documentation](https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs).
## Manual installation
You can also manually download the provider from the [releases section](https://github.com/dmacvicar/terraform-provider-libvirt/releases) on Github. To install it, refer to the [Terraform documentation](https://www.terraform.io/docs/cli/config/config-file.html#provider-installation).
## Building from source
- [Go](https://golang.org/doc/install) is required for building.
```bash
git clone https://github.com/dmacvicar/terraform-provider-libvirt.git
cd terraform-provider-libvirt
make
```
The binary will be called `terraform-provider-libvirt`.
### Using multiple hypervisors / provider instances
You can target different libvirt hosts instantiating the [provider multiple times](https://www.terraform.io/docs/configuration/providers.html#multiple-provider-instances). [Example](examples/v0.12/multiple).
### Using qemu-agent
From its documentation, [qemu-agent](https://wiki.libvirt.org/page/Qemu_guest_agent):
>It is a daemon program running inside the domain which is supposed to help management applications with executing functions which need assistance of the guest OS.
Until terraform-provider-libvirt 0.4.2, qemu-agent was used by default to get network configuration. However, if qemu-agent is not running, this creates a delay until connecting to it times-out.
In current versions, we default to not to attempt connecting to it, and attempting to retrieve network interface information from the agent needs to be enabled explicitly with `qemu_agent = true`, further details [here](https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r/domain.html.markdown). Note that you still need to make sure the agent is running in the OS, and that is unrelated to this option.
Note: when using bridge network configurations you need to enable the `qemu_agent = true`. otherwise you will not retrieve the ip addresses of domains.
Be aware that this variables may be subject to change again in future versions.
## Upstream projects using terraform-libvirt:
* [sumaform](https://github.com/moio/sumaform)
sumaform is a way to quickly configure, deploy, test [Uyuni](https://www.uyuni-project.org/) and [SUSE Manager](https://www.suse.com/products/suse-manager/) setups with clients and servers.
* [ha-cluster-sap](https://github.com/SUSE/ha-sap-terraform-deployments)
Automated HA and SAP Deployments in Public/Private Clouds (including Libvirt/KVM)
* [ceph-open-terrarium](https://github.com/MalloZup/ceph-open-terrarium)
ceph-open-terrarium is a way to quickly configure, deploy, tests CEPH cluster without or with [Deepsea](https://github.com/SUSE/DeepSea)
* [kubic](https://github.com/kubic-project)
* [kubic-terraform-kvm](https://github.com/kubic-project/kubic-terraform-kvm) Kubic Terraform script using KVM/libvirt
* [Community Driven Docker Examples](contrib/)
Docker examples showing how to use the Libvirt Provider
* [Openshift 4 Installer](https://github.com/openshift/installer)
The Openshift 4 Installer uses Terraform for cluster orchestration and relies on terraform-provider-libvirt for
libvirt platform.
* [Kubitect](https://github.com/MusicDin/kubitect) - a CLI tool for deploying and managing Kubernetes clusters on libvirt platform.
## Authors
* Duncan Mac-Vicar P. <duncan@mac-vicar.eu>
See also the list of [contributors](https://github.com/dmacvicar/terraform-provider-libvirt/graphs/contributors) who participated in this project.
The structure and boilerplate is inspired from the [Softlayer](https://github.com/finn-no/terraform-provider-softlayer) and [Google](https://github.com/terraform-providers/terraform-provider-google) Terraform provider sources.
## License
* Apache 2.0, See LICENSE file

View file

@ -0,0 +1,81 @@
## 2.3.7 (April 21, 2025)
NOTES:
* Update dependencies ([#339](https://github.com/hashicorp/terraform-provider-cloudinit/issues/339))
## 2.3.7-alpha1 (March 04, 2025)
NOTES:
* all: This release is being used to test new build and release actions.
## 2.3.6 (February 27, 2025)
NOTES:
* all: This release contains no functionality changes. It is being used to fix release metadata in the registry from the previous alpha1 release. ([#318](https://github.com/hashicorp/terraform-provider-cloudinit/issues/318))
## 2.3.6-alpha1 (December 05, 2024)
NOTES:
* all: This release contains no functionality changes. It is released using new build and release Actions. ([#293](https://github.com/hashicorp/terraform-provider-cloudinit/issues/293))
## 2.3.5 (September 10, 2024)
NOTES:
* all: This release introduces no functional changes. It does however include dependency updates which address upstream CVEs. ([#263](https://github.com/hashicorp/terraform-provider-cloudinit/issues/263))
## 2.3.4 (April 22, 2024)
NOTES:
* all: This release contains no functionality changes, only the inclusion of the LICENSE file in the release archives ([#228](https://github.com/hashicorp/terraform-provider-cloudinit/issues/228))
## 2.3.3 (November 29, 2023)
NOTES:
* This release introduces no functional changes. It does however include dependency updates which address upstream CVEs. ([#186](https://github.com/hashicorp/terraform-provider-cloudinit/issues/186))
## 2.3.2 (February 23, 2023)
BUG FIXES:
* cloudinit_config: Remove length validation to allow empty content string in part blocks ([#105](https://github.com/hashicorp/terraform-provider-cloudinit/issues/105))
## 2.3.1 (February 22, 2023)
BUG FIXES:
* cloudinit_config: Fixed handling of unknown values in `part` blocks ([#103](https://github.com/hashicorp/terraform-provider-cloudinit/issues/103))
## 2.3.0 (February 22, 2023)
NOTES:
* provider: Rewritten to use the [`terraform-plugin-framework`](https://www.terraform.io/plugin/framework) ([#96](https://github.com/hashicorp/terraform-provider-cloudinit/issues/96))
## 2.2.0 (February 19, 2021)
Binary releases of this provider will now include the darwin-arm64 platform. This version contains no further changes.
## 2.1.0 (November 26, 2020)
NEW FEATURES:
* MIMEBOUNDARY can now be customised with `boundary` ([#7](https://github.com/hashicorp/terraform-provider-cloudinit/issues/7)).
## 2.0.0 (October 12, 2020)
Binary releases of this provider will now include the linux-arm64 platform.
BREAKING CHANGES:
* Upgrade to version 2 of the Terraform Plugin SDK, which drops support for Terraform 0.11. This provider will continue to work as expected for users of Terraform 0.11, which will not download the new version. ([#3](https://github.com/hashicorp/terraform-provider-cloudinit/issues/3))
## 1.0.0 (April 14, 2020)
Initial release. This provider exposes one resource, cloudinit_config, which is identical to the template_cloudinit_config resource in terraform-provider-template.

View file

@ -0,0 +1,375 @@
Copyright (c) 2019 HashiCorp, Inc.
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View file

@ -0,0 +1,107 @@
# Terraform Provider: cloud-init
The cloud-init provider supports rendering [cloud-init](https://cloudinit.readthedocs.io) configurations in a [MIME multi-part file](https://cloudinit.readthedocs.io/en/latest/explanation/format.html#mime-multi-part-archive).
> _This provider is intended to replace the [template provider](https://www.terraform.io/docs/providers/template/). General templating can now be achieved through the [`templatefile`](https://www.terraform.io/docs/configuration/functions/templatefile.html) function, without creating a separate data resource._
> _This provider exposes the `cloudinit_config` data source and resource, previously available as the [`template_cloudinit_config`](https://www.terraform.io/docs/providers/template/d/cloudinit_config.html) in the template provider._
## Documentation, questions and discussions
Official documentation on how to use this provider can be found on the
[Terraform Registry](https://registry.terraform.io/providers/hashicorp/cloudinit/latest/docs).
In case of specific questions or discussions, please use the
HashiCorp [Terraform Providers Discuss forums](https://discuss.hashicorp.com/c/terraform-providers/31),
in accordance with HashiCorp [Community Guidelines](https://www.hashicorp.com/community-guidelines).
We also provide:
* [Support](.github/SUPPORT.md) page for help when using the provider
* [Contributing](.github/CONTRIBUTING.md) guidelines in case you want to help this project
* [Design](DESIGN.md) documentation to understand the scope and maintenance decisions
The remainder of this document will focus on the development aspects of the provider.
## Requirements
* [Terraform](https://www.terraform.io/downloads)
* [Go](https://go.dev/doc/install) (1.23)
* [GNU Make](https://www.gnu.org/software/make/)
* [golangci-lint](https://golangci-lint.run/usage/install/#local-installation) (optional)
## Development
### Building
1. `git clone` this repository and `cd` into its directory
2. `make` will trigger the Golang build
The provided `GNUmakefile` defines additional commands generally useful during development,
like for running tests, generating documentation, code formatting and linting.
Taking a look at it's content is recommended.
### Testing
In order to test the provider, you can run
* `make test` to run provider tests
* `make testacc` to run provider acceptance tests
It's important to note that acceptance tests (`testacc`) will actually spawn
`terraform` and the provider. Read more about they work on the
[official page](https://www.terraform.io/plugin/sdkv2/testing/acceptance-tests).
### Generating documentation
This provider uses [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs/)
to generate documentation and store it in the `docs/` directory.
Once a release is cut, the Terraform Registry will download the documentation from `docs/`
and associate it with the release version. Read more about how this works on the
[official page](https://www.terraform.io/registry/providers/docs).
Use `make generate` to ensure the documentation is regenerated with any changes.
### Using a development build
If [running tests and acceptance tests](#testing) isn't enough, it's possible to set up a local terraform configuration
to use a development builds of the provider. This can be achieved by leveraging the Terraform CLI
[configuration file development overrides](https://www.terraform.io/cli/config/config-file#development-overrides-for-provider-developers).
First, use `make install` to place a fresh development build of the provider in your
[`${GOBIN}`](https://pkg.go.dev/cmd/go#hdr-Compile_and_install_packages_and_dependencies)
(defaults to `${GOPATH}/bin` or `${HOME}/go/bin` if `${GOPATH}` is not set). Repeat
this every time you make changes to the provider locally.
Then, setup your environment following [these instructions](https://www.terraform.io/plugin/debugging#terraform-cli-development-overrides)
to make your local terraform use your local build.
### Testing GitHub Actions
This project uses [GitHub Actions](https://docs.github.com/en/actions/automating-builds-and-tests) to realize its CI.
Sometimes it might be helpful to locally reproduce the behaviour of those actions,
and for this we use [act](https://github.com/nektos/act). Once installed, you can _simulate_ the actions executed
when opening a PR with:
```shell
# List of workflows for the 'pull_request' action
$ act -l pull_request
# Execute the workflows associated with the `pull_request' action
$ act pull_request
```
## Releasing
The release process is automated via GitHub Actions, and it's defined in the Workflow
[release.yml](./.github/workflows/release.yml). To cut a release:
- Go to the repository in Github and click on the `Actions` tab.
- Select the `Release` workflow on the left-hand menu.
- Click on the `Run workflow` button.
- Select the branch to cut the release from (default is main).
- Input the `Release version number` which is the Semantic Release number including the `v` prefix (i.e. `v1.4.0`) and click `Run workflow` to kickoff the release.
## License
[Mozilla Public License v2.0](./LICENSE)

View file

@ -0,0 +1,173 @@
## 2.5.2 (September 11, 2024)
NOTES:
* all: This release introduces no functional changes. It does however include dependency updates which address upstream CVEs. ([#348](https://github.com/hashicorp/terraform-provider-local/issues/348))
## 2.5.1 (March 11, 2024)
NOTES:
* No functional changes from v2.5.0. Minor documentation fixes. ([#303](https://github.com/hashicorp/terraform-provider-local/issues/303))
## 2.5.0 (March 11, 2024)
FEATURES:
* functions/direxists: Added a new `direxists` function that checks for the existence of a directory, similar to the built-in `fileexists` function. ([#285](https://github.com/hashicorp/terraform-provider-local/issues/285))
## 2.4.1 (December 12, 2023)
NOTES:
* This release introduces no functional changes. It does however include dependency updates which address upstream CVEs. ([#273](https://github.com/hashicorp/terraform-provider-local/issues/273))
## 2.4.0 (March 08, 2023)
NOTES:
* This Go module has been updated to Go 1.19 per the [Go support policy](https://golang.org/doc/devel/release.html#policy). Any consumers building on earlier Go versions may experience errors. ([#184](https://github.com/hashicorp/terraform-provider-local/issues/184))
FEATURES:
* resource/local_file: added support for `MD5`, `SHA1`, `SHA256`, and `SHA512` checksum outputs. ([#142](https://github.com/hashicorp/terraform-provider-local/issues/142))
* resource/local_sensitive_file: added support for `MD5`, `SHA1`, `SHA256`, and `SHA512` checksum outputs. ([#142](https://github.com/hashicorp/terraform-provider-local/issues/142))
* data-source/local_file: added support for `MD5`, `SHA1`, `SHA256`, and `SHA512` checksum outputs. ([#142](https://github.com/hashicorp/terraform-provider-local/issues/142))
* data-source/local_sensitive-file: added support for `MD5`, `SHA1`, `SHA256`, and `SHA512` checksum outputs. ([#142](https://github.com/hashicorp/terraform-provider-local/issues/142))
## 2.3.0 (January 11, 2023)
NOTES:
* provider: Rewritten to use the [`terraform-plugin-framework`](https://www.terraform.io/plugin/framework) ([#155](https://github.com/hashicorp/terraform-provider-local/issues/155))
## 2.2.3 (May 18, 2022)
NOTES:
* resource/local_file: Update docs to prevent confusion that exactly one of the arguments `content`,
`sensitive_content`, `content_base64`, and `source` needs to be specified ([#123](https://github.com/hashicorp/terraform-provider-local/pull/123)).
* resource/local_sensitive_file: Update docs to prevent confusion that exactly one of the arguments `content`,
`content_base64`, and `source` needs to be specified ([#123](https://github.com/hashicorp/terraform-provider-local/pull/123)).
* No functional changes from 2.2.2.
## 2.2.2 (March 11, 2022)
NOTES:
* resource/local_sensitive_file: Fixed typo in documentation (default permission is `"0700"`, not `"0777"`).
* No functional changes from 2.2.1.
## 2.2.1 (March 10, 2022)
NOTES:
* This release is a republishing of the 2.2.0 release to fix release asset checksum errors. It is identical otherwise.
## 2.2.0 (March 10, 2022)
NOTES:
* resource/local_file: Argument `sensitive_content` is `Deprecated`. For creating or accessing files containing sensitive data,
please use the new resource and data source `local_sensitive_file`.
Both are identical to their `local_file` counterparts, but `content` and `content_base64` attributes are marked as _sensitive_.
FEATURES:
* **New Data Source:** `local_sensitive_file` ([#101](https://github.com/hashicorp/terraform-provider-local/pull/101) and [#106](https://github.com/hashicorp/terraform-provider-local/pull/106))
* **New Resource:** `local_sensitive_file` ([#106](https://github.com/hashicorp/terraform-provider-local/pull/106))
## 2.1.0 (February 19, 2021)
NOTES:
* Binary releases of this provider now include the` darwin-arm64` platform.
* This version contains no further changes.
## 2.0.0 (October 14, 2020)
NOTES:
* Binary releases of this provider now include the `linux-arm64` platform.
BREAKING CHANGES:
* Upgrade to version 2 of the Terraform Plugin SDK, which drops support for Terraform 0.11.
This provider will continue to work as expected for users of Terraform 0.11, which will not download the new version.
([#42](https://github.com/terraform-providers/terraform-provider-local/issues/42))
FEATURES:
* resource/local_file: Added `source` attribute as alternative way to provide content
for the `local_file` resource.
([#44](https://github.com/terraform-providers/terraform-provider-local/issues/44))
## 1.4.0 (September 30, 2019)
NOTES:
* The provider has switched to the standalone TF SDK, there should be no noticeable impact on compatibility.
([#32](https://github.com/terraform-providers/terraform-provider-local/issues/32))
FEATURES:
* resource/local_file: Added support for configurable permissions
([#30](https://github.com/terraform-providers/terraform-provider-local/issues/30))
## 1.3.0 (June 26, 2019)
FEATURES:
* resource/local_file: Added support for base64 encoded content
([#29](https://github.com/terraform-providers/terraform-provider-local/issues/29))
* data-source/local_file: Added support for base64 encoded content
([#29](https://github.com/terraform-providers/terraform-provider-local/issues/29))
## 1.2.2 (May 01, 2019)
NOTES:
* This releases includes another Terraform SDK upgrade intended to align with that being used for other providers
as we prepare for the Core `v0.12.0` release. It should have no significant changes in behavior for this provider.
## 1.2.1 (April 11, 2019)
NOTES:
* This releases includes only a Terraform SDK upgrade intended to align with that being used for other providers
as we prepare for the Core `v0.12.0` release. It should have no significant changes in behavior for this provider.
## 1.2.0 (March 20, 2019)
FEATURES:
* The provider is now compatible with Terraform v0.12, while retaining compatibility with prior versions.
* resource/local_file: added optional `sensitive_content` attribute, which can be used instead of `content`
in situations where the content contains sensitive information that should not be displayed in a rendered diff.
([#9](https://github.com/terraform-providers/terraform-provider-local/issues/9))
## 1.1.0 (January 04, 2018)
FEATURES:
* data-source/local_file: Added for reading files in a way that participates in Terraform's dependency graph,
which allows reading of files that are created dynamically during `terraform apply`.
([#6](https://github.com/terraform-providers/terraform-provider-local/issues/6))
## 1.0.0 (September 15, 2017)
NOTES:
* No changes from 0.1.0; just adjusting to
[the new version numbering scheme](https://www.hashicorp.com/blog/hashicorp-terraform-provider-versioning/).
## 0.1.0 (June 21, 2017)
NOTES:
* Same functionality as that of Terraform 0.9.8.
Repacked as part of [Provider Splitout](https://www.hashicorp.com/blog/upcoming-provider-changes-in-terraform-0-10/)

View file

@ -0,0 +1,375 @@
Copyright (c) 2017 HashiCorp, Inc.
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View file

@ -0,0 +1,122 @@
# Terraform Provider: Local
The Local provider is used to manage local resources, such as files.
**Note** Terraform primarily deals with remote resources which are able
to outlive a single Terraform run, and so local resources can sometimes violate
its assumptions. The resources here are best used with care, since depending
on local state can make it hard to apply the same Terraform configuration on
many different local systems where the local resources may not be universally
available. See specific notes in each resource for more information.
## Documentation, questions and discussions
Official documentation on how to use this provider can be found on the
[Terraform Registry](https://registry.terraform.io/providers/hashicorp/local/latest/docs).
In case of specific questions or discussions, please use the
HashiCorp [Terraform Providers Discuss forums](https://discuss.hashicorp.com/c/terraform-providers/31),
in accordance with HashiCorp [Community Guidelines](https://www.hashicorp.com/community-guidelines).
We also provide:
* [Support](.github/SUPPORT.md) page for help when using the provider
* [Contributing](.github/CONTRIBUTING.md) guidelines in case you want to help this project
The remainder of this document will focus on the development aspects of the provider.
## Compatibility
Compatibility table between this provider, the [Terraform Plugin Protocol](https://www.terraform.io/plugin/how-terraform-works#terraform-plugin-protocol)
version it implements, and Terraform:
| TLS Provider | Terraform Plugin Protocol | Terraform |
|:------------:|:-------------------------:|:---------:|
| `>= 2.x` | `5` | `>= 0.12` |
| `>= 1.1.x` | `4` and `5` | `<= 0.12` |
| `>= 0.x` | `4` | `<= 0.11` |
Details can be found querying the [Registry API](https://www.terraform.io/internals/provider-registry-protocol#list-available-versions)
that return all the details about which version are currently available for a particular provider.
[Here](https://registry.terraform.io/v1/providers/hashicorp/local/versions) are the details for Local (JSON response).
## Requirements
* [Terraform](https://www.terraform.io/downloads)
* [Go](https://go.dev/doc/install) (1.22)
* [GNU Make](https://www.gnu.org/software/make/)
* [golangci-lint](https://golangci-lint.run/usage/install/#local-installation) (optional)
## Development
### Building
1. `git clone` this repository and `cd` into its directory
2. `make` will trigger the Golang build
The provided `GNUmakefile` defines additional commands generally useful during development,
like for running tests, generating documentation, code formatting and linting.
Taking a look at it's content is recommended.
### Testing
In order to test the provider, you can run
* `make test` to run provider tests
* `make testacc` to run provider acceptance tests
It's important to note that acceptance tests (`testacc`) will actually spawn
`terraform` and the provider. Read more about they work on the
[official page](https://www.terraform.io/plugin/sdkv2/testing/acceptance-tests).
### Generating documentation
This provider uses [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs/)
to generate documentation and store it in the `docs/` directory.
Once a release is cut, the Terraform Registry will download the documentation from `docs/`
and associate it with the release version. Read more about how this works on the
[official page](https://www.terraform.io/registry/providers/docs).
Use `make generate` to ensure the documentation is regenerated with any changes.
### Using a development build
If [running tests and acceptance tests](#testing) isn't enough, it's possible to set up a local terraform configuration
to use a development builds of the provider. This can be achieved by leveraging the Terraform CLI
[configuration file development overrides](https://www.terraform.io/cli/config/config-file#development-overrides-for-provider-developers).
First, use `make install` to place a fresh development build of the provider in your
[`${GOBIN}`](https://pkg.go.dev/cmd/go#hdr-Compile_and_install_packages_and_dependencies)
(defaults to `${GOPATH}/bin` or `${HOME}/go/bin` if `${GOPATH}` is not set). Repeat
this every time you make changes to the provider locally.
Then, setup your environment following [these instructions](https://www.terraform.io/plugin/debugging#terraform-cli-development-overrides)
to make your local terraform use your local build.
### Testing GitHub Actions
This project uses [GitHub Actions](https://docs.github.com/en/actions/automating-builds-and-tests) to realize its CI.
Sometimes it might be helpful to locally reproduce the behaviour of those actions,
and for this we use [act](https://github.com/nektos/act). Once installed, you can _simulate_ the actions executed
when opening a PR with:
```shell
# List of workflows for the 'pull_request' action
$ act -l pull_request
# Execute the workflows associated with the `pull_request' action
$ act pull_request
```
## Releasing
The release process is automated via GitHub Actions, and it's defined in the Workflow
[release.yml](./.github/workflows/release.yml).
Each release is cut by pushing a [semantically versioned](https://semver.org/) tag to the default branch.
## License
[Mozilla Public License v2.0](./LICENSE)

View file

@ -1,5 +1,7 @@
#cloud-config
# vim: syntax=yaml
# hostname: ${hostname}
# fqdn: ${hostname}.local
# manage_etc_hosts: true
# Add the default user and authorized ssh key
users:
@ -12,17 +14,14 @@ users:
- ${key}
%{ endfor ~}
# Optional: Run package upgrades on first boot
package_update: true
package_upgrade: true
# Optional: Disable password authentication for SSH
ssh_pwauth: false
# Optional: Install basic packages (useful for debugging or Ansible)
packages:
- vim
- curl
- wget
- git
- python3 # Usually present, but good to ensure for Ansible
- python3

View file

@ -29,6 +29,7 @@ data "cloudinit_config" "common_init" {
content = templatefile("${path.module}/cloud_init.cfg.yml", {
user = var.vm_user
ssh_authorized_keys = [chomp(file(pathexpand(var.ssh_public_key_path)))]
hostname = var.server_hostname
})
}
}

115
tofu/main_copy Normal file
View file

@ -0,0 +1,115 @@
# --- Cloud-Init für Server ---
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.8.3"
}
}
}
data "cloudinit_config" "server_init" {
gzip = false
base64_encode = false
part {
content_type = "text/cloud-config"
content = templatefile("${path.module}/cloud_init.cfg.yml", {
user = var.vm_user
ssh_authorized_keys = [chomp(file(pathexpand(var.ssh_public_key_path)))]
hostname = var.server_hostname
})
}
}
resource "libvirt_cloudinit_disk" "server_iso" {
name = "${var.server_hostname}-init.iso"
user_data = data.cloudinit_config.server_init.rendered
pool = var.libvirt_pool
}
# --- Cloud-Init für Agenten ---
data "cloudinit_config" "agent_init" {
count = var.agent_count
gzip = false
base64_encode = false
part {
content_type = "text/cloud-config"
content = templatefile("${path.module}/cloud_init.cfg.yml", {
user = var.vm_user
ssh_authorized_keys = [chomp(file(pathexpand(var.ssh_public_key_path)))]
hostname = "${var.agent_hostname_prefix}-${count.index + 1}"
})
}
}
resource "libvirt_cloudinit_disk" "agent_iso" {
count = var.agent_count
name = "${var.agent_hostname_prefix}-${count.index + 1}-init.iso"
user_data = data.cloudinit_config.agent_init[count.index].rendered
pool = var.libvirt_pool
}
# --- K3s Server Node ---
resource "libvirt_domain" "server" {
name = var.server_hostname
memory = var.server_memory
vcpu = var.server_vcpu
cloudinit = libvirt_cloudinit_disk.server_iso.id
network_interface {
network_name = var.libvirt_network_name
addresses = [var.server_ip]
wait_for_lease = true
}
disk {
volume_id = libvirt_volume.server_disk.id
}
console {
type = "pty"
target_port = "0"
target_type = "serial"
}
graphics {
type = "spice"
listen_type = "address"
autoport = true
}
}
# --- K3s Agent Nodes ---
resource "libvirt_domain" "agent" {
count = var.agent_count
name = "${var.agent_hostname_prefix}-${count.index + 1}"
memory = var.agent_memory
vcpu = var.agent_vcpu
cloudinit = libvirt_cloudinit_disk.agent_iso[count.index].id
network_interface {
network_name = var.libvirt_network_name
addresses = [var.agent_ips[count.index]]
wait_for_lease = true
}
disk {
volume_id = libvirt_volume.agent_disk[count.index].id
}
console {
type = "pty"
target_port = "0"
target_type = "serial"
}
graphics {
type = "spice"
listen_type = "address"
autoport = true
}
}

1
tofu/terraform.tfstate Normal file

File diff suppressed because one or more lines are too long

BIN
tofu/tfplan Normal file

Binary file not shown.