gautam-y / Ansible

Content related to Ansible
0 stars 0 forks source link

New #3

Open gautam-y opened 8 months ago

gautam-y commented 8 months ago

Get list of all Org ids and names into their respective array variables

fi_org_list="${reports_dir}/org_list_all.csv" rm $fi_org_list echo "Organization, Id" >> $fi_org_list echo "Creating list of all Organizations in file $fi_org_list..."

Make a request to the Tower API using curl

all_orgs_json=$(curl -X GET -H "Authorization: Bearer " -H "Content-Type: application/json" -k "/organizations/" -d "format=json")

Extract organization names and ids from the JSON response using jq

all_org_names=$(echo $all_orgs_json | jq '.results[].name' | tr -d '"') all_org_ids=$(echo $all_orgs_json | jq '.results[].id')

Combine the names and ids into a CSV file

paste -d ',' <(echo -e "$all_org_names") <(echo -e "$all_org_ids") >> $fi_org_list