mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
* Defaults to creating the instance profile to preserve current behaviour
This commit is contained in:
parent
b107635aeb
commit
71510aa67a
1 changed files with 24 additions and 15 deletions
|
@ -57,6 +57,12 @@ options:
|
||||||
- Create or remove the IAM role
|
- Create or remove the IAM role
|
||||||
required: true
|
required: true
|
||||||
choices: [ 'present', 'absent' ]
|
choices: [ 'present', 'absent' ]
|
||||||
|
create_instance_profile:
|
||||||
|
description:
|
||||||
|
- Creates an IAM instance profile along with the role
|
||||||
|
type: bool
|
||||||
|
default: true
|
||||||
|
version_added: 2.5
|
||||||
requirements: [ botocore, boto3 ]
|
requirements: [ botocore, boto3 ]
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- aws
|
- aws
|
||||||
|
@ -217,6 +223,7 @@ def create_or_update_role(connection, module):
|
||||||
if module.params.get('description') is not None:
|
if module.params.get('description') is not None:
|
||||||
params['Description'] = module.params.get('description')
|
params['Description'] = module.params.get('description')
|
||||||
managed_policies = module.params.get('managed_policy')
|
managed_policies = module.params.get('managed_policy')
|
||||||
|
create_instance_profile = module.params.get('create_instance_profile')
|
||||||
if managed_policies:
|
if managed_policies:
|
||||||
managed_policies = convert_friendly_names_to_arns(connection, module, managed_policies)
|
managed_policies = convert_friendly_names_to_arns(connection, module, managed_policies)
|
||||||
changed = False
|
changed = False
|
||||||
|
@ -275,6 +282,7 @@ def create_or_update_role(connection, module):
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
# Instance profile
|
# Instance profile
|
||||||
|
if create_instance_profile:
|
||||||
try:
|
try:
|
||||||
instance_profiles = connection.list_instance_profiles_for_role(RoleName=params['RoleName'])['InstanceProfiles']
|
instance_profiles = connection.list_instance_profiles_for_role(RoleName=params['RoleName'])['InstanceProfiles']
|
||||||
except ClientError as e:
|
except ClientError as e:
|
||||||
|
@ -369,7 +377,8 @@ def main():
|
||||||
assume_role_policy_document=dict(type='json'),
|
assume_role_policy_document=dict(type='json'),
|
||||||
managed_policy=dict(type='list', aliases=['managed_policies']),
|
managed_policy=dict(type='list', aliases=['managed_policies']),
|
||||||
state=dict(choices=['present', 'absent'], required=True),
|
state=dict(choices=['present', 'absent'], required=True),
|
||||||
description=dict(required=False, type='str')
|
description=dict(required=False, type='str'),
|
||||||
|
create_instance_profile=dict(type='bool', default=True)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue