From e2224bc45ef49ec721f3afb702ebf867eb6b26b8 Mon Sep 17 00:00:00 2001
From: Kamil Andoniadis <374100@mail.muni.cz>
Date: Wed, 29 May 2019 17:53:15 +0000
Subject: [PATCH] Resolve "Prepare role for using with Ansible Galaxy"

---
 README.md                | 20 ++++++++++----------
 defaults/main.yml        |  7 ++++++-
 meta/main.yml            | 19 +++++++++++++++++++
 tasks/main-interface.yml |  2 +-
 4 files changed, 36 insertions(+), 12 deletions(-)
 create mode 100644 meta/main.yml

diff --git a/README.md b/README.md
index 731f98b..f77255b 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 eecf4aa..51a9d6c 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 0000000..58ecda5
--- /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 9e198ec..8fb3a4b 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
-- 
GitLab