Skip to content

Commit 4512410

Browse files
committed
Make clock offset configurable
Requested in PR feedback; this allows offset to be set per site and overriden per instance.
1 parent dc7a438 commit 4512410

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Role Variables
3636
- `libvirt_vm_virsh_default_env`: Variables contained within this dictionary are
3737
added to the environment used when executing virsh commands.
3838

39+
- `libvirt_vm_clock_offset`. If defined the instances clock offset is set to
40+
the provided value. When undefined sync is set to `localtime`.
41+
3942
- `libvirt_vms`: list of VMs to be created/destroyed. Each one may have the
4043
following attributes:
4144

@@ -55,6 +58,8 @@ Role Variables
5558
`libvirt_vm_engine` is `kvm`, otherwise `host-model`. Can be set to none
5659
to not configure a cpu mode.
5760

61+
- `clock_offset`: Overrides default set in `libvirt_vm_clock_offset`
62+
5863
- `volumes`: a list of volumes to attach to the VM. Each volume is
5964
defined with the following dict:
6065
- `pool`: Name or UUID of the storage pool from which the volume should be

defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ libvirt_vm_engine:
3535
# correct emulator to use.
3636
libvirt_vm_emulator:
3737

38+
# Default value for clock syncing. The default (false) uses <clock sync="localtime">
39+
# to configure the instances clock synchronisation. Change to a timezone to make
40+
# configuration use <clock offset="specified offset">
41+
libvirt_vm_clock_offset: False
42+
3843
# A list of specifications of VMs to be created.
3944
# For backwards compatibility, libvirt_vms defaults to a singleton list using
4045
# the values of the deprecated variables below.

templates/vm.xml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
<name>{{ vm.name }}</name>
33
<memory>{{ vm.memory_mb | int * 1024 }}</memory>
44
<vcpu>{{ vm.vcpus }}</vcpu>
5+
{% if vm.clock_offset |default({{ libvirt_vm_clock_offset }}) %}
56
<clock offset="{{ vm.clock_offset }}"/>
7+
{% else %}
8+
<clock sync="localtime"/>
9+
{% endif %}
610
<on_poweroff>destroy</on_poweroff>
711
<on_reboot>restart</on_reboot>
812
<on_crash>destroy</on_crash>

0 commit comments

Comments
 (0)