feat: Allow specifying container ID during LXC creation, ensure explicit start, and update README with proxmoxer dependency.
This commit is contained in:
@@ -25,8 +25,9 @@ This Ansible setup is designed to automate the configuration and maintenance of
|
|||||||
To use the provisioning playbooks (`create_lxc.yml`), you must configure Proxmox API access.
|
To use the provisioning playbooks (`create_lxc.yml`), you must configure Proxmox API access.
|
||||||
|
|
||||||
### 1. Requirements on Control Node
|
### 1. Requirements on Control Node
|
||||||
Install `community.general` collection:
|
Install `community.general` collection and `proxmoxer` python library:
|
||||||
```bash
|
```bash
|
||||||
|
sudo apt install python3-proxmoxer # OR pip3 install proxmoxer requests
|
||||||
ansible-galaxy collection install community.general
|
ansible-galaxy collection install community.general
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
- name: container_ip
|
- name: container_ip
|
||||||
prompt: "Enter the IP address (CIDR format preferred, or I will append /24) e.g., 10.0.0.123"
|
prompt: "Enter the IP address (CIDR format preferred, or I will append /24) e.g., 10.0.0.123"
|
||||||
private: no
|
private: no
|
||||||
|
- name: container_id
|
||||||
|
prompt: "Enter the Container ID (VMID) e.g., 105"
|
||||||
|
private: no
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Normalize IP address (append /24 if missing)
|
- name: Normalize IP address (append /24 if missing)
|
||||||
@@ -26,6 +29,7 @@
|
|||||||
node: "{{ proxmox_node }}"
|
node: "{{ proxmox_node }}"
|
||||||
storage: "{{ proxmox_storage }}"
|
storage: "{{ proxmox_storage }}"
|
||||||
ostemplate: '{{ proxmox_storage }}:vztmpl/ubuntu-24.04-standard_24.04-2_amd64.tar.zst'
|
ostemplate: '{{ proxmox_storage }}:vztmpl/ubuntu-24.04-standard_24.04-2_amd64.tar.zst'
|
||||||
|
vmid: "{{ container_id }}"
|
||||||
hostname: "{{ container_name }}"
|
hostname: "{{ container_name }}"
|
||||||
password: "TempPassword123!" # Temporary password, will be disabled by lxc_setup
|
password: "TempPassword123!" # Temporary password, will be disabled by lxc_setup
|
||||||
netif:
|
netif:
|
||||||
@@ -33,12 +37,21 @@
|
|||||||
cores: 2
|
cores: 2
|
||||||
memory: 1024
|
memory: 1024
|
||||||
swap: 512
|
swap: 512
|
||||||
state: started
|
state: present
|
||||||
unprivileged: yes
|
unprivileged: yes
|
||||||
features:
|
features:
|
||||||
- nesting=1
|
- nesting=1
|
||||||
register: proxmox_creation
|
register: proxmox_creation
|
||||||
|
|
||||||
|
- name: Start the container
|
||||||
|
community.general.proxmox:
|
||||||
|
api_host: "{{ proxmox_host | default('10.0.0.1') }}"
|
||||||
|
api_user: "{{ proxmox_api_user }}"
|
||||||
|
api_token_id: "{{ proxmox_api_token_id }}"
|
||||||
|
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||||
|
vmid: "{{ container_id }}"
|
||||||
|
state: started
|
||||||
|
|
||||||
- name: Wait for container to be reachable
|
- name: Wait for container to be reachable
|
||||||
wait_for:
|
wait_for:
|
||||||
host: "{{ container_ip_cidr | split('/') | first }}"
|
host: "{{ container_ip_cidr | split('/') | first }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user