From 05ec7f2022abcd2dc3cf344705b7ee362ae7a9c2 Mon Sep 17 00:00:00 2001 From: Crest Date: Mon, 14 Sep 2020 01:24:17 +0200 Subject: [PATCH] Use ansible ipath to derive /31 and /127 from the guest index --- roles/bhyve-network/tasks/main.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 roles/bhyve-network/tasks/main.yml diff --git a/roles/bhyve-network/tasks/main.yml b/roles/bhyve-network/tasks/main.yml new file mode 100644 index 0000000..c3d77fd --- /dev/null +++ b/roles/bhyve-network/tasks/main.yml @@ -0,0 +1,29 @@ +--- +- name: Describe guest interface + sysrc: + name: 'ifconfig_vmnet{{ item.index }}_descr' + value: 'VM {{ item.name }}' + loop_control: + label: '{{ item.name }} : vmnet{{ item.index }}' + with_items: '{{ bhyve_guests }}' + +- name: Set host IPv4 addresses + sysrc: + name: 'ifconfig_vmnet{{ item.index }}' + value: 'inet {{ bhyve_ipv4 | ipmath(2 * item.index)}}/31' + with_items: '{{ bhyve_guests }}' + +- name: Set host IPv6 addresses + sysrc: + name: 'ifconfig_vmnet{{ item.index }}_ipv6' + value: 'inet6 {{ bhyve_ipv6 | ipmath(2 * item.index)}}/127' + with_items: '{{ bhyve_guests }}' + +- name: Add guest interfaces + sysrc: + name: cloned_interfaces + state: append + value: 'vmnet{{ item.index }}' + loop_control: + label: '{{ item.name }} : vmnet{{ item.index }}' + with_items: '{{ bhyve_guests }}'