diff options
author | binary <me@rgoncalves.se> | 2020-11-07 20:38:07 +0100 |
---|---|---|
committer | binary <me@rgoncalves.se> | 2020-11-07 20:38:07 +0100 |
commit | 352c98322771af117a85904d580e1c062062d634 (patch) | |
tree | d3bca9d27d6ee5d678264d83fc22030d274f30bf /roles/vmm/templates | |
parent | 282be811d2ac07a76d56ac066df5bf33d748bd64 (diff) | |
download | infrastructure-352c98322771af117a85904d580e1c062062d634.tar.gz |
Refactor vmm role with automation
Diffstat (limited to 'roles/vmm/templates')
-rw-r--r-- | roles/vmm/templates/hostname.j2 | 1 | ||||
-rw-r--r-- | roles/vmm/templates/vm.conf.j2 | 16 |
2 files changed, 9 insertions, 8 deletions
diff --git a/roles/vmm/templates/hostname.j2 b/roles/vmm/templates/hostname.j2 new file mode 100644 index 0000000..68b989a --- /dev/null +++ b/roles/vmm/templates/hostname.j2 @@ -0,0 +1 @@ +add {{ vmm.switch.interface_host }} diff --git a/roles/vmm/templates/vm.conf.j2 b/roles/vmm/templates/vm.conf.j2 index 88be7fb..2665c16 100644 --- a/roles/vmm/templates/vm.conf.j2 +++ b/roles/vmm/templates/vm.conf.j2 @@ -1,22 +1,22 @@ #jinja2: trim_blocks: True, lstrip_blocks: True -{% for vm in vm.hosts %} -{% set vm = hostvars[vm] %} +{% for vm in vms if hostvars[vm.name] is defined %} +{% set guest = hostvars[vm.name] %} -vm "{{ vm.ansible_host }}" { - {% if vm.enabled %} +vm "{{ guest.ansible_host }}" { + {% if vm.enabled and vm.enabled is defined %} enable {% else %} disable {% endif %} memory {{ vm.memory }} - disk "{{ vmm.disk.dir }}/{{ vm.ansible_host }}.{{ vmm.disk.format }}" + disk "{{ vmm.disk_dir }}/{{ guest.ansible_host }}.{{ vmm.disk_format }}" interface { - switch "{{ vmm.config.switch.name }}" + switch "{{ vmm.switch.name }}" } } {% endfor %} -switch "{{ vmm.config.switch.name }}" { - interface {{ vmm.config.switch.interface }} +switch "{{ vmm.switch.name }}" { + interface {{ vmm.switch.interface }} } |