Combine interfaces and network_ether_interfaces into one common variable network_interfaces. Provisioning uses format: network_interfaces: - device: device name eg. vio0 or eth0 vlan: vlan id for this interface mac: mac address for interface (optional) Additionally network role will use more settings to configure interface.
37 lines
952 B
YAML
37 lines
952 B
YAML
---
|
|
|
|
- name: create ethernet interface configurations
|
|
template:
|
|
src: hostname.if.j2
|
|
dest: "/etc/hostname.{{ item.device }}"
|
|
mode: 0600
|
|
owner: root
|
|
group: "{{ ansible_wheel }}"
|
|
with_items: "{{ network_interfaces }}"
|
|
notify: restart network
|
|
|
|
- block:
|
|
- name: create carp interface configurations
|
|
template:
|
|
src: hostname.carp.j2
|
|
dest: "/etc/hostname.carp{{ item.vhid }}"
|
|
mode: 0600
|
|
owner: root
|
|
group: "{{ ansible_wheel }}"
|
|
with_items: "{{ network_carp_interfaces }}"
|
|
notify: restart network
|
|
- name: enable carp preempt
|
|
sysctl:
|
|
name: net.inet.carp.preempt
|
|
value: 1
|
|
when: network_carp_interfaces != []
|
|
|
|
- name: set default gateway
|
|
copy:
|
|
content: "{{ network_default_gateway }}\n"
|
|
dest: /etc/mygate
|
|
mode: 0600
|
|
owner: root
|
|
group: "{{ ansible_wheel }}"
|
|
notify: restart network
|
|
when: network_default_gateway is defined
|