Repository: ansible/ansible

Issue:
sros_config difference between lines and src attribute
##### ISSUE TYPE
 - Bug Report
 - Documentation Report

##### COMPONENT NAME
Module sros_config

##### ANSIBLE VERSION
```
$ ansible --version
ansible 2.2.1.0
  config file = /home/nokia/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
Default

##### OS / ENVIRONMENT
```
$ uname --all
Linux srv17 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
```

##### SUMMARY
From documentation point of view it is expected that the behavior of "lines" and "src" attribute is almost the same. Only difference expected is, that src is loading the configuration from configuration file or j2 template - while lines is including the configuration directly into the yaml file.

Seems like, the "lines" attribute is not supporting entering a new configuration context, while this is supported using files/templates. Find example below. Unclear if this is a bug - or if this should just be better described within the module documentation (known limitation).

##### STEPS TO REPRODUCE

Yaml task file used:
```
- name: create vpls service
  sros_config:
    provider: "{{ cli }}"
    lines:
      - description "ansible-created"
      - endpoint "abc" create
      -     description "blub"
      - exit
      - no shutdown
    parents:
      - configure
      - service
      - vpls 1000 customer 1 create
    provider: "{{ cli }}"
    backup: yes
```

##### EXPECTED RESULTS
It is expected that all configuration is created as per ansible yaml file.

##### ACTUAL RESULTS
The "endpoint" description "blub" is not added to the configuration.


Discussion:
cc @privateip @gundalow @Qalthos
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Agreed, this needs to be better documented.  To answer your question, the purpose of lines was intended to only function within a single context unless you are specifying config lines from the top level starting with `configure ...`.  That said, agreed the documentation should be clearer on these points.

Resolving patch:
diff --git a/lib/ansible/modules/network/sros/sros_config.py b/lib/ansible/modules/network/sros/sros_config.py
--- a/lib/ansible/modules/network/sros/sros_config.py
+++ b/lib/ansible/modules/network/sros/sros_config.py
@@ -42,7 +42,8 @@
         section.  The commands must be the exact same commands as found
         in the device running-config.  Be sure to note the configuration
         command syntax as some commands are automatically modified by the
-        device config parser.
+        device config parser.  The I(lines) argument only supports current
+        context lines.  See EXAMPLES
     required: false
     default: null
     aliases: ['commands']
@@ -198,6 +199,23 @@
       src: "{{ inventory_hostname }}.cfg"
       provider: "{{ cli }}"
       save: yes
+
+- name: invalid use of lines
+  sros_config:
+    lines:
+      - service
+      -     vpls 1000 customer foo 1 create
+      -         description "invalid lines example"
+    provider: "{{ cli }}"
+
+- name: valid use of lines
+  sros_config:
+    lines:
+      - description "invalid lines example"
+    parents:
+      - service
+      - vpls 1000 customer foo 1 create
+    provider: "{{ cli }}"
 """
 
 RETURN = """


Test patch: