2022-07-02 23:25:54 +00:00
|
|
|
---
|
2022-09-14 00:56:05 +00:00
|
|
|
- name: provision containers
|
2022-07-02 23:25:54 +00:00
|
|
|
hosts: 127.0.0.1
|
|
|
|
connection: local
|
|
|
|
gather_facts: no
|
2022-09-14 00:56:05 +00:00
|
|
|
vars:
|
|
|
|
proxmox_host: "hyper01"
|
2022-07-02 23:25:54 +00:00
|
|
|
tasks:
|
2022-09-14 00:56:05 +00:00
|
|
|
- name: create containers
|
2022-07-02 23:25:54 +00:00
|
|
|
proxmox:
|
|
|
|
api_user: root@pam
|
2022-09-14 00:56:05 +00:00
|
|
|
api_password: "{{ lookup('passwordstore', 'server/{{ proxmox_host }}') }}"
|
|
|
|
api_host: "{{ hostvars[proxmox_host]['ip'] }}"
|
|
|
|
node: "{{ proxmox_host }}"
|
|
|
|
hostname: "{{ item }}"
|
2022-07-02 23:25:54 +00:00
|
|
|
onboot: yes
|
2022-09-14 00:56:05 +00:00
|
|
|
cpus: "{{ hostvars[item]['cpus'] }}"
|
|
|
|
disk: "{{ hostvars[item]['disk'] }}"
|
|
|
|
memory: "{{ hostvars[item]['memory'] }}"
|
2022-07-02 23:25:54 +00:00
|
|
|
storage: 'local-zfs'
|
2022-09-14 00:56:05 +00:00
|
|
|
ostemplate: "{{ hostvars[item]['ostemplate'] }}"
|
2022-09-14 00:58:42 +00:00
|
|
|
password: "{{ lookup('passwordstore', 'container/{{ item }}/root') }}"
|
2022-07-02 23:25:54 +00:00
|
|
|
pubkey: "{{ lookup('ansible.builtin.file', 'files/authorized_keys') }}"
|
2022-09-14 00:56:05 +00:00
|
|
|
netif: "{{ hostvars[item]['net'] }}"
|
2022-07-02 23:25:54 +00:00
|
|
|
unprivileged: yes
|
|
|
|
features:
|
|
|
|
- nesting=1
|
2022-09-14 00:56:05 +00:00
|
|
|
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'] }}"
|