3 * ============LICENSE_START=======================================================
5 * ================================================================================
6 * Copyright (C) 2017 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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 * ============LICENSE_END=========================================================
33 sudo apt-get install python2.7
34 sudo apt-get install python-pip
40 sudo apt-get install software-properties-common
41 sudo apt-add-repository ppa:ansible/ansible
43 sudo apt-get install ansible
48 sudo apt-get install mysql-server
50 Set root passwd during installation (i.e. password_4_mysql_user_id)
52 sudo service mysql restart
54 Setup mysql: N/A for SDNC
60 Create user (i.e. id=mysql_user_id psswd=password_4_mysql_user_id)
61 CREATE USER 'appc'@'%' IDENTIFIED BY 'password_4_mysql_user_id';
62 GRANT ALL PRIVILEGES ON *.* TO 'mysql_user_id'@'%';
63 SET PASSWORD FOR 'mysql_user_id'@'%'=PASSWORD('password_4_mysql_user_id');
66 CREATE SCHEMA ansible;
69 CREATE TABLE playbook (name VARCHAR(45) NOT NULL, value BLOB, type VARCHAR(60), version VARCHAR(60), PRIMARY KEY (name));
71 CREATE TABLE inventory (hostname VARCHAR(45) NOT NULL, hostgroup VARCHAR(45), credentials VARCHAR(500), PRIMARY KEY (hostname));
72 SHOW COLUMNS FROM playbook;
73 SHOW COLUMNS FROM inventory;
74 GRANT ALL PRIVILEGES ON *.* TO 'mysql_user_id'@'%' IDENTIFIED BY 'password_4_mysql_user_id' WITH GRANT OPTION;
75 GRANT ALL PRIVILEGES ON *.* TO 'ansible'@'%' IDENTIFIED BY 'ansible_agent' WITH GRANT OPTION;
81 python LoadAnsibleMySql.py
86 1. Start RestServer: python RestServer.py
88 2. Try curl commands (case no secured REST: http & no authentication):
90 - Request to execute playbook:
91 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
93 response: {"ExpectedDuration": "60sec", "StatusMessage": "PENDING", "StatusCode": 100}
95 - Get results (blocked until test finished):
96 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"
98 response: {"Results": {"localhost": {"GroupName": "host", "StatusMessage": "SUCCESS", "StatusCode": 200}}, "PlaybookName": "ansible_sleep", "Version": "0.00", "Duration": "11.261794", "StatusMessage": "FINISHED", "StatusCode": 200}
100 - Delete playbook execution information
101 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
103 response: {"StatusMessage": "PLAYBOOK EXECUTION RECORDS DELETED", "StatusCode": 200}