remove LCM in ansibleSysCall
[ccsdk/distribution.git] / ansible-server / src / main / ansible-server / README
1 '''
2 /*-
3 * ============LICENSE_START=======================================================
4 * ONAP : APPC
5 * ================================================================================
6 * Copyright (C) 2017-2019 AT&T Intellectual Property.  All rights reserved.
7 * ================================================================================
8 * Copyright (C) 2017 Amdocs
9 * =============================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 *      http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21
22 * ============LICENSE_END=========================================================
23 */
24 '''
25
26 ============
27 INSTALLATION:
28 ============
29
30 Python:
31 -------
32 sudo apt-get install python2.7
33 sudo apt-get install python-pip
34 pip install requests
35
36 Ansible:
37 --------
38 sudo apt-get install software-properties-common
39 sudo apt-add-repository ppa:ansible/ansible
40 sudo apt-get update
41 sudo apt-get install ansible
42
43 ++ SQL db: The new version REST API code does not need sql db in ansible server
44
45 =============
46 CODE TESTING:
47 =============
48 1. Start RestServer: python RestServer.py
49
50 2. Try curl commands (case no secured REST: http & no authentication):
51 (we will need more samples for testing -Taka@att)
52
53 - curl -H "Content-type:application/json" -X POST -d '{"Id": "ap3929_1548451746", "PlaybookName": "ctpx/R7.0.1/ansible/healthcheck/site.yml", "Timeout": "10", "InventoryNames": "VM", "EnvParameters": {"vnf_instance": "ctpx5000v"}}' http://0.0.0.0:8000/Dispatch
54
55 response: {"StatusMessage": "PLAYBOOK INVENTORY FILE NOT FOUND", "StatusCode": 101}
56
57 - Request to execute playbook:
58 curl -H "Content-type: application/json" -X POST -d '{"Id": "10", "PlaybookName": "ansible_sleep", "NodeList": ["host"], "Timeout": "60", "EnvParameters": {"Sleep": "10"}}' http://0.0.0.0:8000/Dispatch
59
60 response: {"ExpectedDuration": "60sec", "StatusMessage": "PENDING", "StatusCode": 100}
61
62 - Get results (blocked until test finished):
63 curl --cacert ~/SshKey/fusion_eric-vm_cert.pem --user "appc:abc123" -H "Content-type: application/json" -X GET  "http://0.0.0.0:8000/Dispatch/?Id=10&Type=GetResult"
64
65 response: {"Results": {"localhost": {"GroupName": "host", "StatusMessage": "SUCCESS", "StatusCode": 200}}, "PlaybookName": "ansible_sleep", "Version": "0.00", "Duration": "11.261794", "StatusMessage": "FINISHED", "StatusCode": 200}
66
67 - Delete playbook execution information
68 curl --cacert ~/SshKey/fusion_eric-vm_cert.pem --user "appc:abc123" -H "Content-type: application/json" -X DELETE  http://0.0.0.0:8000/Dispatch/?Id=10
69
70 response: {"StatusMessage": "PLAYBOOK EXECUTION RECORDS DELETED", "StatusCode": 200}