Repository: ansible/ansible

Issue:
ec2_ami registered output does not include 'name' from invocation
##### ISSUE TYPE
 - Feature Idea

##### COMPONENT NAME
ec2_ami

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.0.0
  config file =
  configured module search path = Default w/o overrides
```

##### CONFIGURATION

##### OS / ENVIRONMENT
<!---
OS X 10.12.2
-->

##### SUMMARY
When registering the output of `ec2_ami`, where a `name` param is a passed in, this is does not appear on the output.

##### STEPS TO REPRODUCE
```
    - name: create AMI
      ec2_ami:
        description: desc
        instance_id: id-xxxxx
        name: "foo"
        region: region
        wait: yes
      register: create_ami_output

    - debug: var=create_ami_output
```

##### EXPECTED RESULTS

Registered debug output contains `name: foo`.

##### ACTUAL RESULTS

Output does not show `name` as a separate key:value pair. Closest is `location`, which has to be split.

<!--- Paste verbatim command output between quotes below -->
```
ok: [localhost] => {
    "create_ami_output": {
        "architecture": "x86_64",
        "block_device_mapping": {
            "/dev/sda1": {
                "delete_on_termination": true,
                "encrypted": false,
                "size": 64,
                "snapshot_id": "snap-06sdfsdf",
                "volume_type": "gp2"
            },
            "/dev/xvdb": {
                "delete_on_termination": true,
                "encrypted": true,
                "size": 200,
                "snapshot_id": "snap-sdfsdfsdfsdf9",
                "volume_type": "gp2"
            }
        },
        "changed": true,
        "creationDate": "2016-11-22T16:11:20.000Z",
        "description": "sdfsdfsd",
        "hypervisor": "xen",
        "image_id": "ami-sdfsdf",
        "is_public": false,
        "location": "435345345345345/foo",
        "msg": "AMI creation operation complete",
        "ownerId": "345345345",
        "root_device_name": "/dev/sda1",
        "root_device_type": "ebs",
        "state": "available",
        "tags": {},
        "virtualization_type": "hvm"
    }
}
```

ec2_ami registered output does not include 'name' from invocation
##### ISSUE TYPE
 - Feature Idea

##### COMPONENT NAME
ec2_ami

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.0.0
  config file =
  configured module search path = Default w/o overrides
```

##### CONFIGURATION

##### OS / ENVIRONMENT
<!---
OS X 10.12.2
-->

##### SUMMARY
When registering the output of `ec2_ami`, where a `name` param is a passed in, this is does not appear on the output.

##### STEPS TO REPRODUCE
```
    - name: create AMI
      ec2_ami:
        description: desc
        instance_id: id-xxxxx
        name: "foo"
        region: region
        wait: yes
      register: create_ami_output

    - debug: var=create_ami_output
```

##### EXPECTED RESULTS

Registered debug output contains `name: foo`.

##### ACTUAL RESULTS

Output does not show `name` as a separate key:value pair. Closest is `location`, which has to be split.

<!--- Paste verbatim command output between quotes below -->
```
ok: [localhost] => {
    "create_ami_output": {
        "architecture": "x86_64",
        "block_device_mapping": {
            "/dev/sda1": {
                "delete_on_termination": true,
                "encrypted": false,
                "size": 64,
                "snapshot_id": "snap-06sdfsdf",
                "volume_type": "gp2"
            },
            "/dev/xvdb": {
                "delete_on_termination": true,
                "encrypted": true,
                "size": 200,
                "snapshot_id": "snap-sdfsdfsdfsdf9",
                "volume_type": "gp2"
            }
        },
        "changed": true,
        "creationDate": "2016-11-22T16:11:20.000Z",
        "description": "sdfsdfsd",
        "hypervisor": "xen",
        "image_id": "ami-sdfsdf",
        "is_public": false,
        "location": "435345345345345/foo",
        "msg": "AMI creation operation complete",
        "ownerId": "345345345",
        "root_device_name": "/dev/sda1",
        "root_device_type": "ebs",
        "state": "available",
        "tags": {},
        "virtualization_type": "hvm"
    }
}
```



Discussion:
cc @jjshoe
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @willthames
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @Constantin07 @gunzy83 @scicoin-project
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
The name (and also the platform) is a documented output but is not included in the outputs currently (so this is actually a bug). I have  submitted a PR fix #27021.
cc @jjshoe
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @willthames
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @Constantin07 @gunzy83 @scicoin-project
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
The name (and also the platform) is a documented output but is not included in the outputs currently (so this is actually a bug). I have  submitted a PR fix #27021.

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/ec2_ami.py b/lib/ansible/modules/cloud/amazon/ec2_ami.py
--- a/lib/ansible/modules/cloud/amazon/ec2_ami.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_ami.py
@@ -401,7 +401,9 @@ def get_ami_info(image):
         root_device_name=image.root_device_name,
         root_device_type=image.root_device_type,
         tags=image.tags,
-        virtualization_type=image.virtualization_type
+        virtualization_type=image.virtualization_type,
+        name=image.name,
+        platform=image.platform
     )
 
 


Test patch: