aboutsummaryrefslogtreecommitdiffstats
path: root/roles/vmm/tasks/network.yml
blob: b5ac4dba34610015c7601307c638b6cadd13e542 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---

- name: start ip forwarding
  ansible.builtin.command: sysctl net.inet.ip{{ item }}.forwarding=1
  loop: "{{ vmm_network_forwarded_ips }}"
  register: result
  changed_when: item ~ "->" ~ item not in result.stdout_lines

- name: enable ip forwarding
  ansible.builtin.lineinfile:
    path: /etc/sysctl.conf
    regexp: "^net.inet.ip{{ item }}.forwarding="
    line: "net.inet.ip{{ item }}.forwarding=1"
    owner: 0
    group: 0
    mode: "0640"
    create: true
  loop: "{{ vmm_network_forwarded_ips }}"

- name: create network switch
  ansible.builtin.lineinfile:
    path: "/etc/hostname.{{ vmm_network_switch.interface }}"
    regexp: &network_line "add {{ ansible_default_ipv4.interface }}"
    line: *network_line
    owner: 0
    group: 0
    mode: "0640"
    create: true

- name: start network switch  # noqa: no-changed-when
  ansible.builtin.command: "sh /etc/netstart {{ vmm_network_switch.interface }}"
remember that computers suck.