Your curl command places the output in /var/output/{{ item }}.json.
Your jq command reads the output from {{ item }}.json which is not 
/var/output/{{ item }}.json.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On May 19, 2023, at 1:21 AM, Narmada Karthika <[email protected]> wrote:

I am getting error saying  I am using 2 var_files.
ERROR! failed at splitting arguments, either an unbalanced jinja2 block or 
quotes:

I also tried using include_vars which gave me same error, the values in these 2 
files need to be replace at diff locations at play book
some one please suggest what is the best way for this

 name: post call to get servergroup
  hosts: localhost
  become: true
  gather_facts: no
  tasks:
    - name: set the facts per host
      set_fact:
        access_token: "{{ hostvars.localhost.output.stdout }}" # this is the 
output of the above play
    - name: Make a post call to get server details
      shell: |
        cd /var/output/
        curl --location --request GET "{{ serverlist }}" \--header 
'Authorization: Bearer "{{ access_token }}" > /var/output/"{{ item }}".json
        jq -r '.[]|.serverData[].servers[]' "{{ item }}".json > 
/home/deploy-user/ansible/group_vars/"{{ item }}".yml
      # item and server list from one file and
register: data
    - debug: msg="data , {{ repo }}" # this need to replaced from one var file
      loop:
        - dev
        - uat
        - stg2


--
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]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/41e35941-ac2e-48fe-9654-489f0c298c7dn%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/41e35941-ac2e-48fe-9654-489f0c298c7dn%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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/1A60AF1D-F9C4-4201-A7A6-5DFFBA77EB80%40nist.gov.

Reply via email to