-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathcreate_inventory.sh
executable file
·24 lines (19 loc) · 1.44 KB
/
create_inventory.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
read -p "Username: " CURL_USER
read -p "Password:" -s CURL_PASSOWRD
INVENTORY_NAME="myInventory"
QUERY_NAME="endpointsByZypperVersion"
SERVER_ADDR="$1"
# create inventory
echo -e "\nCreating an inventory ..."
curl -f -u ${CURL_USER}:${CURL_PASSOWRD} -H "Content-Type: application/json" -d "{\"name\": \"$INVENTORY_NAME\"}" "http://${SERVER_ADDR}/api/v1/org/Default/inventory"
# create inventory data
echo -e "\nUploading inventory data isp.s01160.ca_ansiblefacts ..."
curl -f -u ${CURL_USER}:${CURL_PASSOWRD} -H "Content-Type: application/json" -d @isp.s01160.ca_ansiblefacts.json "http://${SERVER_ADDR}/api/v1/org/Default/inventory/$INVENTORY_NAME/data/s01160/ansible_facts"
echo -e "\nUploading inventory data s05505.us_ansiblefacts ..."
curl -f -u ${CURL_USER}:${CURL_PASSOWRD} -H "Content-Type: application/json" -d @isp.s05505.us_ansiblefacts.json "http://${SERVER_ADDR}/api/v1/org/Default/inventory/$INVENTORY_NAME/data/s05505/ansible_facts"
echo -e "\nUploading inventory data s00524.us_ansiblefacts ..."
curl -f -u ${CURL_USER}:${CURL_PASSOWRD} -H "Content-Type: application/json" -d @rxp.s00524.us_ansiblefacts.json "http://${SERVER_ADDR}/api/v1/org/Default/inventory/$INVENTORY_NAME/data/s00524/ansible_facts"
# create query
echo -e "\nCreating a named query ..."
curl -f -u ${CURL_USER}:${CURL_PASSOWRD} -H "Content-Type: text/plain" --data-binary @query.sql "http://${SERVER_ADDR}/api/v1/org/Default/inventory/$INVENTORY_NAME/query/${QUERY_NAME}"