diff --git a/lib/ansible/modules/network/net_vrf.py b/lib/ansible/modules/network/net_vrf.py
new file mode 100644
index 00000000000..36178e058ce
--- /dev/null
+++ b/lib/ansible/modules/network/net_vrf.py
@@ -0,0 +1,74 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2017, Ansible by Red Hat, inc
+#
+# This file is part of Ansible by Red Hat
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see .
+#
+
+ANSIBLE_METADATA = {'metadata_version': '1.0',
+ 'status': ['preview'],
+ 'supported_by': 'core'}
+
+
+DOCUMENTATION = """
+---
+module: net_vrf
+version_added: "2.4"
+author: "Ricardo Carrillo Cruz (@rcarrillocruz)"
+short_description: Manage VRFs on network devices
+description:
+ - This module provides declarative management of VRFs
+ on network devices.
+options:
+ name:
+ description:
+ - Name of the VRF.
+ interfaces:
+ description:
+ - List of interfaces the VRF should be configured on.
+ collection:
+ description: List of VRFs definitions
+ purge:
+ description:
+ - Purge VRFs not defined in the collections parameter.
+ default: no
+ state:
+ description:
+ - State of the VRF configuration.
+ default: present
+ choices: ['present', 'absent']
+"""
+
+EXAMPLES = """
+- name: Create VRF named MANAGEMENT
+ net_vrf:
+ name: MANAGEMENT
+
+- name: remove VRF named MANAGEMENT
+ net_vrf:
+ name: MANAGEMENT
+ state: absent
+"""
+
+RETURN = """
+commands:
+ description: The list of configuration mode commands to send to the device
+ returned: always
+ type: list
+ sample:
+ - vrf definition MANAGEMENT
+"""
diff --git a/lib/ansible/plugins/action/net_vrf.py b/lib/ansible/plugins/action/net_vrf.py
new file mode 100644
index 00000000000..cad73f8a26a
--- /dev/null
+++ b/lib/ansible/plugins/action/net_vrf.py
@@ -0,0 +1,27 @@
+# (c) 2017, Ansible Inc,
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see .
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+from ansible.plugins.action.net_base import ActionModule as _ActionModule
+
+
+class ActionModule(_ActionModule):
+ def run(self, tmp=None, task_vars=None):
+ result = super(ActionModule, self).run(tmp, task_vars)
+
+ return result
diff --git a/test/integration/platform_agnostic.yaml b/test/integration/platform_agnostic.yaml
index 7f5369f07ae..70c2293eaa0 100644
--- a/test/integration/platform_agnostic.yaml
+++ b/test/integration/platform_agnostic.yaml
@@ -13,3 +13,4 @@
- { role: net_command, when: "limit_to in ['*', 'net_command']" }
- { role: net_user, when: "limit_to_in ['*', 'net_user']" }
- { role: net_vlan, when: "limit_to in ['*', 'net_vlan']" }
+ - { role: net_vrf, when: "limit_to_in ['*', 'net_vrf']" }
diff --git a/test/integration/targets/net_vrf/aliases b/test/integration/targets/net_vrf/aliases
new file mode 100644
index 00000000000..93151a8d9df
--- /dev/null
+++ b/test/integration/targets/net_vrf/aliases
@@ -0,0 +1 @@
+network/ci
diff --git a/test/integration/targets/net_vrf/defaults/main.yaml b/test/integration/targets/net_vrf/defaults/main.yaml
new file mode 100644
index 00000000000..5f709c5aac1
--- /dev/null
+++ b/test/integration/targets/net_vrf/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/net_vrf/tasks/cli.yaml b/test/integration/targets/net_vrf/tasks/cli.yaml
new file mode 100644
index 00000000000..46d86dd6988
--- /dev/null
+++ b/test/integration/targets/net_vrf/tasks/cli.yaml
@@ -0,0 +1,16 @@
+---
+- name: collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/net_vrf/tasks/main.yaml b/test/integration/targets/net_vrf/tasks/main.yaml
new file mode 100644
index 00000000000..415c99d8b12
--- /dev/null
+++ b/test/integration/targets/net_vrf/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
diff --git a/test/integration/targets/net_vrf/tests/cli/basic.yaml b/test/integration/targets/net_vrf/tests/cli/basic.yaml
new file mode 100644
index 00000000000..ed9c8327e79
--- /dev/null
+++ b/test/integration/targets/net_vrf/tests/cli/basic.yaml
@@ -0,0 +1,7 @@
+---
+- debug: msg="START cli/set_name_servers.yaml"
+
+- include: "{{ role_path }}/tests/eos/basic.yaml"
+ when: hostvars[inventory_hostname]['ansible_network_os'] == 'eos'
+
+- debug: msg="END cli/set_name_servers.yaml"
diff --git a/test/integration/targets/net_vrf/tests/eos/basic.yaml b/test/integration/targets/net_vrf/tests/eos/basic.yaml
new file mode 100644
index 00000000000..ded44ccf601
--- /dev/null
+++ b/test/integration/targets/net_vrf/tests/eos/basic.yaml
@@ -0,0 +1,116 @@
+---
+
+- name: setup - remove vrf
+ eos_vrf:
+ name: test
+ state: absent
+ authorize: yes
+ provider: "{{ cli }}"
+
+- name: Create vrf
+ net_vrf:
+ name: test
+ rd: 1:200
+ state: present
+ authorize: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'vrf definition test' in result.commands"
+ - "'rd 1:200' in result.commands"
+ # Ensure sessions contains epoc. Will fail after 18th May 2033
+ - "'ansible_1' in result.session_name"
+
+- name: Create vrf again (idempotent)
+ net_vrf:
+ name: test
+ rd: 1:200
+ state: present
+ authorize: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.commands | length == 0"
+ # Ensure sessions contains epoc. Will fail after 18th May 2033
+ - "result.session_name is not defined"
+
+- name: Modify rd
+ net_vrf:
+ name: test
+ rd: 1:201
+ state: present
+ authorize: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'vrf definition test' in result.commands"
+ - "'rd 1:201' in result.commands"
+ # Ensure sessions contains epoc. Will fail after 18th May 2033
+ - "'ansible_1' in result.session_name"
+
+- name: Modify rd again (idempotent)
+ net_vrf:
+ name: test
+ rd: 1:201
+ state: present
+ authorize: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.commands | length == 0"
+ # Ensure sessions contains epoc. Will fail after 18th May 2033
+ - "result.session_name is not defined"
+
+- name: Add Ethernet2 to vrf
+ net_vrf:
+ name: test
+ rd: 1:201
+ state: present
+ authorize: yes
+ interfaces:
+ - Ethernet2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'interface Ethernet2' in result.commands"
+ - "'vrf forwarding test' in result.commands"
+ # Ensure sessions contains epoc. Will fail after 18th May 2033
+ - "'ansible_1' in result.session_name"
+
+- name: Add Ethernet2 to vrf again (idempotent)
+ net_vrf:
+ name: test
+ rd: 1:201
+ state: present
+ authorize: yes
+ interfaces:
+ - Ethernet2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.commands | length == 0"
+ # Ensure sessions contains epoc. Will fail after 18th May 2033
+ - "result.session_name is not defined"
+
+
+# FIXME add in tests for everything defined in docs
+# FIXME Test state:absent + test:
+# FIXME Without powers ensure "privileged mode required"