diff --git a/README.md b/README.md index 731f98b901d69ff9990f5a28d56b8af0c6ec2960..f77255b4b93b9fe47a932ea0cc522e17ae75eb01 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Ansible role - Interface - BETA (only for Ansible 2.3.3.0) +# Ansible role - Interface (only for Ansible 2.3.3.0) This role serves for network interface configuration on debian-based systems. @@ -19,22 +19,22 @@ This role serves for network interface configuration on debian-based systems. Mandatory parameters. * `interface_interfaces` - The list of network interface parameters. Each interface may consists of following attributes. - * `interface_mac` (mandatory) - . - * `interface_default_gateway` (optional) - . + * `interface_mac` (mandatory) - The MAC address of interface to configure. + * `interface_default_gateway` (optional) - The IPv4 address of default gateway. * `interface_routes` (optional) - The list of route parameters. Each route must consist of following attributes. - * `gateway` (mandatory) - . - * `network` (mandatory) - . - * `mask` (mandatory) - . + * `gateway` (mandatory) - The IPv4 address of default gateway for this route. + * `network` (mandatory) - The IP address of network from which pakets will be routed. + * `mask` (mandatory) - The subnet mask in address format or prefix number. Optional parameters. -* `interface_clean` - . -* `interface_mtu` - . -* `interface_file_name` - . +* `interface_clean` - Boolean value (**True**/**False**) that means whether to clean all interface configuration before applying role or not. +* `interface_mtu` - The number of maximum transmission unit. +* `interface_file_name` - The file name for your configuration located in `/etc/network/interfaces.d/` directory. ## Example -Example of the simplest network interface configuration that +Example of the simplest network interface configuration that just set MTU of specified interface. ```yml roles: diff --git a/defaults/main.yml b/defaults/main.yml index eecf4aa7db4b065f9e9adff5f07e79275219127d..51a9d6c35f98874ab016f7e898ce82d00d8c8da3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,7 +2,12 @@ interface_default_file: /etc/network/interfaces interface_directory: '{{ interface_default_file }}.d' interface_file_name: -interface_file: '{% if interface_file_name is defined and interface_file_name %}{{ interface_directory }}/{{ interface_file_name }}{% else %}{{ interface_default_file }}{% endif %}' +interface_file: ' + {%- if interface_file_name is defined and interface_file_name -%} + {{ interface_directory }}/{{ interface_file_name }} + {%- else -%} + {{ interface_default_file }} + {%- endif %}' interface_clean: True interface_mtu: 1442 diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..58ecda581c150aac8a05d5d99e63955a1cae7073 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,19 @@ + +dependencies: + - src: git@gitlab.ics.muni.cz:CSIRT-MU-public/ansible-roles/common.git + scm: git + +galaxy_info: + role_name: interface + author: Kamil Andoniadis + description: Basic network interface configuration + licence: MIT + min_ansible_version: 2.3.3 + platforms: + - name: Debian + versions: + - all + - name: Ubuntu + versions: + - all + diff --git a/tasks/main-interface.yml b/tasks/main-interface.yml index 9e198ec66ad8ff50574238f338316a03bdf0c245..8fb3a4bfb90aa9d7065a65701c03d91428b5fa7c 100644 --- a/tasks/main-interface.yml +++ b/tasks/main-interface.yml @@ -5,7 +5,7 @@ when: not interface_mac - set_fact: - interface_device: '{%- from "templates/network.j2" import mac_to_interface with context -%} + interface_device: '{%- from "roles/common/templates/network.j2" import mac_to_interface with context -%} {{ mac_to_interface(interface_mac) | default("") }}' - include: clean.yml