Repository: ansible/ansible

Issue:
aws_ssm_parameter_store Key error 'Description'
<!---
Verify first that your issue/request is not already reported on GitHub.
THIS FORM WILL BE READ BY A MACHINE, COMPLETE ALL SECTIONS AS DESCRIBED.
Also test if the latest release, and devel branch are affected too.
ALWAYS add information AFTER (OUTSIDE) these html comments.
Otherwise it may end up being automatically closed by our bot. -->

##### SUMMARY
<!--- Explain the problem briefly -->
Ansibel module aws_ssm_parameter_store stop working with error 'Key Error Description'

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
<!--- Insert, BELOW THIS COMMENT, the name of the module, plugin, task or feature.
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path-->

##### ANSIBLE VERSION
<!--- Paste, BELOW THIS COMMENT, verbatim output from "ansible --version" between quotes below -->
```
ansible --version
ansible 2.6.1
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
```

##### CONFIGURATION
<!--- If using Ansible 2.4 or above, paste, BELOW THIS COMMENT, the results of "ansible-config dump --only-changed"
Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).-->
```
stevek@stevek-macbook 11:25 ~> ansible-config dump --only-changed
stevek@stevek-macbook 11:25 ~>
```
##### OS / ENVIRONMENT
<!--- Mention, BELOW THIS COMMENT, 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.-->

Ubuntu 18.04
ansible installed using pip install -U ansible

##### 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 -->
```yaml
- name: test ssm
  hosts: localhost
  tasks:
    - name: Test aws_ssm_parameter_store
      aws_ssm_parameter_store:
        profile: "{{ profile }}"
        region: "{{ region }}"
        name: "Hello"
        description: "{{ desc|default(omit) }}"
        string_type: SecureString
        value: "World"
    - set_fact:
        out: "{{ lookup('aws_ssm', 'Hello', aws_profile=profile, region=region) }}"
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

Play passed

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
Play error see the output

<!--- Paste verbatim command output between quotes below -->
```
TASK [Test aws_ssm_parameter_store] ******************************************************
task path: /home/stevek/deployments/act2-ansible/tests/test-ssm-parameter-store.yml:4
Thursday 19 July 2018  11:30:12 +1000 (0:00:00.639)       0:00:00.671 ********* 
Using module_utils file /home/stevek/deployments/act2-ansible/module_utils/ec2.py
Using module_utils file /usr/local/lib/python2.7/dist-packages/ansible/module_utils/aws/core.py
Using module_utils file /home/stevek/deployments/act2-ansible/module_utils/aws/__init__.py
Using module_utils file /usr/local/lib/python2.7/dist-packages/ansible/module_utils/_text.py
Using module_utils file /usr/local/lib/python2.7/dist-packages/ansible/module_utils/cloud.py
Using module_utils file /usr/local/lib/python2.7/dist-packages/ansible/module_utils/six/__init__.py
Using module_utils file /usr/local/lib/python2.7/dist-packages/ansible/module_utils/basic.py
Using module_utils file /usr/local/lib/python2.7/dist-packages/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /usr/local/lib/python2.7/dist-packages/ansible/module_utils/parsing/__init__.py
Using module_utils file /usr/local/lib/python2.7/dist-packages/ansible/module_utils/pycompat24.py
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/cloud/amazon/aws_ssm_parameter_store.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: stevek
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_L5Bvi2/ansible_module_aws_ssm_parameter_store.py", line 253, in <module>
    main()
  File "/tmp/ansible_L5Bvi2/ansible_module_aws_ssm_parameter_store.py", line 248, in main
    (changed, response) = invocations[state](client, module)
  File "/tmp/ansible_L5Bvi2/ansible_module_aws_ssm_parameter_store.py", line 184, in create_update_parameter
    if args['Description']:
KeyError: 'Description'

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_L5Bvi2/ansible_module_aws_ssm_parameter_store.py\", line 253, in <module>\n    main()\n  File \"/tmp/ansible_L5Bvi2/ansible_module_aws_ssm_parameter_store.py\", line 248, in main\n    (changed, response) = invocations[state](client, module)\n  File \"/tmp/ansible_L5Bvi2/ansible_module_aws_ssm_parameter_store.py\", line 184, in create_update_parameter\n    if args['Description']:\nKeyError: 'Description'\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 1
}
	to retry, use: --limit @/home/stevek/.ansible-retry/test-ssm-parameter-store.retry

PLAY RECAP *******************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1   

```

=== NOTES

* If I supply the description as a text in the ansible module then it goes fine.
* If downgrade ansible to version 2.5.6 everything works again. 2.6.0 and 2.6.1 (lastest) has the same issues.




Discussion:
Please try out https://github.com/ansible/ansible/pull/43020 and see if that resolves your issue

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/aws_ssm_parameter_store.py b/lib/ansible/modules/cloud/amazon/aws_ssm_parameter_store.py
--- a/lib/ansible/modules/cloud/amazon/aws_ssm_parameter_store.py
+++ b/lib/ansible/modules/cloud/amazon/aws_ssm_parameter_store.py
@@ -181,7 +181,7 @@ def create_update_parameter(client, module):
             if existing_parameter['Parameter']['Value'] != args['Value']:
                 (changed, response) = update_parameter(client, module, args)
 
-            if args['Description']:
+            if args.get('Description'):
                 # Description field not available from get_parameter function so get it from describe_parameters
                 describe_existing_parameter = None
                 try:


Test patch: