The following command works in an interactive shell - 

aws autoscaling start-instance-refresh  --auto-scaling-group-name 
Test_Iwo_nodes_Development_zone1 --preferences '{"InstanceWarmup": 400, 
"MinHealthyPercentage": 50}'

Please let me know, how should I pass this in shell module within ansible?

Thanks

On Wednesday, February 23, 2022 at 11:02:58 PM UTC+5:30 [email protected] 
wrote:

> Can you confirm that the exact same command (without single quotes around 
> it) actually works from an interactive shell?
>
> On Wed, 23 Feb 2022 at 18:13, Shivani Arora <[email protected]> wrote:
>
>> Hi All,
>>
>> I need help with passing JSON in the shell module in ansible. 
>>
>> *Playbook - *
>>
>> - hosts: localhost
>>   name: refresh asg
>>   connection: local
>>   gather_facts: True
>>   tasks:
>>   - name: refresh instances
>>
>     shell: 'aws autoscaling start-instance-refresh --region=us-east-1 
>> --auto-scaling-group-name test_asg --preferences '{"InstanceWarmup": 
>> 400, "MinHealthyPercentage": 50}'
>>
>
>> *The error I'm getting is -*
>>
>> fatal: [localhost]: FAILED! => {"changed": true, "cmd": "aws autoscaling 
>> start-instance-refresh --region=us-east-1 --auto-scaling-group-name 
>> Test_Iwo_nodes_Development_zone3 --preferences 
>> {\"MinHealthyPercentage\":90,\"InstanceWarmup\":180}", "delta": 
>> "0:00:01.069908", "end": "2022-02-23 08:40:31.459081", "msg": "non-zero 
>> return code", "rc": 255, "start": "2022-02-23 08:40:30.389173", "stderr": 
>> "usage: \rNote: AWS CLI version 2, the latest major version of the AWS CLI, 
>> is now stable and recommended for general use. For more information, see 
>> the AWS CLI version 2 installation instructions at: 
>> https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html\n\nusage:
>>  
>> aws [options] <command> <subcommand> [<subcommand> ...] [parameters]\nTo 
>> see help text, you can run:\n\n  aws help\n  aws <command> help\n  aws 
>> <command> <subcommand> help\n\nUnknown options: InstanceWarmup:180", 
>> "stderr_lines": ["usage: ", "Note: AWS CLI version 2, the latest major 
>> version of the AWS CLI, is now stable and recommended for general use. For 
>> more information, see the AWS CLI version 2 installation instructions at: 
>> https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html";, 
>> "", "usage: aws [options] <command> <subcommand> [<subcommand> ...] 
>> [parameters]", "To see help text, you can run:", "", "  aws help", "  aws 
>> <command> help", "  aws <command> <subcommand> help", "", *"Unknown 
>> options: InstanceWarmup:180"*], "stdout": "", "stdout_lines": []}
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/a36daf18-cc83-4e4c-86f0-6539f3f78f64n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/a36daf18-cc83-4e4c-86f0-6539f3f78f64n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d4855cda-86a7-493d-aff5-38bd8888dea6n%40googlegroups.com.

Reply via email to