Skip to content

Commit

Permalink
Capture params from playbook
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar242 committed Aug 31, 2021
1 parent 9dd8f40 commit 6634233
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions plugins/modules/ec2_spot_instance_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

RETURN = '''
'''

import time
import datetime

Expand All @@ -30,23 +29,36 @@
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code

def describe_spot_instance_requests(module,connection):
def describe_spot_instance_requests(connection, module):

params = {}

if module.params.get('filters'):
params['Filters'] = module.params.get('filters')
if module.params.get('dry_run'):
params['DryRun'] = module.params.get('dry_run')
if module.params.get('spot_instance_request_ids'):
params['SpotInstanceRequestIds'] = module.params.get('spot_instance_request_ids')
if module.params.get('next_token'):
params['NextToken'] = module.params.get('next_token')
if module.params.get('max_results'):
params['MaxResults'] = module.params.get('max_results')

pass

def main():

argument_spec=dict(
filters=dict(default={}, type='list', elements='dict'),
dry_run_options = dict(type='bool'),
spot_instance_request__ids=dict(default=[], type='list', elements='str'),
next_token = dict(type='str'),
filters=dict(default=[], type='list', elements='dict'),
dry_run = dict(default=False, type='bool', choices=[True, False]),
spot_instance_request_ids=dict(default=[], type='list', elements='str'),
next_token = dict(default=None, type='str'),
max_results = dict(type='int')
)
module = AnsibleAWSModule(
argument_spec=argument_spec,
supports_check_mode=True
)
print(argument_spec)
try:
connection = module.client('ec2', retry_decorator=AWSRetry.jittered_backoff())
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
Expand All @@ -55,4 +67,4 @@ def main():
describe_spot_instance_requests(connection, module)

if __name__ == '__main__':
main()
main()

0 comments on commit 6634233

Please sign in to comment.