Cameron Bolourchi
Cameron Bolourchi

Reputation: 23

Restarting Services on multiple Boxes

I've been getting a handle on Ansible for a couple weeks now. I think it's coming along well. All my work has been 1-to-1 or one Ansible job to one server/process.

What's the best way to handle restarting services on multiple servers?

Ex: I need to restart an app server and database server with slave.

The main issue is I need to maintain a order similar to this: S1 Stop application S3 Stop replication S2 Restart master S1 Restart application S3 Start replication

Or am I overthinking this too much?

Thanks.

Upvotes: 2

Views: 885

Answers (1)

Xiong Chiamiov
Xiong Chiamiov

Reputation: 13734

This sounds like a pretty straightforward playbook to me:

---
- hosts: s1
  tasks:
    - name: stop application

- hosts: s3
  tasks:
    - name: stop replication

- hosts: s2
  tasks:
    - name: restart master

- hosts: s1
  tasks:
    - name: start application

- hosts: s3
  tasks:
    - name: start replication

(You'll need to fill in the task definitions with whatever you actually need to do.)

Playbooks are all about defining a series of steps to take, and they don't have to all be on one set of servers.

Upvotes: 3

Related Questions