network: Playbook to configure networking
The `network.yml` playbook is used to configure the network interfaces on a managed node. Currently, it only supports the Red Hat configuration style (i.e. `/etc/sysconfig/network-scripts/ifcfg-*` files).jenkins-master
parent
7de51f4bc5
commit
2a5b257943
|
@ -0,0 +1,3 @@
|
|||
- hosts: RedHat
|
||||
roles:
|
||||
- rhel-network
|
|
@ -0,0 +1,2 @@
|
|||
default_bond_opts:
|
||||
miimon: 100
|
|
@ -0,0 +1,5 @@
|
|||
- name: restart network
|
||||
service:
|
||||
name=network
|
||||
state=restarted
|
||||
when: not no_restart_network|d|bool
|
|
@ -0,0 +1,13 @@
|
|||
- name: ensure network devices are configured
|
||||
template:
|
||||
src=ifcfg.j2
|
||||
dest=/etc/sysconfig/network-scripts/ifcfg-{{ item.ifname }}
|
||||
mode=0644
|
||||
with_items: '{{ network.interfaces }}'
|
||||
notify: restart network
|
||||
|
||||
- name: ensure ignored devices are not configured
|
||||
file:
|
||||
path=/etc/sysconfig/network-scripts/ifcfg-{{ item }}
|
||||
state=absent
|
||||
with_items: '{{ network.ignore_interfaces|d(()) }}'
|
|
@ -0,0 +1,59 @@
|
|||
{#- vim: set ft=jinja : -#}
|
||||
DEVICE="{{ item.ifname }}"
|
||||
{% if item.enabled %}
|
||||
ONBOOT="yes"
|
||||
{% else %}
|
||||
ONBOOT="no"
|
||||
{% endif %}
|
||||
|
||||
{% if item.mode == "auto" %}
|
||||
BOOTPROTO="dhcp"
|
||||
{% elif item.mode == "manual" %}
|
||||
BOOTPROTO="none"
|
||||
IPADDR="{{ item.addr }}"
|
||||
{% if item.mask is defined %}
|
||||
NETMASK="{{ item.mask }}"
|
||||
{% else %}
|
||||
PREFIX={{ item.prefix|d(24) }}
|
||||
{% endif %}
|
||||
{% if item.gateway is defined %}
|
||||
GATEWAY="{{ item.gateway }}"
|
||||
{% endif %}
|
||||
{% for dns in item.dns|d(()) %}
|
||||
DNS{{ loop.index }}="{{ dns }}"
|
||||
{% endfor %}
|
||||
{% if item.addr6 is defined %}
|
||||
IPV6ADDR="{{ item.addr6 }}"
|
||||
{% endif %}
|
||||
{% else %}
|
||||
BOOTPROTO="none"
|
||||
{% endif %}
|
||||
{% if item.dhcpv6 is defined %}
|
||||
{% if item.dhcpv6.enabled|d(True) %}
|
||||
DHCPV6C="yes"
|
||||
{% if item.dhcpv6.stateless|d(False) %}
|
||||
DHCPV6C_OPTIONS="-S"
|
||||
{% elif item.dhcpv6.temporary|d(False) %}
|
||||
DHCPV6C_OPTIONS="-T"
|
||||
{% elif item.dhcpv6.pd|d(False) %}
|
||||
DHCPV6C_OPTIONS="-P"
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if item.master|d %}
|
||||
|
||||
SLAVE=yes
|
||||
MASTER={{ item.master }}
|
||||
{% endif %}
|
||||
{% if item.bond_opts|d %}
|
||||
|
||||
BONDING_OPTS="{% for key, value in default_bond_opts|combine(item.bond_opts)|dictsort %}{{ key }}={{ value }}{% if not loop.last %} {% endif %}{% endfor %}"
|
||||
{% endif %}
|
||||
{% if item.vlan_id|d %}
|
||||
|
||||
VLAN=yes
|
||||
VID={{ item.vlan_id }}
|
||||
{% if item.physdev|d %}
|
||||
PHYSDEV={{ item.physdev }}
|
||||
{% endif %}
|
||||
{% endif %}
|
Loading…
Reference in New Issue