Proxmox LXC Module v1
Summary
Introduce a way to bake proxmox-lxc-template
on the fly with Ansible -
Implementation
Details
- Add support for
ubuntu-privileged-2204-standard-lxc-template
- Add support for
ubuntu-unprivileged-2204-standard-lxc-template
- Add support for
ubuntu-privileged-2204-docker-lxc-template
- Add sample inventory list
- Add sample group_vars that are associated with the default inventory list
- Add relevant playbooks to automate the proxmox-lxc-template baking process
Prerequisites
Update group_vars
Inventory Structure
./inventory/
├── local.yml
├── main.yml
├── proxmox-lxc
│ ├── proxmox-ubuntu-privileged-docker-lxc
│ │ ├── group_vars
│ │ │ └── proxmox-ubuntu-privileged-docker-lxc.yml
│ │ └── main.yml
│ ├── proxmox-ubuntu-privileged-standard-lxc
│ │ ├── group_vars
│ │ │ └── proxmox-ubuntu-privileged-standard-lxc.yml
│ │ └── main.yml
│ └── proxmox-ubuntu-unprivileged-standard-lxc
│ ├── group_vars
│ │ └── proxmox-ubuntu-unprivileged-standard-lxc.yml
│ └── main.yml
└── proxmox.yml
Feel free to update group_vars for proxmox-ubuntu-*.yml
to fit your need.
Relevant Playbooks Preview
./playbooks/proxmox/
├── bake-lxc
│ ├── privileged
│ │ ├── purge-lxc.yml
│ │ ├── ubuntu-2204-docker.yml
│ │ └── ubuntu-2204-standard.yml
│ └── unprivileged
│ ├── purge-lxc.yml
│ └── ubuntu-2204-standard.yml
├── start-proxmox-vm.yml
└── stop-proxmox-vm.yml
How to Run
Bake ubuntu-2204-privileged-standard-lxc-template
cd $HOME/cloud-estate/ansible-playbooks
ansible-playbook -e ansible_become_pass=<localhost password> -i inventory/proxmox-lxc/proxmox-ubuntu-privileged-standard-lxc/ playbooks/proxmox/bake-lxc/privileged/ubuntu-2204-standard.yml
Purge ubuntu-2204-privileged-standard-lxc-template
cd $HOME/cloud-estate/ansible-playbooks
ansible-playbook -e ansible_become_pass=<localhost password> -i inventory/proxmox-lxc/proxmox-ubuntu-privileged-standard-lxc/ playbooks/proxmox/bake-lxc/privileged/purge-lxc.yml
References
- Ansible roles directory structure overview | Beginners Guide
- Create LXC Templates
- Extract a substring from a variable in Ansible
- Regex after matched string and white space in Ansible
- Ansible Handlers: running operations on change
- Ansible-playbook: directly run handler
- Creating a new user and password with Ansible
- ansible.builtin.meta module – Execute Ansible ‘actions’
- Ansible Special Variables