Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Ansible role for deploying tarantool cartridge-based applications

License

Notifications You must be signed in to change notification settings

tarantool/ansible-cartridge

Repository files navigation

DEPRECATION NOTICE: This role will be deprecated by January 1, 2024. All open issues and pull requests will be closed shortly. ansible-cartridge will remain in public archive as Tarantool moves on with version 3.0. Please follow official community channels in Telegram — @tarantool (en), @tarantoolru (ru). Feel free to ask ansible related questions there.

Ansible Role: Tarantool Cartridge

Ansible Galaxy Releases

Unit Tests Molecule Tests Consistency Tests

An Ansible role to easily deploy Tarantool Cartridge applications.

This role can deploy and configure applications packed in RPM, DEB and TGZ using Cartridge CLI.

Only RedHat and Debian OS families are supported.

Table of contents

Requirements

  • Tarantool Cartridge >= 2.0.0, < 3;
  • Ansible 2.8.4 or higher.

Note that running the role may require root access.

Installation

First, you need to install this role using ansible-galaxy:

$ ansible-galaxy install tarantool.cartridge,1.12.0

Quick start

Check out the Getting Started guide to learn how to use this role.

You can start two virtual machines using example Vagrantfile.

Let's deploy an application with simple topology.

First, pack your application to RPM using cartridge pack rpm command.

Then, describe the topology in hosts.yml file:

hosts.yml:

---
all:
  vars:
    cartridge_app_name: myapp
    cartridge_package_path: ./myapp-1.0.0-0.rpm
    cartridge_cluster_cookie: secret-cookie

    # may be useful for vagrant
    ansible_ssh_private_key_file: ~/.vagrant.d/insecure_private_key
    ansible_ssh_common_args: '-o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'

  hosts:
    storage-1:
      config:
        advertise_uri: '172.19.0.2:3301'
        http_port: 8181

    storage-1-replica:
      config:
        advertise_uri: '172.19.0.2:3302'
        http_port: 8182

  children:
    # group instances by machines
    machine_1:
      vars:
        # first machine address and connection opts
        ansible_host: 172.19.0.2
        ansible_user: vagrant

      hosts:  # instances to be started on this machine
        storage-1:
        storage-1-replica:

    # group instances by replicasets
    storage_1_replicaset:  # replicaset storage-1
      hosts:  # instances
        storage-1:
        storage-1-replica:
      vars:
        # replicaset configuration
        replicaset_alias: storage-1
        roles:
          - 'vshard-storage'
        failover_priority:
          - storage-1
          - storage-1-replica

Write a simple playbook that imports role:

# playbook.yml
---
- name: Deploy my Tarantool Cartridge app
  hosts: all
  become: true
  become_user: root
  any_errors_fatal: true
  gather_facts: false
  roles:
    - tarantool.cartridge

Then run the playbook with created inventory:

ansible-playbook -i hosts.yml playbook.yml

Now, visit http://localhost:8181

image

Using scenario

It's possible to perform different actions with instances or replicasets by combining cartridge_scenario variable and Ansible limits.

For example, you can configure and start some instances. To do this, you should define cartridge_scenario variable like this:

cartridge_scenario:
  - configure_instances
  - start_instance
  - wait_instance_started

Then run playbook with --limit option:

ansible-playbook -i hosts.yml playbook.yml --limit instance_1,instance_2

You can also simply edit some replicaset. To do this, define cartridge_scenario variable like this:

cartridge_scenario:
  - edit_topology

After run playbook with --limit option:

ansible-playbook -i hosts.yml playbook.yml --limit replicaset_1_group,replicaset_2_group

Moreover, scenario allows you to describe custom steps for configuring cluster. For more details about using scenario and available steps, see scenario documentation.

Documentation

Cookbook

Learn the cookbook to know now to use the tarantool.cartridge role for different purposes.