Swift object storage clusters with Ansible

OpenStack Swift is a most brilliant object store and I have built a few clusters over the last couple of years using SwiftStack’s product, which is really excellent. However, I need an alternative way of creating and managing clusters, that’s still inspired by SwiftStack.

Ansible seems a logical choice to me, as I need to manage packages, configure services and perform certain operations on a running cluster.

A couple of months ago I attended the Swift Ops feedback session at OpenStack PTG and said that I had been working on this. Several other attendees mentioned they are also looking at Ansible, or currently use it for bits and pieces, so hopefully this can grow into something useful!

My Ansible Swift role can currently build a Swift cluster from scratch (on CentOS 8 Stream nodes) and perform some basic operations. The idea is to define the nodes and their services (PACO) using YAML based Ansible inventory and use the role to perform specific actions. Together all of those actions let you build an entirely new cluster, or modify and manage an existing one. Over time, I plan to add new features and operational actions.

The role currently performs the following:

  • Prepare Swift nodes, including setting SELinux and ensuring SSH access
  • Add repositories and install packages (upstream RDO at the moment)
  • Configure dependent services, such as logging, rsyncd and memcached
  • Configure and enable TLS proxy endpoint for Proxy nodes
  • Configure keepalived for failover of Proxy VIPs
  • Configure Swift PACO services using templates and variables
  • Create initial account, container and object rings
  • Prepare disks on each node, format and mount to match the rings
  • Build and distribute the rings
  • Configure dispersion
  • Simple operational tasks such as:
    • Add new disks
    • Rebuild and distribute the rings
    • Reconfigure PACO services
    • Generate dispersion and replication reports

I’m working on a library for managing the rings, as it’s a bit clunky using the swift-ring-builder command in the role. So that’ll be the next focus, then onto other operations functions as well as moving from RPM packages to containers. Eventually I’d like to have a web service which can front-end the inventory and Ansible plays, providing a unified management platform.

I also provide sample inventory, playbooks and wrapper scripts on GitHub. Simply modify the inventory to suit your node and network setup and run the site.sh role wrapper script. It also optionally supports my virtual infrastructure role which means one can easily spin up a virtual, production-like multi-node Swift cluster from scratch on KVM hosts.

Running the Swift Ansible playbook

I would love any feedback and to collaborate on this with anyone, if it seems useful.

Leave a Reply

Your email address will not be published. Required fields are marked *