Skip to content

Commit

Permalink
Cleanup headers and imports (ansible-collections#1738)
Browse files Browse the repository at this point in the history
Cleanup headers and imports

SUMMARY
Mass update of imports, docs fragments and file headers

Many of the amazon.aws module_utils and docs fragments got moved about, update community.aws to reflect this.
Consistently apply the comment headers as documented at https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_documenting.html#python-shebang-utf-8-coding

ISSUE TYPE

Docs Pull Request
Feature Pull Request

COMPONENT NAME
ADDITIONAL INFORMATION
Header cleanup based upon:
https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_documenting.html#python-shebang-utf-8-coding

Begin your Ansible module with #!/usr/bin/python - this “shebang” allows ansible_python_interpreter to work. Follow the shebang immediately with # -*- coding: utf-8 -*- to clarify that the file is UTF-8 encoded.

and
https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_documenting.html#copyright-and-license

After the shebang and UTF-8 coding, add a copyright line with the original copyright holder and a license declaration. The license declaration should be ONLY one line, not the full GPL prefix.
...
Additions to the module (for instance, rewrites) are not permitted to add additional copyright lines other than the default copyright statement if missing:

Reviewed-by: Alina Buzachis

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@a4f20bf
  • Loading branch information
tremble authored and abikouo committed Oct 20, 2023
1 parent f4a540a commit 5832943
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
38 changes: 19 additions & 19 deletions plugins/modules/iam_role.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
# -*- coding: utf-8 -*-

# Copyright: Contributors to the Ansible project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

DOCUMENTATION = r'''
DOCUMENTATION = r"""
---
module: iam_role
version_added: 1.0.0
Expand Down Expand Up @@ -91,13 +90,13 @@
default: True
type: bool
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.boto3
- amazon.aws.common.modules
- amazon.aws.region.modules
- amazon.aws.tags
'''
- amazon.aws.boto3
"""

EXAMPLES = r'''
EXAMPLES = r"""
# Note: These examples do not set authentication details, see the AWS Guide for details.
- name: Create a role with description and tags
Expand Down Expand Up @@ -127,8 +126,8 @@
assume_role_policy_document: "{{ lookup('file', 'policy.json') }}"
state: absent
'''
RETURN = r'''
"""
RETURN = r"""
iam_role:
description: dictionary containing the IAM Role data
returned: success
Expand Down Expand Up @@ -214,7 +213,7 @@
type: dict
returned: always
sample: '{"Env": "Prod"}'
'''
"""

import json

Expand All @@ -225,13 +224,14 @@

from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ansible_dict_to_boto3_tag_list
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import compare_aws_tags
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import compare_policies


@AWSRetry.jittered_backoff()
Expand Down
32 changes: 15 additions & 17 deletions plugins/modules/iam_role_info.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
__metaclass__ = type


DOCUMENTATION = '''
DOCUMENTATION = r"""
---
module: iam_role_info
version_added: 1.0.0
Expand All @@ -29,13 +27,12 @@
- Mutually exclusive with I(name).
type: str
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
- amazon.aws.boto3
- amazon.aws.common.modules
- amazon.aws.region.modules
- amazon.aws.boto3
"""

'''

EXAMPLES = '''
EXAMPLES = r"""
- name: find all existing IAM roles
community.aws.iam_role_info:
register: result
Expand All @@ -47,9 +44,9 @@
- name: describe all roles matching a path prefix
community.aws.iam_role_info:
path_prefix: /application/path
'''
"""

RETURN = '''
RETURN = r"""
iam_roles:
description: List of IAM roles
returned: always
Expand Down Expand Up @@ -153,7 +150,7 @@
type: dict
returned: always
sample: '{"Env": "Prod"}'
'''
"""

try:
import botocore
Expand All @@ -162,10 +159,11 @@

from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict

from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict

from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict


@AWSRetry.jittered_backoff()
Expand Down

0 comments on commit 5832943

Please sign in to comment.