thelastpickle / tlp-cluster

tlp-cluster, a tool for launching Cassandra clusters in AWS
http://thelastpickle.com/tlp-cluster/
Other
21 stars 11 forks source link

Replacing all the bash setup with ansible #103

Open rustyrazorblade opened 5 years ago

rustyrazorblade commented 5 years ago

I had originally written all the tooling in straight bash to avoid some of the complexity of using a tool like Puppet, Salt, or Ansible.

Looking at the work we have ahead, there's quite a bit to do that might be a little bit easier if we used Ansible. It works over SSH, supports for pushing files around, bulk executing commands. I think it could be a nice replacement for our parallel ssh / rsync / bash / duct tape thing.

Thoughts @jsanda, @ossarga ?

jsanda commented 5 years ago

I am not terribly familiar with the implementation of tlp-cluster. Can you give me an example of something you might considering replacing with Ansible?

rustyrazorblade commented 5 years ago

Right now when we provision a node we use parallel-rsync to push up the Cassandra deb package and a bunch of custom install scripts.

The scripts are here:

https://github.com/thelastpickle/tlp-cluster/tree/master/src/main/resources/com/thelastpickle/tlpcluster/commands/origin/provisioning/cassandra

The install process is very DIY. Each of those scripts run in numbered order to set up the server.

My understanding is that Ansible has it's own bulk rsync feature as well as parallel ssh. If it has any similarity to puppet and salt I think it would also have the ability to ensure packages are installed, host file entries exist, configs are in place, etc. I'm hoping it can probably also auto-restart services if their configs change.

Am I on the right track here or way off base?

jsanda commented 5 years ago

I am not familiar with Salt so I cannot comment on it. I only have a little bit of experience with puppet, but I know that it has a big distinction with ansible in terms of architecture. Puppet has a centralized server with an agent running on each machine that it manages. The agent periodically checks in with the server to check for changes. Ansible has a simpler architecture in that there is neither a server nor an agent. The only thing ansible requires on the target machines is ssh. You do not even need python (it can be bootstrapped with the raw task).

By default ansible with execute tasks on groups of machines in parallel. There are different ways to go about controlling how/when things are executed.

There are tasks for copying files to remote machines, but task execution happens on the remote machines. The templating features are really flexible and that would be a good example of where files are pushed out to remote machines. Here is a good example:

---
hosts: cassandra_hosts
tasks:
  - name: Template cassandra.yaml
    template:
      src: cassandra.yaml.j2
      dest: /etc/cassandra/conf/cassandra.yaml

This playbook will run on all machines in the cassandra_hosts group. It will copy the template to each machine. The template is run through jinja and the results are then copied to /etc/cassandra/conf/casandra.yaml.

Tasks are generally designed to be idempotent. And yes it is very common to have tasks/playbooks for installing/updating packages, starting/restarting services, applying config changes, etc.

At some point in the near future, I would be happy to walk through some examples if you'd like.

rustyrazorblade commented 5 years ago

As a migration tactic, is it possible to have ansible run the current shell scripts, and migrate to the more conventional ansible style over time?

jsanda commented 5 years ago

yes

On Tue, Apr 23, 2019 at 3:21 PM Jon Haddad notifications@github.com wrote:

As a migration tactic, is it possible to have ansible run the current shell scripts, and migrate to the more conventional ansible style over time?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/thelastpickle/tlp-cluster/issues/103#issuecomment-485939565, or mute the thread https://github.com/notifications/unsubscribe-auth/AABJBOJ7QO6LBBA643ZRKO3PR5OSLANCNFSM4HHSY5TA .

--