alpine build, implement to follow VNF anisble Req
[ccsdk/distribution.git] / ansible-server / src / main / scripts / 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 * ============LICENSE_END=========================================================
24 */
25 '''
26
27 ============
28 INSTALLATION:
29 ============
30
31 Python:
32 -------
33 sudo apt-get install python2.7
34 sudo apt-get install python-pip
35 pip install requests
36
37 Ansible:
38 --------
39 sudo apt-get install software-properties-common
40 sudo apt-add-repository ppa:ansible/ansible
41 sudo apt-get update
42 sudo apt-get install ansible
43
44 ++ SQL db: The new version REST API code does not need sql db in ansible server
45
46 =============
47 CODE TESTING:
48 =============
49 1. Start RestServer: python RestServer.py
50
51 2. Try curl commands (case no secured REST: http & no authentication):
52 (we will need more samples for testing -Taka@att)
53
54 - 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
55
56 response: {"StatusMessage": "PLAYBOOK INVENTORY FILE NOT FOUND", "StatusCode": 101}
57
58 - Request to execute playbook:
59 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
60
61 response: {"ExpectedDuration": "60sec", "StatusMessage": "PENDING", "StatusCode": 100}
62
63 - Get results (blocked until test finished):
64 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"
65
66 response: {"Results": {"localhost": {"GroupName": "host", "StatusMessage": "SUCCESS", "StatusCode": 200}}, "PlaybookName": "ansible_sleep", "Version": "0.00", "Duration": "11.261794", "StatusMessage": "FINISHED", "StatusCode": 200}
67
68 - Delete playbook execution information
69 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
70
71 response: {"StatusMessage": "PLAYBOOK EXECUTION RECORDS DELETED", "StatusCode": 200}