This set of scripts helps you to manage separate clusters in your cloud. The tool lets you create and cleanup a
cluster of your choice (see #Configuration).
$ ./main.py -h
usage: main.py [-h] -a {create,cleanup,prepare_ansible,run_ansible}
[-c CONFIG] [-v]
project
Cloud CLI tool
positional arguments:
project the name of the project
optional arguments:
-h, --help show this help message and exit
-a | --action {create,cleanup,prepare_ansible,run_ansible}
the action to do
-c | --config CONFIG
path to the configuration file
-v, --verbose set verbosity mode
The following examples will show how to setup a cluster (after configuring all necessary settings in the config file):
# create cluster with an external config.yml + show debug messages
$ ./main.py --action create --config /path/to/config.yml -vvv myproject
# after cluster has been created, generate necessary ansible files + show only 'info' level logging
$ ./main.py --action prepare_ansible --config /path/to/config.yml -vv myproject
# run ansible playbook to setup software infrastructure
$ ./main.py -a run_ansible -c /path/to/config.yml myproject
# cleanup cluster from the cloud
$ ./main.py -a cleanup -vvv myprojectYou can find the configuration files in the ./config dir.
This configuration file is the main configuration for the CLI tool. You can set the following parameters:
-
projectthe name of the project (cluster) you want to manage.
-
projects_dir- the path to the default projects directory- default:
./projects
- default:
-
platform- the cloud platform of your choice- default:
openstack - currently supported platforms:
openstack
- default:
-
platform_settings_fileoptional - the path to settings_file for the platform. It's the same assettings_fileinsupported_platforms.ymlbut if defined, has a higher priority (easier to define openstack credentials outside the source) -
networkdict - the network settings for your cluster (when creating)cidr- the CIDR for your cluster's network.- default:
auto - possible values:
autoorXXX.XXX.XXX.0/24
- default:
cidr_template- the CIDR template. Currently the script will substitute theXcharacter from the template.- default:
10.X.100.0/24 - Required when
cidr == auto, otherwise optional
- default:
ext_net_name- the name of the gateway for your network to connect to the external network- default:
ext-net
- default:
-
vm_managementdict - vm management settings for your cluster (when creating)default_image_name- the default name of the image to use to spin up a vm. If you don't specify theimage_nameproperty for a host, this value will be used.- default:
Ubuntu 14.04.2_20150505
- default:
default_vm_flavor- the name of the flavor to spin up a vm. If you don't specify thevm_flavorproperty for a host, this value will be used.- default:
m1.medium
- default:
hosts_startup_timeout- the amount of time (in seconds) to wait to spin up all the vms and then keep executing the rest of the script- default:
600
- default:
terminate_vm_poll- the amount of time (in seconds) to wait between polls when terminating vms- default:
5
- default:
-
hostsarray - the section to setup host configs. Each array item is ahostdict, which is a configuration for one host-
namerequired - the name of the host -
vm_flavoroptional - the name of the flavor to spin up a vm. This property overridesvm_management.default_vm_flavor -
countoptional - the number of vms to spin up with these properties. If this field is missing, default value of1will be used. -
image_nameoptional - the name of the image to spin up a vm. This property overridesvm_management.default_image_name -
cloud_varsoptional array - implementation specific special variables. Each item in the array must be a dict that contains the following parameter:-
indexall | <number> - the index to which host to apply the current special var- possible values can be
allor the index<number>of the host - see
config/default.ymlas example
Implemented options so far:
assignPublicIPboolean - whentrue, a public IP will be assigned to theindex-th host
- possible values can be
-
-
ansible_settingsarray - the section to setup the ansible settings for the host. Each item in the array is a dict with the following parameters:-
ansible_group- which ansible group this host will belong to -
group_varsarray - an array of dict items to describe group-level variables. Each item must contain an index key and the desired parameter key with its valueindex- which item in the list should have the parameter keyparameter_key: parameter_value- the parameter key-value to add in the inventory file for the current host
-
item_varsarray - an array of key-value pairs that every item should contain in the group
-
-
-
ansibledict - ansible settings to setup the software infrastructureansible_dir- the path to directory where your ansible project files resideplaybook- relative path to the playbook to run your setuptemplates_path- path to folder that contains template filesinventory_templateoptional - a jinja2 template file for your inventory to usessh_config_templateoptional - a jinja2 template file for thessh.configfileansible_cfg_templateoptional - a jinja2 template file for theansible.cfgfileansible_bin_pathrequired - the folder that holdsansible,ansible-playbook, etc
** For OpenStack networking the official OpenStack SDK was used as libcloud doesn't support the required functionalities (i.e. creating/removing subnets, networks, routers, etc).
UPDATE libcloud dropped completely.
./config/supported_platforms.yml contains the implementations of different platforms (so far only openstack is supported).