We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add partition strategy to placement groups module
### Summary

Add partition as a strategy for the community.aws.ec2_placement_group module.

Also add an option to choose the actual number of partitions (min 2 which is the default and a max of 7). This option would be taken into account when the strategy is set to partition.

### Issue Type

Feature Idea

### Component Name

ec2_placement_group

### Additional Information

Possible module definition
```yaml (paste below)
- name: Create a Spread placement group.
  community.aws.ec2_placement_group:
    name: my-cluster
    state: present
    strategy: partition
    partition_number: 4
```

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `plugins/modules/ec2_placement_group.py`
Content:
```
1 #!/usr/bin/python
2 # Copyright (c) 2017 Ansible Project
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4 
5 from __future__ import absolute_import, division, print_function
6 __metaclass__ = type
7 
8 
9 DOCUMENTATION = '''
10 ---
11 module: ec2_placement_group
12 version_added: 1.0.0
13 short_description: Create or delete an EC2 Placement Group
14 description:
15     - Create an EC2 Placement Group; if the placement group already exists,
16       nothing is done. Or, delete an existing placement group. If the placement
17       group is absent, do nothing. See also
18       U(https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html)
19 author: "Brad Macpherson (@iiibrad)"
20 options:
21   name:
22     description:
23       - The name for the placement group.
24     required: true
25     type: str
26   state:
27     description:
28       - Create or delete placement group.
29     default: present
30     choices: [ 'present', 'absent' ]
31     type: str
32   strategy:
33     description:
34       - Placement group strategy. Cluster will cluster instances into a
35         low-latency group in a single Availability Zone, while Spread spreads
36         instances across underlying hardware.
37     default: cluster
38     choices: [ 'cluster', 'spread' ]
39     type: str
40 extends_documentation_fragment:
41 - amazon.aws.aws
42 - amazon.aws.ec2
43 
44 '''
45 
46 EXAMPLES = '''
47 # Note: These examples do not set authentication details, see the AWS Guide
48 # for details.
49 
50 - name: Create a placement group.
51   community.aws.ec2_placement_group:
52     name: my-cluster
53     state: present
54 
55 - name: Create a Spread placement group.
56   community.aws.ec2_placement_group:
57     name: my-cluster
58     state: present
59     strategy: spread
60 
61 - name: Delete a placement group.
62   community.aws.ec2_placement_group:
63     name: my-cluster
64     state: absent
65 
66 '''
67 
68 
69 RETURN = '''
70 placement_group:
71   description: Placement group attributes
72   returned: when state != absent
73   type: complex
74   contains:
75     name:
76       description: PG name
77       type: str
78       sample: my-cluster
79     state:
80       description: PG state
81       type: str
82       sample: "available"
83     strategy:
84       description: PG strategy
85       type: str
86       sample: "cluster"
87 
88 '''
89 
90 try:
91     import botocore
92 except ImportError:
93     pass  # caught by AnsibleAWSModule
94 
95 from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
96 from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code
97 from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry
98 
99 
100 @AWSRetry.exponential_backoff()
101 def get_placement_group_details(connection, module):
102     name = module.params.get("name")
103     try:
104         response = connection.describe_placement_groups(
105             Filters=[{
106                 "Name": "group-name",
107                 "Values": [name]
108             }])
109     except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
110         module.fail_json_aws(
111             e,
112             msg="Couldn't find placement group named [%s]" % name)
113 
114     if len(response['PlacementGroups']) != 1:
115         return None
116     else:
117         placement_group = response['PlacementGroups'][0]
118         return {
119             "name": placement_group['GroupName'],
120             "state": placement_group['State'],
121             "strategy": placement_group['Strategy'],
122         }
123 
124 
125 @AWSRetry.exponential_backoff()
126 def create_placement_group(connection, module):
127     name = module.params.get("name")
128     strategy = module.params.get("strategy")
129 
130     try:
131         connection.create_placement_group(
132             GroupName=name, Strategy=strategy, DryRun=module.check_mode)
133     except is_boto3_error_code('DryRunOperation'):
134         module.exit_json(changed=True, placement_group={
135             "name": name,
136             "state": 'DryRun',
137             "strategy": strategy,
138         })
139     except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:  # pylint: disable=duplicate-except
140         module.fail_json_aws(
141             e,
142             msg="Couldn't create placement group [%s]" % name)
143 
144     module.exit_json(changed=True,
145                      placement_group=get_placement_group_details(
146                          connection, module
147                      ))
148 
149 
150 @AWSRetry.exponential_backoff()
151 def delete_placement_group(connection, module):
152     name = module.params.get("name")
153 
154     try:
155         connection.delete_placement_group(
156             GroupName=name, DryRun=module.check_mode)
157     except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
158         module.fail_json_aws(
159             e,
160             msg="Couldn't delete placement group [%s]" % name)
161 
162     module.exit_json(changed=True)
163 
164 
165 def main():
166     argument_spec = dict(
167         name=dict(required=True, type='str'),
168         state=dict(default='present', choices=['present', 'absent']),
169         strategy=dict(default='cluster', choices=['cluster', 'spread'])
170     )
171 
172     module = AnsibleAWSModule(
173         argument_spec=argument_spec,
174         supports_check_mode=True
175     )
176 
177     connection = module.client('ec2')
178 
179     state = module.params.get("state")
180 
181     if state == 'present':
182         placement_group = get_placement_group_details(connection, module)
183         if placement_group is None:
184             create_placement_group(connection, module)
185         else:
186             strategy = module.params.get("strategy")
187             if placement_group['strategy'] == strategy:
188                 module.exit_json(
189                     changed=False, placement_group=placement_group)
190             else:
191                 name = module.params.get("name")
192                 module.fail_json(
193                     msg=("Placement group '{}' exists, can't change strategy" +
194                          " from '{}' to '{}'").format(
195                              name,
196                              placement_group['strategy'],
197                              strategy))
198 
199     elif state == 'absent':
200         placement_group = get_placement_group_details(connection, module)
201         if placement_group is None:
202             module.exit_json(changed=False)
203         else:
204             delete_placement_group(connection, module)
205 
206 
207 if __name__ == '__main__':
208     main()
209
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/plugins/modules/ec2_placement_group.py b/plugins/modules/ec2_placement_group.py
--- a/plugins/modules/ec2_placement_group.py
+++ b/plugins/modules/ec2_placement_group.py
@@ -23,6 +23,13 @@
       - The name for the placement group.
     required: true
     type: str
+  partition_count:
+    description:
+      - The number of partitions.
+      - Valid only when I(Strategy) is set to C(partition).
+      - Must be a value between C(1) and C(7).
+    type: int
+    version_added: 3.1.0
   state:
     description:
       - Create or delete placement group.
@@ -35,7 +42,7 @@
         low-latency group in a single Availability Zone, while Spread spreads
         instances across underlying hardware.
     default: cluster
-    choices: [ 'cluster', 'spread' ]
+    choices: [ 'cluster', 'spread', 'partition' ]
     type: str
 extends_documentation_fragment:
 - amazon.aws.aws
@@ -58,6 +65,13 @@
     state: present
     strategy: spread
 
+- name: Create a Partition strategy placement group.
+  community.aws.ec2_placement_group:
+    name: my-cluster
+    state: present
+    strategy: partition
+    partition_count: 3
+
 - name: Delete a placement group.
   community.aws.ec2_placement_group:
     name: my-cluster
@@ -126,10 +140,21 @@
 def create_placement_group(connection, module):
     name = module.params.get("name")
     strategy = module.params.get("strategy")
+    partition_count = module.params.get("partition_count")
+
+    if strategy != 'partition' and partition_count:
+        module.fail_json(
+            msg="'partition_count' can only be set when strategy is set to 'partition'.")
+
+    params = {}
+    params['GroupName'] = name
+    params['Strategy'] = strategy
+    if partition_count:
+        params['PartitionCount'] = partition_count
+    params['DryRun'] = module.check_mode
 
     try:
-        connection.create_placement_group(
-            GroupName=name, Strategy=strategy, DryRun=module.check_mode)
+        connection.create_placement_group(**params)
     except is_boto3_error_code('DryRunOperation'):
         module.exit_json(changed=True, placement_group={
             "name": name,
@@ -165,8 +190,9 @@
 def main():
     argument_spec = dict(
         name=dict(required=True, type='str'),
+        partition_count=dict(type='int'),
         state=dict(default='present', choices=['present', 'absent']),
-        strategy=dict(default='cluster', choices=['cluster', 'spread'])
+        strategy=dict(default='cluster', choices=['cluster', 'spread', 'partition'])
     )
 
     module = AnsibleAWSModule(

{"golden_diff": "diff --git a/plugins/modules/ec2_placement_group.py b/plugins/modules/ec2_placement_group.py\n--- a/plugins/modules/ec2_placement_group.py\n+++ b/plugins/modules/ec2_placement_group.py\n@@ -23,6 +23,13 @@\n       - The name for the placement group.\n     required: true\n     type: str\n+  partition_count:\n+    description:\n+      - The number of partitions.\n+      - Valid only when I(Strategy) is set to C(partition).\n+      - Must be a value between C(1) and C(7).\n+    type: int\n+    version_added: 3.1.0\n   state:\n     description:\n       - Create or delete placement group.\n@@ -35,7 +42,7 @@\n         low-latency group in a single Availability Zone, while Spread spreads\n         instances across underlying hardware.\n     default: cluster\n-    choices: [ 'cluster', 'spread' ]\n+    choices: [ 'cluster', 'spread', 'partition' ]\n     type: str\n extends_documentation_fragment:\n - amazon.aws.aws\n@@ -58,6 +65,13 @@\n     state: present\n     strategy: spread\n \n+- name: Create a Partition strategy placement group.\n+  community.aws.ec2_placement_group:\n+    name: my-cluster\n+    state: present\n+    strategy: partition\n+    partition_count: 3\n+\n - name: Delete a placement group.\n   community.aws.ec2_placement_group:\n     name: my-cluster\n@@ -126,10 +140,21 @@\n def create_placement_group(connection, module):\n     name = module.params.get(\"name\")\n     strategy = module.params.get(\"strategy\")\n+    partition_count = module.params.get(\"partition_count\")\n+\n+    if strategy != 'partition' and partition_count:\n+        module.fail_json(\n+            msg=\"'partition_count' can only be set when strategy is set to 'partition'.\")\n+\n+    params = {}\n+    params['GroupName'] = name\n+    params['Strategy'] = strategy\n+    if partition_count:\n+        params['PartitionCount'] = partition_count\n+    params['DryRun'] = module.check_mode\n \n     try:\n-        connection.create_placement_group(\n-            GroupName=name, Strategy=strategy, DryRun=module.check_mode)\n+        connection.create_placement_group(**params)\n     except is_boto3_error_code('DryRunOperation'):\n         module.exit_json(changed=True, placement_group={\n             \"name\": name,\n@@ -165,8 +190,9 @@\n def main():\n     argument_spec = dict(\n         name=dict(required=True, type='str'),\n+        partition_count=dict(type='int'),\n         state=dict(default='present', choices=['present', 'absent']),\n-        strategy=dict(default='cluster', choices=['cluster', 'spread'])\n+        strategy=dict(default='cluster', choices=['cluster', 'spread', 'partition'])\n     )\n \n     module = AnsibleAWSModule(\n", "issue": "Add partition strategy to placement groups module\n### Summary\n\nAdd partition as a strategy for the community.aws.ec2_placement_group module.\r\n\r\nAlso add an option to choose the actual number of partitions (min 2 which is the default and a max of 7). This option would be taken into account when the strategy is set to partition.\n\n### Issue Type\n\nFeature Idea\n\n### Component Name\n\nec2_placement_group\n\n### Additional Information\n\nPossible module definition\r\n```yaml (paste below)\r\n- name: Create a Spread placement group.\r\n  community.aws.ec2_placement_group:\r\n    name: my-cluster\r\n    state: present\r\n    strategy: partition\r\n    partition_number: 4\r\n```\n\n### Code of Conduct\n\n- [X] I agree to follow the Ansible Code of Conduct\n", "before_files": [{"content": "#!/usr/bin/python\n# Copyright (c) 2017 Ansible Project\n# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)\n\nfrom __future__ import absolute_import, division, print_function\n__metaclass__ = type\n\n\nDOCUMENTATION = '''\n---\nmodule: ec2_placement_group\nversion_added: 1.0.0\nshort_description: Create or delete an EC2 Placement Group\ndescription:\n    - Create an EC2 Placement Group; if the placement group already exists,\n      nothing is done. Or, delete an existing placement group. If the placement\n      group is absent, do nothing. See also\n      U(https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html)\nauthor: \"Brad Macpherson (@iiibrad)\"\noptions:\n  name:\n    description:\n      - The name for the placement group.\n    required: true\n    type: str\n  state:\n    description:\n      - Create or delete placement group.\n    default: present\n    choices: [ 'present', 'absent' ]\n    type: str\n  strategy:\n    description:\n      - Placement group strategy. Cluster will cluster instances into a\n        low-latency group in a single Availability Zone, while Spread spreads\n        instances across underlying hardware.\n    default: cluster\n    choices: [ 'cluster', 'spread' ]\n    type: str\nextends_documentation_fragment:\n- amazon.aws.aws\n- amazon.aws.ec2\n\n'''\n\nEXAMPLES = '''\n# Note: These examples do not set authentication details, see the AWS Guide\n# for details.\n\n- name: Create a placement group.\n  community.aws.ec2_placement_group:\n    name: my-cluster\n    state: present\n\n- name: Create a Spread placement group.\n  community.aws.ec2_placement_group:\n    name: my-cluster\n    state: present\n    strategy: spread\n\n- name: Delete a placement group.\n  community.aws.ec2_placement_group:\n    name: my-cluster\n    state: absent\n\n'''\n\n\nRETURN = '''\nplacement_group:\n  description: Placement group attributes\n  returned: when state != absent\n  type: complex\n  contains:\n    name:\n      description: PG name\n      type: str\n      sample: my-cluster\n    state:\n      description: PG state\n      type: str\n      sample: \"available\"\n    strategy:\n      description: PG strategy\n      type: str\n      sample: \"cluster\"\n\n'''\n\ntry:\n    import botocore\nexcept ImportError:\n    pass  # caught by AnsibleAWSModule\n\nfrom ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule\nfrom ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code\nfrom ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry\n\n\n@AWSRetry.exponential_backoff()\ndef get_placement_group_details(connection, module):\n    name = module.params.get(\"name\")\n    try:\n        response = connection.describe_placement_groups(\n            Filters=[{\n                \"Name\": \"group-name\",\n                \"Values\": [name]\n            }])\n    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:\n        module.fail_json_aws(\n            e,\n            msg=\"Couldn't find placement group named [%s]\" % name)\n\n    if len(response['PlacementGroups']) != 1:\n        return None\n    else:\n        placement_group = response['PlacementGroups'][0]\n        return {\n            \"name\": placement_group['GroupName'],\n            \"state\": placement_group['State'],\n            \"strategy\": placement_group['Strategy'],\n        }\n\n\n@AWSRetry.exponential_backoff()\ndef create_placement_group(connection, module):\n    name = module.params.get(\"name\")\n    strategy = module.params.get(\"strategy\")\n\n    try:\n        connection.create_placement_group(\n            GroupName=name, Strategy=strategy, DryRun=module.check_mode)\n    except is_boto3_error_code('DryRunOperation'):\n        module.exit_json(changed=True, placement_group={\n            \"name\": name,\n            \"state\": 'DryRun',\n            \"strategy\": strategy,\n        })\n    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:  # pylint: disable=duplicate-except\n        module.fail_json_aws(\n            e,\n            msg=\"Couldn't create placement group [%s]\" % name)\n\n    module.exit_json(changed=True,\n                     placement_group=get_placement_group_details(\n                         connection, module\n                     ))\n\n\n@AWSRetry.exponential_backoff()\ndef delete_placement_group(connection, module):\n    name = module.params.get(\"name\")\n\n    try:\n        connection.delete_placement_group(\n            GroupName=name, DryRun=module.check_mode)\n    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:\n        module.fail_json_aws(\n            e,\n            msg=\"Couldn't delete placement group [%s]\" % name)\n\n    module.exit_json(changed=True)\n\n\ndef main():\n    argument_spec = dict(\n        name=dict(required=True, type='str'),\n        state=dict(default='present', choices=['present', 'absent']),\n        strategy=dict(default='cluster', choices=['cluster', 'spread'])\n    )\n\n    module = AnsibleAWSModule(\n        argument_spec=argument_spec,\n        supports_check_mode=True\n    )\n\n    connection = module.client('ec2')\n\n    state = module.params.get(\"state\")\n\n    if state == 'present':\n        placement_group = get_placement_group_details(connection, module)\n        if placement_group is None:\n            create_placement_group(connection, module)\n        else:\n            strategy = module.params.get(\"strategy\")\n            if placement_group['strategy'] == strategy:\n                module.exit_json(\n                    changed=False, placement_group=placement_group)\n            else:\n                name = module.params.get(\"name\")\n                module.fail_json(\n                    msg=(\"Placement group '{}' exists, can't change strategy\" +\n                         \" from '{}' to '{}'\").format(\n                             name,\n                             placement_group['strategy'],\n                             strategy))\n\n    elif state == 'absent':\n        placement_group = get_placement_group_details(connection, module)\n        if placement_group is None:\n            module.exit_json(changed=False)\n        else:\n            delete_placement_group(connection, module)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "plugins/modules/ec2_placement_group.py"}], "after_files": [{"content": "#!/usr/bin/python\n# Copyright (c) 2017 Ansible Project\n# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)\n\nfrom __future__ import absolute_import, division, print_function\n__metaclass__ = type\n\n\nDOCUMENTATION = '''\n---\nmodule: ec2_placement_group\nversion_added: 1.0.0\nshort_description: Create or delete an EC2 Placement Group\ndescription:\n    - Create an EC2 Placement Group; if the placement group already exists,\n      nothing is done. Or, delete an existing placement group. If the placement\n      group is absent, do nothing. See also\n      U(https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html)\nauthor: \"Brad Macpherson (@iiibrad)\"\noptions:\n  name:\n    description:\n      - The name for the placement group.\n    required: true\n    type: str\n  partition_count:\n    description:\n      - The number of partitions.\n      - Valid only when I(Strategy) is set to C(partition).\n      - Must be a value between C(1) and C(7).\n    type: int\n    version_added: 3.1.0\n  state:\n    description:\n      - Create or delete placement group.\n    default: present\n    choices: [ 'present', 'absent' ]\n    type: str\n  strategy:\n    description:\n      - Placement group strategy. Cluster will cluster instances into a\n        low-latency group in a single Availability Zone, while Spread spreads\n        instances across underlying hardware.\n    default: cluster\n    choices: [ 'cluster', 'spread', 'partition' ]\n    type: str\nextends_documentation_fragment:\n- amazon.aws.aws\n- amazon.aws.ec2\n\n'''\n\nEXAMPLES = '''\n# Note: These examples do not set authentication details, see the AWS Guide\n# for details.\n\n- name: Create a placement group.\n  community.aws.ec2_placement_group:\n    name: my-cluster\n    state: present\n\n- name: Create a Spread placement group.\n  community.aws.ec2_placement_group:\n    name: my-cluster\n    state: present\n    strategy: spread\n\n- name: Create a Partition strategy placement group.\n  community.aws.ec2_placement_group:\n    name: my-cluster\n    state: present\n    strategy: partition\n    partition_count: 3\n\n- name: Delete a placement group.\n  community.aws.ec2_placement_group:\n    name: my-cluster\n    state: absent\n\n'''\n\n\nRETURN = '''\nplacement_group:\n  description: Placement group attributes\n  returned: when state != absent\n  type: complex\n  contains:\n    name:\n      description: PG name\n      type: str\n      sample: my-cluster\n    state:\n      description: PG state\n      type: str\n      sample: \"available\"\n    strategy:\n      description: PG strategy\n      type: str\n      sample: \"cluster\"\n\n'''\n\ntry:\n    import botocore\nexcept ImportError:\n    pass  # caught by AnsibleAWSModule\n\nfrom ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule\nfrom ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code\nfrom ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry\n\n\n@AWSRetry.exponential_backoff()\ndef get_placement_group_details(connection, module):\n    name = module.params.get(\"name\")\n    try:\n        response = connection.describe_placement_groups(\n            Filters=[{\n                \"Name\": \"group-name\",\n                \"Values\": [name]\n            }])\n    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:\n        module.fail_json_aws(\n            e,\n            msg=\"Couldn't find placement group named [%s]\" % name)\n\n    if len(response['PlacementGroups']) != 1:\n        return None\n    else:\n        placement_group = response['PlacementGroups'][0]\n        return {\n            \"name\": placement_group['GroupName'],\n            \"state\": placement_group['State'],\n            \"strategy\": placement_group['Strategy'],\n        }\n\n\n@AWSRetry.exponential_backoff()\ndef create_placement_group(connection, module):\n    name = module.params.get(\"name\")\n    strategy = module.params.get(\"strategy\")\n    partition_count = module.params.get(\"partition_count\")\n\n    if strategy != 'partition' and partition_count:\n        module.fail_json(\n            msg=\"'partition_count' can only be set when strategy is set to 'partition'.\")\n\n    params = {}\n    params['GroupName'] = name\n    params['Strategy'] = strategy\n    if partition_count:\n        params['PartitionCount'] = partition_count\n    params['DryRun'] = module.check_mode\n\n    try:\n        connection.create_placement_group(**params)\n    except is_boto3_error_code('DryRunOperation'):\n        module.exit_json(changed=True, placement_group={\n            \"name\": name,\n            \"state\": 'DryRun',\n            \"strategy\": strategy,\n        })\n    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:  # pylint: disable=duplicate-except\n        module.fail_json_aws(\n            e,\n            msg=\"Couldn't create placement group [%s]\" % name)\n\n    module.exit_json(changed=True,\n                     placement_group=get_placement_group_details(\n                         connection, module\n                     ))\n\n\n@AWSRetry.exponential_backoff()\ndef delete_placement_group(connection, module):\n    name = module.params.get(\"name\")\n\n    try:\n        connection.delete_placement_group(\n            GroupName=name, DryRun=module.check_mode)\n    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:\n        module.fail_json_aws(\n            e,\n            msg=\"Couldn't delete placement group [%s]\" % name)\n\n    module.exit_json(changed=True)\n\n\ndef main():\n    argument_spec = dict(\n        name=dict(required=True, type='str'),\n        partition_count=dict(type='int'),\n        state=dict(default='present', choices=['present', 'absent']),\n        strategy=dict(default='cluster', choices=['cluster', 'spread', 'partition'])\n    )\n\n    module = AnsibleAWSModule(\n        argument_spec=argument_spec,\n        supports_check_mode=True\n    )\n\n    connection = module.client('ec2')\n\n    state = module.params.get(\"state\")\n\n    if state == 'present':\n        placement_group = get_placement_group_details(connection, module)\n        if placement_group is None:\n            create_placement_group(connection, module)\n        else:\n            strategy = module.params.get(\"strategy\")\n            if placement_group['strategy'] == strategy:\n                module.exit_json(\n                    changed=False, placement_group=placement_group)\n            else:\n                name = module.params.get(\"name\")\n                module.fail_json(\n                    msg=(\"Placement group '{}' exists, can't change strategy\" +\n                         \" from '{}' to '{}'\").format(\n                             name,\n                             placement_group['strategy'],\n                             strategy))\n\n    elif state == 'absent':\n        placement_group = get_placement_group_details(connection, module)\n        if placement_group is None:\n            module.exit_json(changed=False)\n        else:\n            delete_placement_group(connection, module)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "plugins/modules/ec2_placement_group.py"}]}