3 * ============LICENSE_START=======================================================
5 * ================================================================================
6 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
30 sudo apt-get install python2.7
31 sudo apt-get install python-pip
37 sudo apt-get install software-properties-common
38 sudo apt-add-repository ppa:ansible/ansible
40 sudo apt-get install ansible
45 sudo apt-get install mysql-server
47 Set root passwd during installation (i.e. password_4_mysql_user_id)
49 sudo service mysql restart
57 Create user (i.e. id=mysql_user_id psswd=password_4_mysql_user_id)
58 CREATE USER 'appc'@'%' IDENTIFIED BY 'password_4_mysql_user_id';
59 GRANT ALL PRIVILEGES ON *.* TO 'mysql_user_id'@'%';
60 SET PASSWORD FOR 'mysql_user_id'@'%'=PASSWORD('password_4_mysql_user_id');
63 CREATE SCHEMA ansible;
66 CREATE TABLE playbook (name VARCHAR(45) NOT NULL, value BLOB, type VARCHAR(60), version VARCHAR(60), PRIMARY KEY (name));
68 CREATE TABLE inventory (hostname VARCHAR(45) NOT NULL, hostgroup VARCHAR(45), credentials VARCHAR(500), PRIMARY KEY (hostname));
69 SHOW COLUMNS FROM playbook;
70 SHOW COLUMNS FROM inventory;
71 GRANT ALL PRIVILEGES ON *.* TO 'mysql_user_id'@'%' IDENTIFIED BY 'password_4_mysql_user_id' WITH GRANT OPTION;
72 GRANT ALL PRIVILEGES ON *.* TO 'ansible'@'%' IDENTIFIED BY 'ansible_agent' WITH GRANT OPTION;
78 python LoadAnsibleMySql.py
83 1. Start RestServer: python RestServer.py
85 2. Try curl commands (case no secured REST: http & no authentication):
87 - Request to execute playbook:
88 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
90 response: {"ExpectedDuration": "60sec", "StatusMessage": "PENDING", "StatusCode": 100}
92 - Get results (blocked until test finished):
93 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"
95 response: {"Results": {"localhost": {"GroupName": "host", "StatusMessage": "SUCCESS", "StatusCode": 200}}, "PlaybookName": "ansible_sleep", "Version": "0.00", "Duration": "11.261794", "StatusMessage": "FINISHED", "StatusCode": 200}
97 - Delete playbook execution information
98 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
100 response: {"StatusMessage": "PLAYBOOK EXECUTION RECORDS DELETED", "StatusCode": 200}