mirror of
https://github.com/inofix/common-playbooks.git
synced 2026-02-05 12:45:29 +01:00
34 lines
1.6 KiB
YAML
34 lines
1.6 KiB
YAML
#* This playbook creates a vm on a KVM host (via virt-install for now).
|
|
#* Currently only debian jessie on amd64 via preseed is supported, extending
|
|
#* should not be too difficult, but we had to start somewhere..
|
|
#* The playbook is intended to be used by 'maestro', which gets the necessary
|
|
#* 'host' dict with the vm info from the knowledge base (reclass-inventory),
|
|
#* the 'new__hostname' parameter can be provided as the first argument after
|
|
#* the name of the play (See Maestro Examples below).
|
|
#* Use '-a' to pass parameters to ansible (as '-e'). See ansible fetch for
|
|
#* details.
|
|
#* The following arguments are mandatory:
|
|
#* - 'new__hostname'
|
|
#* - 'host' (dict)
|
|
#* Maestro Examples:
|
|
#* * Create a VM called <newhost> on <kvmhost>
|
|
#* `$ maestro.sh -H <kvmhost> ansible-play create-vm "new__hostname=<newhost>"`
|
|
|
|
- hosts: host.KVM
|
|
vars:
|
|
new: '{{ host.resource[new__hostname] }}'
|
|
new__system_disk_tmp: '{{ new.disk | selectattr("system") | first() }}'
|
|
# TODO why does attr() not work as expected?
|
|
new__system_disk:
|
|
bus: '{{ host.virt.storage[new__system_disk_tmp.meta.pool].bus }}'
|
|
cache: '{{ host.virt.storage[new__system_disk_tmp.meta.pool].cache }}'
|
|
name: '{{ new__system_disk_tmp.name }}'
|
|
path: '{{ new__system_disk_tmp.path }}'
|
|
pool: '{{ new__system_disk_tmp.meta.pool }}'
|
|
target: '{{ host.virt.storage[new__system_disk_tmp.meta.pool].path }}/{{ new__hostname }}-{{ new__system_disk_tmp.name }}'
|
|
new__system_net: '{{ new.net | selectattr("primary") | first() }}'
|
|
os__installer_files: '{{ os__installer_base[new.os.distro][new.os.codename][new.arch] }}'
|
|
roles:
|
|
- virt-install
|
|
|