Repository: ansible/ansible

Issue:
junos_vrf vrf-table-label support
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report


##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
junos_vrf

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.4.0
  config file = /home/as/projects/ansible-test/ansible.cfg
  configured module search path = [u'/home/as/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/as/projects/ansible-test/local/lib/python2.7/site-packages/ansible
  executable location = /home/as/projects/ansible-test/bin/ansible
  python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118]
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
N/A
##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
N/A
##### SUMMARY
<!--- Explain the problem briefly -->
Incomplete Junos VRF configuration

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->
<!--- Paste example playbooks or commands between quotes below -->

The current implementation of junos_vrf is missing the vrf-table-label tag. This tag causes the JUNOS device to allocate an MPLS label for all of the routes within a VRF (the default behaviour for Cisco/Brocade/Huawei etc), rather than a VPN label per FEC. Without this tag, COS, egress filtering, forwarding traffic to any directly connected subnet and a number of other features are not supported. 


<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```

```



Discussion:

Resolving patch:
diff --git a/lib/ansible/modules/network/junos/junos_vrf.py b/lib/ansible/modules/network/junos/junos_vrf.py
--- a/lib/ansible/modules/network/junos/junos_vrf.py
+++ b/lib/ansible/modules/network/junos/junos_vrf.py
@@ -49,6 +49,11 @@
     description:
       - It configures VRF target community configuration. The target value takes
         the form of C(target:A:B) where C(A) and C(B) are both numeric values.
+  table_label:
+    description:
+      - Causes JUNOS to allocate a VPN label per VRF rather than per VPN FEC.
+        This allows for forwarding of traffic to directly connected subnets, COS
+        Egress filtering etc.
   aggregate:
     description:
       - The set of VRF definition objects to be configured on the remote
@@ -185,7 +190,8 @@ def main():
         interfaces=dict(type='list'),
         target=dict(type='list'),
         state=dict(default='present', choices=['present', 'absent']),
-        active=dict(default=True, type='bool')
+        active=dict(default=True, type='bool'),
+        table_label=dict(default=True, type='bool')
     )
 
     aggregate_spec = deepcopy(element_spec)
@@ -227,6 +233,7 @@ def main():
         ('rd', 'route-distinguisher/rd-type'),
         ('interfaces', 'interface/name'),
         ('target', 'vrf-target/community'),
+        ('table_label', {'xpath': 'vrf-table-label', 'tag_only': True}),
     ])
 
     params = to_param_list(module)


Test patch: