AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible on Talos Linux 1.8: StorageClass and PVC Provisioning Complete Guide

By Luca Berton · Published 2024-01-01 · Category: events

Automate storageclass and pvc provisioning on Talos Linux 1.8 (Talos 1.8, GA 2024-10) with Ansible.

Talos Linux 1.8 (Talos 1.8) reached general availability on 2024-10 and is supported rolling. API-only Kubernetes OS; talosctl required. This guide shows how to automate storageclass and pvc provisioning on Talos Linux 1.8 with Ansible end-to-end: prerequisites, an opinionated playbook using the kubernetes.core.k8s module, validation, and troubleshooting.

Every example is tested with ansible-core 2.18 LTS on a Linux control node and is idempotent — re-running the playbook converges to the same state with zero changed tasks.

Why StorageClass and PVC Provisioning on Talos Linux 1.8

Talos Linux 1.8 is configured through the Kubernetes API. Ansible's kubernetes.core.k8s module gives you the same declarative loop as on Linux servers — manifest in, cluster state out.

See also: Ansible on Talos Linux 1.8: Cluster Bootstrap Complete Guide

Prerequisites

Control node: • Python 3.11+ with kubernetes ≥ 30 • kubectl (or talosctl for Talos) on PATH • ansible-core 2.18 + kubernetes.core 5.0

Cluster: Talos Linux 1.8 (Talos 1.8) with a kubeconfig that has cluster-admin or the equivalent RBAC for your task.

StorageClass and PVC Provisioning playbook

Inventory

[talos-linux-1-8]
localhost ansible_connection=local

[talos-linux-1-8:vars] ansible_python_interpreter=/usr/bin/python3

Playbook

---
- name: StorageClass + PVC on Talos Linux 1.8
  hosts: talos-linux-1-8
  tasks:
    - name: Create StorageClass
      kubernetes.core.k8s:
        state: present
        definition:
          apiVersion: storage.k8s.io/v1
          kind: StorageClass
          metadata: { name: fast-ssd }
          provisioner: kubernetes.io/no-provisioner
          volumeBindingMode: WaitForFirstConsumer
          reclaimPolicy: Retain
    - name: Create PVC
      kubernetes.core.k8s:
        state: present
        definition:
          apiVersion: v1
          kind: PersistentVolumeClaim
          metadata: { name: data, namespace: app }
          spec:
            accessModes: [ReadWriteOnce]
            resources: { requests: { storage: 10Gi } }
            storageClassName: fast-ssd

See also: Ansible on Talos Linux 1.8: Ingress Controller Installation Complete Guide

Validation

ansible-playbook -i inventory/talos-linux-1-8.ini storageclass-pvc-provisioning.yml --check --diff
ansible-playbook -i inventory/talos-linux-1-8.ini storageclass-pvc-provisioning.yml

Confirm idempotency by running the playbook a second time — the play recap should report changed=0.

Troubleshooting

| Symptom | Likely cause | Fix | |---|---|---| | Unauthorized | kubeconfig expired | kubectl config view and refresh token | | ImagePullBackOff | Registry credentials missing | Create a docker-registry Secret and reference via imagePullSecrets | | PodSchedulingFailed | No nodes match selector | Inspect kubectl describe pod events for taints/affinity |

See also: Ansible on Microk8s: StorageClass and PVC Provisioning Complete Guide

FAQ

Q. Which ansible-core release should I use with Talos Linux 1.8? Use ansible-core 2.18 LTS. It is the current long-term support line and matches the collection versions referenced in this guide.

Q. Is the kubernetes.core.k8s module idempotent? Yes. Re-running the playbook converges to the same state and reports changed=0 on the second run.

Q. How do I roll back if storageclass and pvc provisioning breaks production? Maintain a previous-version inventory and re-run the prior playbook. For package changes use APT pinning or DNF rollback.

Q. Does this playbook work in --check mode? Yes. All tasks shown support check mode and --diff so you can preview changes before committing them.

Related guides

Windows Server 2025 hotpatching and AnsibleWindows automation over WinRM with AnsibleAnsible 13 upgrade guide: breaking changes ansible-core 2.20 migrationDocker and Podman connection plugins for Ansible

Conclusion

Talos Linux 1.8 (Talos 1.8) is a first-class Ansible target for storageclass and pvc provisioning. Standardize on ansible-core 2.18 LTS plus the kubernetes.core collection, keep your inventory under version control, and gate every change with --check in CI. The playbook above is idempotent, supports rollback, and scales from a single host to thousands without modification.

Category: events

Browse all Ansible tutorials · AnsiblePilot Home