Buonanotte
This commit is contained in:
parent
f7723e72dc
commit
aa8d849825
11 changed files with 178 additions and 7 deletions
67
playbooks/create_lxc.yml
Normal file
67
playbooks/create_lxc.yml
Normal file
|
@ -0,0 +1,67 @@
|
|||
- name: Crea container lxc per prosody (xmpp)
|
||||
hosts: proxmox_nodes
|
||||
gather_facts: false
|
||||
vars:
|
||||
root_password: "{{ lookup('env', 'XMPP_PASSWORD') }}"
|
||||
ssh_public_key: "{{ lookup('file', '~/.ssh/ansible.pub') }}"
|
||||
|
||||
|
||||
tasks:
|
||||
|
||||
|
||||
- name: Create LXC
|
||||
community.general.proxmox:
|
||||
api_host: "{{ proxmox_url }}"
|
||||
api_user: "{{ proxmox_user }}"
|
||||
api_password: "{{ proxmox_password }}"
|
||||
vmid: 121
|
||||
node: milan
|
||||
hostname: xmpp
|
||||
ostemplate: "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst"
|
||||
storage: slow1
|
||||
cores: 1
|
||||
memory: 512
|
||||
netif:
|
||||
net0: "name=eth0,bridge=vmbr1,ip=10.10.0.21/16,gw=10.10.0.1"
|
||||
pubkey: "{{ ssh_public_key }}"
|
||||
password: "{{ root_password }}"
|
||||
state: present
|
||||
delegate_to: localhost
|
||||
register: lxc_creation_result #booooh, capiremo questo che vuol dire. Intanto registriamolo... immagino...
|
||||
|
||||
|
||||
- name: Start LXC container
|
||||
community.general.proxmox:
|
||||
api_host: "{{ proxmox_url }}"
|
||||
api_user: "{{ proxmox_user }}"
|
||||
api_password: "{{ proxmox_password }}"
|
||||
vmid: 121
|
||||
node: milan
|
||||
state: started # Tutto questo blocco è riassumibile in questa riga
|
||||
delegate_to: localhost
|
||||
when: lxc_creation_result.changed
|
||||
|
||||
|
||||
# - name: Wait for container SSH to be available
|
||||
# wait_for:
|
||||
# host: 10.10.0.21
|
||||
# port: 22
|
||||
# timeout: 90
|
||||
# delay: 10
|
||||
# delegate_to: localhost
|
||||
# when: lxc_creation_result.changed
|
||||
|
||||
|
||||
- name: Wait until SSH is fully ready
|
||||
ansible.builtin.wait_for_connection:
|
||||
timeout: 180
|
||||
delegate_to: xmpp01
|
||||
|
||||
|
||||
|
||||
- name: Aggiungi container all'inventory dinamico
|
||||
add_host:
|
||||
name: xmpp01
|
||||
ansible_host: "10.10.0.21"
|
||||
groups: lxc_containers
|
||||
when: lxc_creation_result.changed
|
Loading…
Add table
Add a link
Reference in a new issue