renamed vars to use 'lxc' prefix instead of 'container'

This commit is contained in:
hiperman
2026-01-31 18:42:23 -05:00
parent 60fbe461be
commit 0a52e32f42
13 changed files with 174 additions and 176 deletions

View File

@@ -1,11 +1,23 @@
---
- name: Container source must be defined (clone_from or container_template)
- name: Check if container exists
community.general.proxmox:
<<: "{{ proxmox_api_connection }}"
vmid: "{{ lxc_vmid }}"
state: current
register: existing_container
ignore_errors: true
- name: Skip if container already exists
meta: end_host
when: existing_container is succeeded
- name: Container source must be defined (lxc_clone_from or lxc_template)
ansible.builtin.fail:
msg: "Neither clone_from or container_template are defined"
when: clone_from is undefined and container_template is undefined
msg: "Neither lxc_clone_from or lxc_template are defined"
when: lxc_clone_from is undefined and lxc_template is undefined
- name: Clone container from another container or template, then update
when: clone_from is defined
when: lxc_clone_from is defined
block:
- name: Clone from template
ansible.builtin.include_tasks: clone.yaml
@@ -14,25 +26,25 @@
- name: Update container
ansible.builtin.include_tasks: update.yaml
vars:
container_vmid: "{{ clone_result.vmid }}"
register: container_result
lxc_vmid: "{{ clone_result.vmid }}"
register: lxc_result
- name: Create the new container
ansible.builtin.include_tasks: create.yaml
when: container_template is defined and clone_from is undefined
when: lxc_template is defined and lxc_clone_from is undefined
- name: Start the created container and wait for ssh
vars:
container_vmid: "{{ container_result.vmid }}"
lxc_vmid: "{{ lxc_result.vmid }}"
ansible.builtin.include_tasks: "{{ item }}"
loop:
- start.yaml
- wait.yaml
when: container_start
when: lxc_start
- name: Post clone updates
when: clone_from is defined
delegate_to: "{{ container_hostname }}"
when: lxc_clone_from is defined
delegate_to: "{{ lxc_hostname }}"
block:
- name: Include post-clone tasks
ansible.builtin.include_tasks: post-clone.yaml