Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions vm-setup/roles/common/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ networks:
dhcp_range_v6:
- "{{ virsh_dhcp_v6_start }}"
- "{{ virsh_dhcp_v6_end }}"
# libvirt defaults to minutes as the unit
lease_expiry: 60
nat_port_range:
- 1024
- 65535
Expand Down
8 changes: 6 additions & 2 deletions vm-setup/roles/libvirt/templates/network.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
{% set ironic_name = ironic_prefix + flavor + "_" + num|string %}
{% set hostname_format = lookup('vars', flavor + '_hostname_format', default=flavor + '-%d') %}
{% set hostname = hostname_format % num %}
<host mac='{{ node_mac_map.get(ironic_name).get(item.name)}}' name='{{hostname}}' ip='{{item.dhcp_range_v4[0]|ipmath(ns.index|int)}}'/>
<host mac='{{ node_mac_map.get(ironic_name).get(item.name)}}' name='{{hostname}}' ip='{{item.dhcp_range_v4[0]|ipmath(ns.index|int)}}'>
<lease expiry='{{ item.lease_expiry }}'/>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be conditional on item.lease_expiry being defined?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a default for lease_expiry so it should always be set.

</host>
{% set ns.index = ns.index + 1 %}
{% endfor %}
{% endfor %}
Expand Down Expand Up @@ -88,7 +90,9 @@
{% set ironic_name = ironic_prefix + flavor + "_" + num|string %}
{% set hostname_format = lookup('vars', flavor + '_hostname_format', default=flavor + '-%d') %}
{% set hostname = hostname_format % num %}
<host id='00:03:00:01:{{ node_mac_map.get(ironic_name).get(item.name)}}' name='{{hostname}}' ip='{{item.dhcp_range_v6[0]|ipmath(ns.index|int)}}'/>
<host id='00:03:00:01:{{ node_mac_map.get(ironic_name).get(item.name)}}' name='{{hostname}}' ip='{{item.dhcp_range_v6[0]|ipmath(ns.index|int)}}'>
<lease expiry='{{ item.lease_expiry }}'/>
</host>
{% set ns.index = ns.index + 1 %}
{% endfor %}
{% endfor %}
Expand Down