Skip to content

Commit

Permalink
Bulk migration to AnsibleAWSModule (ansible-collections#173)
Browse files Browse the repository at this point in the history
* Update comments to reference AnsibleAWSModule rather than AnsibleModule
* Bulk re-order imports and split onto one from import per-line.
* Add AnsibleAWSModule imports
* Migrate boto 2 based modules to AnsibleAWSModule
* Move boto3-only modules over to AnsibleAWSModule
* Remove extra ec2_argument_spec calls - not needed now we're using AnsibleAWSModule
* Remove most HAS_BOTO3 code, it's handled by AnsibleAWSModule
* Handle missing Boto 2 consistently  (HAS_BOTO)
* Remove AnsibleModule imports
* Changelog fragment

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@818c6d2
  • Loading branch information
tremble authored and alinabuzachis committed Oct 13, 2023
1 parent bb57d21 commit 6e207a1
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions plugins/modules/iam_server_certificate_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@
try:
import boto3
import botocore.exceptions
HAS_BOTO3 = True
except ImportError:
HAS_BOTO3 = False
pass # Handled by AnsibleAWSModule

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_conn, ec2_argument_spec, get_aws_connection_info
from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_conn
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_aws_connection_info


def get_server_certs(iam, name=None):
Expand Down Expand Up @@ -141,19 +141,15 @@ def get_server_certs(iam, name=None):


def main():
argument_spec = ec2_argument_spec()
argument_spec.update(dict(
argument_spec = dict(
name=dict(type='str'),
))
)

module = AnsibleModule(argument_spec=argument_spec,)
module = AnsibleAWSModule(argument_spec=argument_spec,)
if module._name == 'iam_server_certificate_facts':
module.deprecate("The 'iam_server_certificate_facts' module has been renamed to 'iam_server_certificate_info'",
date='2021-12-01', collection_name='community.aws')

if not HAS_BOTO3:
module.fail_json(msg='boto3 required for this module')

try:
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
iam = boto3_conn(module, conn_type='client', resource='iam', region=region, endpoint=ec2_url, **aws_connect_kwargs)
Expand Down

0 comments on commit 6e207a1

Please sign in to comment.