Markus Katharina Brechtel пре 8 година
родитељ
комит
94a32cf9b3
4 измењених фајлова са 61 додато и 4 уклоњено
  1. +1
    -0
      defaults/main.yml
  2. +8
    -4
      tasks/main.yml
  3. +49
    -0
      templates/network-interfaces.j2
  4. +3
    -0
      templates/persistent-net.rules.j2

+ 1
- 0
defaults/main.yml Прегледај датотеку

@@ -0,0 +1 @@
#network_interfaces_default_interface: "{{ undefined | default(ansible_default_ipv6.interface) | default(ansible_default_ipv4.interface) }}"

+ 8
- 4
tasks/main.yml Прегледај датотеку

@@ -1,7 +1,11 @@
---
- setup:

- debug: msg={{ hostvars[inventory_hostname] }}
- name: network interfaces configuration
template:
src: network-interfaces.j2
dest: "{{ root_target_directory | default('') }}/etc/network/interfaces"

#- name: network interface configuration
# template: src=interface.j2 dest={{ network_config_target }}/etc
#- name: persistent net rules
# template:
# src: persistent-net.rules.j2
# dest: "{{ network_interfaces_target }}/etc/udev/rules.d/z25_persistent-net.rules"

+ 49
- 0
templates/network-interfaces.j2 Прегледај датотеку

@@ -0,0 +1,49 @@
# interfaces(5) file used by ifup(8) and ifdown(8)

{{ ansible_managed | comment }}

auto lo
iface lo inet loopback

{% for netname,netif in network_interfaces.iteritems() %}
### {{ netname }} ###
auto {{ netif.device }}
allow-hotplug {{ netif.device }}

{% if netif.bridge is defined %}
iface {{ netif.device }} inet manual
bridge_ports {{ netif.bridge.ports | join(" ") }}
bridge_stp {{ netif.bridge.stp | default(false) | ternary('on','off') }}
{% endif %}

{% for ipv6 in netif.ipv6 | default([]) %}
iface {{ netif.device }} inet6 {{ ipv6.method }}
{% if ipv6.method == "static" %}
address {{ ipv6.address | ipv6('address') }}
netmask {{ ipv6.address | ipv6('prefix') }}
{% if ipv6.gateway is defined %}
gateway {{ ipv6.gateway | ipv6('address') }}
{% endif %}
{% endif %}
{% endfor %}

{% for ipv4 in netif.ipv4 | default([]) %}
iface {{ netif.device }} inet {{ ipv4.method }}
{% if ipv4.method == "static" %}
address {{ ipv4.address | ipv4('address') }}
network {{ ipv4.address | ipv4('network') }}
netmask {{ ipv4.address | ipv4('netmask') }}
broadcast {{ ipv4.address | ipv4('broadcast') }}
{% if ipv4.gateway is defined %}
gateway {{ ipv4.gateway | ipv4('address') }}
{% endif %}
{% if ipv4.gateway is defined %}
gateway {{ ipv4.gateway | ipv4('address') }}
{% endif %}
{% endif %}
{% endfor %}

{% endfor %}

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

+ 3
- 0
templates/persistent-net.rules.j2 Прегледај датотеку

@@ -0,0 +1,3 @@
{% for netif in network_interfaces %}
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="{{ netif.mac_address }}", ATTR{type}=="1", KERNEL=="eth*", NAME="{{ netif.device }}"
{% endfor %}

Loading…
Откажи
Сачувај