Browse Source

libvirt: implement libvirt_disk

keep-around/c749928a1720ab2ff5103d0a3809ba9476abcd30
Loïc Dachary 5 months ago
parent
commit
c749928a17
Signed by: dachary GPG Key ID: 992D23B392F9E4F2
  1. 15
      enough/common/libvirt.py
  2. 2
      inventory/group_vars/all/libvirt.yml
  3. 1
      inventory/host_vars/forum-host/provision.yml
  4. 1
      inventory/host_vars/gitlab-host/provision.yml
  5. 1
      inventory/host_vars/openedx-host/provision.yml
  6. 1
      inventory/host_vars/packages-host/provision.yml
  7. 1
      inventory/host_vars/runner-host/provision.yml

15
enough/common/libvirt.py

@ -61,6 +61,14 @@ class Libvirt(object):
'bash -x /root/network.sh'),
)
def resize(self, name, definition):
sh.qemu_img.create('-f', 'qcow2', '-o', 'preallocation=metadata',
self.host_image_name(name), definition['disk'])
sh.virt_resize(
'--expand', '/dev/sda1',
self.image_name(),
self.host_image_name(name))
def get(self, name):
try:
return self.lv.lookupByName(name)
@ -79,7 +87,8 @@ class Libvirt(object):
return info
log.info(f"{name}: building image")
self.image_builder()
sh.cp('--sparse=always', self.image_name(), self.host_image_name(name))
log.info(f"{name}: copy and resize image")
self.resize(name, definition)
log.info(f"{name}: preparing image")
self.sysprep(name, definition)
log.info(f"{name}: creating host")
@ -149,7 +158,7 @@ class Libvirt(object):
'name': name,
'port': definition.get('ansible_port', '22'),
'ram': definition.get('libvirt_ram', '2048'),
# 'disk': definition.get('libvirt_disk', '20G'),
'disk': definition.get('libvirt_disk', '20G'),
'network_interface_unconfigured': definition.get('network_interface_unconfigured'),
'network_interface_routed': definition.get('network_interface_routed'),
'network_interface_not_routed': definition.get('network_interface_not_routed'),
@ -172,7 +181,7 @@ class Libvirt(object):
'--no-cache',
'--output', image,
'--format', 'qcow2',
'--size', '20G',
'--size', '6G',
'--install', 'sudo',
'--root-password', 'disabled',
'--run-command', 'dpkg-reconfigure --frontend=noninteractive openssh-server',

2
inventory/group_vars/all/libvirt.yml

@ -1,4 +1,6 @@
---
libvirt_ram: 2048
libvirt_disk: 10G
libvirt_network_external_name: enough-ext
libvirt_network_external_prefix: 10.23.10
libvirt_network_internal_name: enough-int

1
inventory/host_vars/forum-host/provision.yml

@ -1,3 +1,4 @@
---
openstack_flavor: '{{ openstack_flavor_medium }}'
libvirt_ram: 4096
libvirt_disk: 20G

1
inventory/host_vars/gitlab-host/provision.yml

@ -2,3 +2,4 @@
ansible_port: 2222
openstack_flavor: '{{ openstack_flavor_medium }}'
libvirt_ram: 4096
libvirt_disk: 20G

1
inventory/host_vars/openedx-host/provision.yml

@ -1,3 +1,4 @@
---
openstack_flavor: '{{ openstack_flavor_large }}'
libvirt_ram: 8192
libvirt_disk: 40G

1
inventory/host_vars/packages-host/provision.yml

@ -1,3 +1,4 @@
---
openstack_flavor: '{{ openstack_flavor_medium }}'
libvirt_ram: 4096
libvirt_disk: 20G

1
inventory/host_vars/runner-host/provision.yml

@ -1,3 +1,4 @@
---
openstack_flavor: '{{ openstack_flavor_medium }}'
libvirt_ram: 4096
libvirt_disk: 20G
Loading…
Cancel
Save