Syntax error on the last line in the ansible playbook [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Syntax error on the last line in the ansible playbook [closed]



All,
My playbook is almost ready. Only the last line with alias is giving me issues. I tried to look at what I am doing wrong in the yaml syntax checker but still not able to find it. Any clue what I am doing wrong? I tried escaping the forward slash but still no luck :(



I am bad at finding the syntax errors in general. So appreciate any clues you folks can provide in finding the problem.


tasks:
- name: Create a KMS key for using the aws cli
command: 'aws kms create-key --profile=" aws_profile " --region=" aws_region "'
register: newkeydetails

- name: Display the values for the variable output
set_fact: newkeydetails=" newkeydetails.stdout "

- name: Display the value of keyid
debug:
msg: " newkeydetails.KeyMetadata.KeyId "

- name: Create a alias name for KMS key using the aws cli
command: 'aws kms create-alias --alias-name 'alias/anothernewkeydetailskey' --target-key-id '" newkeydetails.KeyMetadata.KeyId "' --profile=" aws_profile " --region=" aws_region "'



This question appears to be off-topic. The users who voted to close gave this specific reason:





Might this issue be due to not escaping your single quotes in the last line? Perhaps the following might work? 'aws kms create-alias --alias-name "alias/anothernewkeydetailskey" --target-key-id " newkeydetails.KeyMetadata.KeyId " --profile=" aws_profile " --region=" aws_region "
– Andrew Fan
Aug 8 at 2:29



'aws kms create-alias --alias-name "alias/anothernewkeydetailskey" --target-key-id " newkeydetails.KeyMetadata.KeyId " --profile=" aws_profile " --region=" aws_region "





Also, if you are wondering what I am trying to do. I am trying to use the command module to create a new AWS KMS key and then, create the alias for the key.
– Pradeep Prasad
Aug 8 at 2:30





Appreciate your help Andrew. Yes you are correct. This is what got me working:
– Pradeep Prasad
Aug 8 at 2:41





command: 'aws kms create-alias --alias-name "alias/anothernewkeydetailskey" --target-key-id " newkeydetails.KeyMetadata.KeyId " --profile=" aws_profile " --region=" aws_region "'
– Pradeep Prasad
Aug 8 at 2:41




1 Answer
1



The reason for the issue here was due to the usage of single quotes in the last line, as they were not escaped, resulting in parsing errors.



The working solution involves removing unnecessary quotes, resulting in the following:



'aws kms create-alias --alias-name "alias/anothernewkeydetailskey" --target-key-id " newkeydetails.KeyMetadata.KeyId " --profile=" aws_profile " --region=" aws_region "


'aws kms create-alias --alias-name "alias/anothernewkeydetailskey" --target-key-id " newkeydetails.KeyMetadata.KeyId " --profile=" aws_profile " --region=" aws_region "

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard