- inventory 조회
$ curl -X GET http://192.168.20.10:8801/api/v2/inventory/ \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer LQHjuUuJIn0jWjXLZ9LGVJEqXalvJM' | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'
- Credential 정보 조회
$ curl -X GET http://192.168.20.10:8801/api/v2/credentials/ \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer LQHjuUuJIn0jWjXLZ9LGVJEqXalvJM' | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'
- job templates조회
$ curl -X GET http://192.168.20.10:8801/api/v2/job_templates/ \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer LQHjuUuJIn0jWjXLZ9LGVJEqXalvJM' | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'
- job template 실행
$ curl -X POST http://192.168.20.10:8801/api/v2/job_templates/46/launch/ \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer LQHjuUuJIn0jWjXLZ9LGVJEqXalvJM' \
--data '{
"inventory": 2,
"limit": "192.168.209.10",
"credentials": [2],
"extra_vars": {
"MAX_JOB": 1,
"SVC_USER": "user",
"INSTALL_PATH": "/home/",
"RUN_TYPE": "CMD",
"RUN_CMD":"ls -l"
}
}'
- template ID가 46이고, inventory id가 2, credential id 가 2 인 job 수행
- 호스트 등록
$ curl -X POST http://192.168.20.10:8801/api/v2/inventories/2/hosts/ \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer LQHjuUuJIn0jWjXLZ9LGVJEqXalvJM' \
--data '{
"name": "192.168.200.10",
"enabled": "true",
"variables": "use: yes\ntest: no"
}'
- inventory id가 2이고, 182.168.200.10에 use, test라는 변수를 적용해서 호스트 등록
- 그룹에 해당 호스트 추가
$ curl -X POST http://192.168.20.10:8801/api/v2/groups/6/hosts/ \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer LQHjuUuJIn0jWjXLZ9LGVJEqXalvJM' \
--data '{
"name": "192.168.200.10",
"enabled": true
}'
- group id가 6번인 그룹에 192.168.200.10 호스트 등록
- 호스트 삭제
$ curl -X POST http://192.168.20.10:8801/api/v2/inventories/2/hosts/ \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer LQHjuUuJIn0jWjXLZ9LGVJEqXalvJM' \
--data '{
"id": 75,
"disassociate": "True"
}'