playbook_provision_hyper01: generify playbook
now we read the containers to create dynamically from the inventory
This commit is contained in:
parent
24a31603ef
commit
e350445a4b
|
@ -19,4 +19,9 @@ hyper01 ip=10.84.1.21
|
||||||
|
|
||||||
[vms]
|
[vms]
|
||||||
eae-adp-jump01 ip=162.55.53.85 monitoring_ip=10.84.254.0 ansible_python_interpreter=/usr/local/bin/python3
|
eae-adp-jump01 ip=162.55.53.85 monitoring_ip=10.84.254.0 ansible_python_interpreter=/usr/local/bin/python3
|
||||||
monitoring01 ip=10.84.1.51
|
|
||||||
|
[container]
|
||||||
|
monitoring01 ip=10.84.1.51 cpus=2 disk=50 memory=1024 net='{"net0":"name=eth0,ip=10.84.1.51/24,gw=10.84.1.1,bridge=vmbr0"}'
|
||||||
|
|
||||||
|
[container:vars]
|
||||||
|
ostemplate=local:vztmpl/debian-11-standard_11.3-1_amd64.tar.zst
|
||||||
|
|
|
@ -1,25 +1,38 @@
|
||||||
---
|
---
|
||||||
- name: create vms/container
|
- name: provision containers
|
||||||
hosts: 127.0.0.1
|
hosts: 127.0.0.1
|
||||||
connection: local
|
connection: local
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
vars:
|
||||||
|
proxmox_host: "hyper01"
|
||||||
tasks:
|
tasks:
|
||||||
- name: create monitoring01
|
- name: create containers
|
||||||
proxmox:
|
proxmox:
|
||||||
api_user: root@pam
|
api_user: root@pam
|
||||||
api_password: "{{ lookup('passwordstore', 'server/hyper01') }}"
|
api_password: "{{ lookup('passwordstore', 'server/{{ proxmox_host }}') }}"
|
||||||
api_host: "{{ hostvars['hyper01']['ip'] }}"
|
api_host: "{{ hostvars[proxmox_host]['ip'] }}"
|
||||||
node: hyper01
|
node: "{{ proxmox_host }}"
|
||||||
hostname: monitoring01
|
hostname: "{{ item }}"
|
||||||
onboot: yes
|
onboot: yes
|
||||||
cpus: 2
|
cpus: "{{ hostvars[item]['cpus'] }}"
|
||||||
disk: 50
|
disk: "{{ hostvars[item]['disk'] }}"
|
||||||
memory: 1024
|
memory: "{{ hostvars[item]['memory'] }}"
|
||||||
storage: 'local-zfs'
|
storage: 'local-zfs'
|
||||||
ostemplate: 'local:vztmpl/debian-11-standard_11.3-1_amd64.tar.zst'
|
ostemplate: "{{ hostvars[item]['ostemplate'] }}"
|
||||||
password: "{{ lookup('passwordstore', 'vms/monitoring01/root') }}"
|
password: "{{ lookup('passwordstore', 'vms/{{ item }}/root') }}"
|
||||||
pubkey: "{{ lookup('ansible.builtin.file', 'files/authorized_keys') }}"
|
pubkey: "{{ lookup('ansible.builtin.file', 'files/authorized_keys') }}"
|
||||||
netif: '{"net0":"name=eth0,ip=10.84.1.51/24,gw=10.84.1.1,bridge=vmbr0"}'
|
netif: "{{ hostvars[item]['net'] }}"
|
||||||
unprivileged: yes
|
unprivileged: yes
|
||||||
features:
|
features:
|
||||||
- nesting=1
|
- nesting=1
|
||||||
|
with_items: "{{ groups['container'] }}"
|
||||||
|
|
||||||
|
- name: start containers
|
||||||
|
proxmox:
|
||||||
|
api_user: root@pam
|
||||||
|
api_password: "{{ lookup('passwordstore', 'server/{{ proxmox_host }}') }}"
|
||||||
|
api_host: "{{ hostvars[proxmox_host]['ip'] }}"
|
||||||
|
node: "{{ proxmox_host }}"
|
||||||
|
hostname: "{{ item }}"
|
||||||
|
state: started
|
||||||
|
with_items: "{{ groups['container'] }}"
|
||||||
|
|
Reference in New Issue