elasticluster.providers.ansible_provider

class elasticluster.providers.ansible_provider.AnsibleSetupProvider(groups, playbook_path=None, environment_vars=None, storage_path=None, sudo=True, sudo_user='root', slow_but_safer=False, **extra_conf)[source]

This implementation uses ansible to configure and manage the cluster setup. See https://github.com/ansible/ansible for details.

Parameters:
  • groups (dict) – dictionary of node kinds with corresponding ansible groups to install on the node kind. e.g [node_kind] = [‘ansible_group1’, ‘ansible_group2’] The group defined here can be references in each node. Therefore groups can make it easier to define multiple groups for one node.
  • playbook_path (str) – path to playbook; if empty this will use the shared playbook of elasticluster
  • environment_vars (dict) – dictonary to define variables per node kind, e.g. [node_kind][var] = value
  • storage_path (str) – path to store the inventory file. By default the inventory file is saved temporarily in a temporary directory and deleted when the cluster in stopped.
  • sudo (bool) – indication whether use sudo to gain root permission
  • sudo_user (str) – user with root permission
  • ansible_module_dir (str) – comma- or colon-separated path to additional ansible modules
  • slow_but_safer (bool) – Avoid using eatmydata to speed up installation of many packages which comprise several smallish files.
  • extra_conf – tbd.
Variables:
  • groups – node kind and ansible group mapping dictionary
  • environment – additional environment variables
HUMAN_READABLE_NAME = 'Ansible'

to identify this provider type in messages

cleanup(cluster)[source]

Deletes the inventory file used last recently used.

Parameters:cluster (elasticluster.cluster.Cluster) – cluster to clear up inventory file for
resume_cluster(cluster, extra_args=())[source]

As setup_cluster, but prefers to run a resume playbook, if one is available. A resume playbook is a playbook which is designed to restart a cluster after it has been paused, and can be more efficient than a setup playbook (since it can assume that the required software is already installed). If no such playbook is available, it will use the standard setup playbook and print a warning.

Parameters:
  • cluster (elasticluster.cluster.Cluster) – cluster to configure
  • extra_args (list) – List of additional command-line arguments that are appended to each invocation of the setup program.
Returns:

True on success, False otherwise. Please note, if nothing has to be configured, then True is returned.

Raises:

ConfigurationError if the playbook can not be found or is corrupt.

setup_cluster(cluster, extra_args=())[source]

Configure the cluster by running an Ansible playbook.

The ElastiCluster configuration attribute <kind>_groups determines, for each node kind, what Ansible groups nodes of that kind are assigned to.

Parameters:
  • cluster (elasticluster.cluster.Cluster) – cluster to configure
  • extra_args (list) – List of additional command-line arguments that are appended to each invocation of the setup program.
Returns:

True on success, False otherwise. Please note, if nothing has to be configured, then True is returned.

Raises:

ConfigurationError if the playbook can not be found or is corrupt.