Thank you so much Vladimir Botka.And it works now. On Thursday, June 16, 2022 at 2:18:37 PM UTC+5:30 Nipun Jain wrote:
> Hi Dick, > I understand your point ..I want to achieve the list of amis which is > based on creation date.For example i want to print out list of amis for > last 3 days and the output showing only 3 days before amis info....Thats > the aim of above script. > I hope you understand my problem situation.Imagine you have 100 amis so u > want to get info of particular date of amis like filters. > > On Thursday, June 16, 2022 at 12:41:25 PM UTC+5:30 [email protected] > wrote: > >> To start with You cannot use operators like > < etc on a string like >> '2022-06-10'. >> Can you be more clear about what you want to achieve? >> >> >> On Thu, 16 Jun 2022 at 06:19, Nipun Jain <[email protected]> wrote: >> >>> Hi Team, >>> Looking forward to any input. >>> >>> *With Best Regards* >>> >>> Nipun Jain >>> >>> >>> On Wed, Jun 15, 2022 at 2:40 PM Nipun Jain <[email protected]> wrote: >>> >>>> Hi, >>>> I am trying to fetch the json data from ami info in the existing yml >>>> using ansible.Now i am getting errors regarding json query format in >>>> number >>>> expression. >>>> I need help with proper json query under set fact so that the >>>> indentation is maintained.Please suggest how this can be achieved. >>>> I am using below code for this :- >>>> --- >>>> - name: List AMI info >>>> hosts: localhost >>>> gather_facts: yes >>>> tasks: >>>> - name: Gather AMI Info >>>> amazon.aws.ec2_ami_info: >>>> owners: self >>>> region: us-east-1 >>>> filters: >>>> state: available >>>> register: result >>>> >>>> - name: Set fact date from last {{ec2_input_day}} days >>>> run_once: yes >>>> set_fact: >>>> ec2_f_date: "{{ lookup('pipe','date \"+%Y-%m-%d\" -d >>>> \"{{ec2_input_day}} day ago\"') }}" >>>> - debug: >>>> var: ec2_f_date >>>> >>>> - name: Set fact date from {{ec2_input_day}} days using amis filters >>>> run_once: yes >>>> set_fact: >>>> ec2_f_amis: "{{ result | json_query(\"item[?creation_date<= \" >>>> + ec2_f_date + \"]\") }}" >>>> - debug: >>>> var: ec2_f_amis >>>> >>>> PLease feel to run this script.Use this command => >>>> >>>> ansible-playbook <any_file>.yml -e ec2_input_day="'<any number>" >>>> >>>> The output i am getting now is this :- >>>> fatal: [localhost]: FAILED! => {"msg": "JMESPathError in json_query >>>> filter plugin:\ninvalid token: Parse error at column 22, token \"2022\" >>>> (NUMBER), for expression:\n\"item[?creation_date<= 2022-06-10]\"\n >>>> ^"}. >>>> >>>> Thank you. >>>> >>>> >>>> >>>> >>>> *Disclaimer: **© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains >>>> PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the >>>> addressee(s). If you are not the intended recipient, please notify the >>>> sender by e-mail and delete the original message. Further, you are not to >>>> copy, disclose, or distribute this e-mail or its contents to any other >>>> person and any such actions are unlawful.* >>>> >>>> >>>> -- >>>> 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/aafeafa7-c036-48de-ab31-6fd88460afcen%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/ansible-project/aafeafa7-c036-48de-ab31-6fd88460afcen%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> >>> *Disclaimer: **© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains >>> PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the >>> addressee(s). If you are not the intended recipient, please notify the >>> sender by e-mail and delete the original message. Further, you are not to >>> copy, disclose, or distribute this e-mail or its contents to any other >>> person and any such actions are unlawful.* >>> >>> >>> -- >>> 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/CAK1%2BVp%3DooLs5VpN4f9%2BgnfoRwwYrvhMr9ZHvQMbSLM670cdY0w%40mail.gmail.com >>> >>> <https://groups.google.com/d/msgid/ansible-project/CAK1%2BVp%3DooLs5VpN4f9%2BgnfoRwwYrvhMr9ZHvQMbSLM670cdY0w%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> Sent from Gmail Mobile >> > -- _Disclaimer: _© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful._ _ _ _ __ -- 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/203a5d88-8394-4e89-a560-a48d39169237n%40googlegroups.com.
