how can i get only the arn value but not complete output saved in to variable
in the below example
TASK [debug] ****************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
“template_arn.results.0.stdout_lines[1]”: " "assessmentTemplateArn": "arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC""
i want to print only arn:aws:inspector:us-west-2:024283424342:target/0-Rrtw16WK/template/0-5KIIPQREcC\ i dont want “”““assessmentTemplateArn””“” to be saved to my variable
Can anyone please help
Thank you
playbook task
- name: “create Assessment template”
command: “{{ item }}”
with_items:
- aws inspector create-assessment-template --assessment-target-arn {{ target_arn }} --assessment-template-name {{ assessment_template_name }} --duration-in-seconds {{ run_duration }} --rules-package-arns {{ rules_arn }}
register: template_arn
tags: create-assessment-template
var: template_arn.results.0.stdout_lines[1]
tags: create-assessment-template
The output of that command is already json. Instead of fragile filtering a (hopefully) single line that contains your value and then trying to unquote that, please use the entire output in combination with the from_json filter to access the value.
Dick
thank you for the advise but i am new to json can you please help with the commad or any reference link