Repository: ansible/ansible-modules-core

Issue:
iosxr_config: No message/protection against overly long commit messages
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

iosxr_config
##### ANSIBLE VERSION

```
ansible 2.3.0 (devel d09f57fb3a) last updated 2016/10/04 09:47:32 (GMT +100)
  lib/ansible/modules/core: (devel 0ee774ff15) last updated 2016/10/04 09:47:37 (GMT +100)
  lib/ansible/modules/extras: (devel 5cc72c3f06) last updated 2016/10/04 09:47:38 (GMT +100)

```
##### CONFIGURATION
##### OS / ENVIRONMENT
##### SUMMARY

Very low priority bug. Documentation (and code) should reference the maximum length, which appears to be 60 characters.
##### STEPS TO REPRODUCE

``` yaml
- name: setup
  iosxr_config:
    commands:
      - no description
      - no shutdown
    parents:
      - interface Loopback999
    match: none
    provider: "{{ cli }}"

- name: configure device with comment
  iosxr_config:
    src: basic/config.j2
    provider: "{{ cli }}"
    comment: "this is a really long message  aaaaabbbbbbcdde end-of-message"
  register: result

```
##### EXPECTED RESULTS

More meaningful error message and documentation to reference this limit
##### ACTUAL RESULTS

``` yaml
TASK [test_iosxr_config : configure device with comment] ***********************
task path: /home/johnb/git/ansible-inc/test-iosxr-config-comment/roles/test_iosxr_config/tests/cli/comment.yaml:14
Using module file /home/johnb/git/ansible-inc/ansible/lib/ansible/modules/core/network/iosxr/iosxr_config.py
<iosxr01> ESTABLISH LOCAL CONNECTION FOR USER: johnb
<iosxr01> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1475576461.63-14161189397342 `" && echo ansible-tmp-1475576461.63-14161189397342="` echo $HOME/.ansible/tmp/ansible-tmp-1475576461.63-14161189397342 `" ) && sleep 0'
<iosxr01> PUT /tmp/tmp4ifEiT TO /home/johnb/.ansible/tmp/ansible-tmp-1475576461.63-14161189397342/iosxr_config.py
<iosxr01> EXEC /bin/sh -c 'chmod u+x /home/johnb/.ansible/tmp/ansible-tmp-1475576461.63-14161189397342/ /home/johnb/.ansible/tmp/ansible-tmp-1475576461.63-14161189397342/iosxr_config.py && sleep 0'
<iosxr01> EXEC /bin/sh -c 'python /home/johnb/.ansible/tmp/ansible-tmp-1475576461.63-14161189397342/iosxr_config.py; rm -rf "/home/johnb/.ansible/tmp/ansible-tmp-1475576461.63-14161189397342/" > /dev/null 2>&1 && sleep 0'
fatal: [iosxr01]: FAILED! => {
    "changed": false, 
    "commands": [
        "commit comment this is a really long message  aaaaabbbbbbcdde end-of-message", 
        "end"
    ], 
    "failed": true, 
    "invocation": {
        "module_args": {
            "after": null, 
            "auth_pass": null, 
            "authorize": false, 
            "backup": false, 
            "before": null, 
            "comment": "this is a really long message  aaaaabbbbbbcdde end-of-message", 
            "config": null, 
            "force": false, 
            "host": "iosxr01", 
            "lines": null, 
            "match": "line", 
            "parents": null, 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": null, 
            "provider": {
                "host": "iosxr01", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "transport": "cli", 
                "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
            }, 
            "replace": "line", 
            "src": "interface Loopback999\n description this is a test\n shutdown\n\n", 
            "ssh_keyfile": null, 
            "timeout": 10, 
            "transport": "cli", 
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    }, 
    "msg": "matched error in response: ong message  aaaaabbbbbbcdde end-of-message\r\n                                                                           ^   \r\n\r\n% Invalid input detected at '^' marker.\r\nRP/0/0/CPU0:iosxr01(config-if)#"
}
    to retry, use: --limit @/home/johnb/git/ansible-inc/test-iosxr-config-comment/iosxr.retry


```



Discussion:
<!-- @gundalow: Thanks for filing this bug report! -->

@privateip, @gundalow, ping. This issue is waiting on your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)

<!--- boilerplate: issue_bug_new --->


Resolving patch:
diff --git a/network/iosxr/iosxr_config.py b/network/iosxr/iosxr_config.py
--- a/network/iosxr/iosxr_config.py
+++ b/network/iosxr/iosxr_config.py
@@ -194,6 +194,9 @@
 
 
 def check_args(module, warnings):
+    if module.params['comment']:
+        if len(module.params['comment']) > 60:
+            module.fail_json(msg='comment argument cannot be more than 60 characters')
     if module.params['force']:
         warnings.append('The force argument is deprecated, please use '
                         'match=none instead.  This argument will be '


Test patch: