Skip to main content

Primary links

  • Home
  • AI
  • Kubernetes
  • Incus
  • Ansible
  • Terraform
  • OpenStack
  • Virtualization
  • Linux
  • SmartHome
  • HowTo

Misc

  • Linux
  • Hardware
  • Programming
  • Databases
  • Multimedia
  • Windows

Cloud

  • OpenStack
  • cloud-config
  • nextcloud

Virtualization

  • Virtualization
  • Incus
  • Docker
  • KVM
  • Kubernetes
  • LXC
  • LXD
  • QEMU
  • VMware
  • VirtualBox
  • multipass
  • podman
  • vagrant
  • XEN

Network

  • DNS
  • Firewall
  • Linux
  • OpenvSwitch
  • SSL
  • VLAN
  • VPN
  • iPXE
  • namespaces
  • nmcli
  • tcpdump

Storage

  • CEPH
  • DRBD
  • LVM
  • S3
  • ZFS
  • btrfs

Automation / CI/CD

  • Install
  • Ansible
  • GitLab
  • LLM
  • Preseed
  • Puppet
  • Terraform
  • Ubuntu autoinstall

Monitoring / Visualisation

  • Grafana
  • Icinga
  • Prometheus
  • Monitoring
  • ELK
  • mermaid

Create Incus WireGuard container

Create container

CONTAINER=wireguard

# Create Incus container
incus launch images:ubuntu/26.04 ${CONTAINER}

# update APT packages
incus exec ${CONTAINER} -- bash -c "export http_proxy=${http_proxy} && apt update && apt -y dist-upgrade && apt -y autoremove"

# Install WireGuard
incus exec ${CONTAINER} -- bash -c "export http_proxy=${http_proxy} && apt install -y wireguard iptables iputils-ping"

Configure UDP port forward to wireguard container

PORT=51820
incus config device add ${CONTAINER} udp${PORT} proxy listen=udp:0.0.0.0:${PORT} connect=udp:127.0.0.1:${PORT}

Configure WireGuard

incus shell ${CONTAINER}

cd /etc/wireguard
umask 077;
wg genkey | tee privatekey | wg pubkey > publickey

# /etc/wireguard/wg0.conf
[Interface]
Address = 192.168.8.1/24
ListenPort = 51820
PrivateKey = aI+ohS+Jd5T5lMIDXqvLwp8g6eT6U28bQVS43t5YaU8=
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
PublicKey = yD3wRcoQ94Wu9o9WaLzjfA0S2IQrD91E8xxpSiMU6yE=
AllowedIPs = 192.168.8.2/32

Enable and start WireGuard systemd service

# wg-quick up wg0
sudo systemctl enable --now wg-quick@wg0.service

WireGuard Home configuration

Incus Ansible deployment

---
- name: Create container
  hosts: incus1.example.com
  # become: yes
  tasks:
    - name: Create incus container
      community.general.lxd_container:
        url: "unix:/var/lib/incus/unix.socket"
        name: u2604
        source:
          type: image
          mode: pull
          server: https://images.linuxcontainers.org/
          alias: ubuntu/26.04/cloud
          protocol: simplestreams
        wait_for_container: true
        wait_for_ipv4_addresses: true
        config:
          limits.cpu: "4"
          boot.autostart: "true"
          cloud-init.user-data: |
            #cloud-config
            package_upgrade: true
            locale: en_US.UTF-8
            timezone: Europe/Berlin
            apt_upgrade: true
            package_upgrade: true
            packages:
              - openssh-server
            # disable_root: false
            ssh_authorized_keys:
              - "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
          cloud-init.network-config: |
          network:
            version: 2
            ethernets:
              eno1:
                dhcp4: true
        profiles: ["disk-default", "nic-dev"]
      register: container

    - name: Configure temporary user for initial run
      set_fact:
        remote_user: ubuntu
      delegate_to: localhost
      delegate_facts: True
      when: container.changed


- name: Configure container
  hosts: u2404.example.com
  gather_facts: no
  remote_user:  "{{ hostvars['localhost']['remote_user'] | default(lookup('env', 'USER')) }}"
  become: yes
  tasks:
    - name: Create a user 'johnd' with a home directory
      ansible.builtin.user:
        name: johnd
        create_home: yes

Links
https://discuss.linuxcontainers.org/t/creating-container-with-ansible/20050/7
https://documentation.ubuntu.com/lxd/en/latest/cloud-init/
https://docs.ansible.com/ansible/latest/collections/community/general/lxd_container_module.html
https://github.com/kmpm/ansible-incus

Incus Terraform

Enable Incus remote API authentication
http://www.panticz.de/incus

Terraform main.tf

terraform {
  required_providers {
    incus = {
      source = "lxc/incus"
    }
  }
}

provider "incus" {
  # generate_client_certificates = true
  # accept_remote_certificate    = true

  remote {
    name    = "10.0.1.104"
    scheme  = "https"
    address = "10.0.1.104"
    token   = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
    default = true
  }
}

data "template_file" "user_data" {
  template = <

<strong>Deploy</strong>
<code>
terraform init
terraform apply -auto-approve

Links
https://registry.terraform.io/providers/lxc/incus/latest/docs
https://github.com/lxc/terraform-provider-incus
https://discuss.linuxcontainers.org/t/issues-with-private-network-and-cloud-init-using-tf-incus-and-images-debian-12-cloud/19196/3

incus
Profiles GitHub StackOverflow LinkedIn Xing
Contact Imprint
© panticz 2026

Cookie-Einstellungen

Diese Website nutzt eingebettete Inhalte von Drittanbietern (z.B. YouTube, SoundCloud). Beim Laden dieser Inhalte werden Daten an die jeweiligen Anbieter übermittelt. Datenverarbeitungserklärung