Christian
Christian

Reputation: 4249

Best practice to manage my clients' hosts and apps using Ansible

Some of my clients have virtual machines for their websites which I want to manage using Ansible.

I'm sure that roles are the way to go. I can assign common roles like "web server" and "mail daemon" to my clients' hosts as well as deploy i.e. multiple Wordpress instances to one host using parametrized roles.

What I'm not sure about is how to assign these roles to my clients' hosts. What is the best practice to use inventory files, groups, playbooks, host_vars, group_vars and so on to assign roles (including multiple assignment of a parametrized role) to the hosts? Should I add each host to a playbook and assign the roles there? Should I assign roles to groups only (but then I could not add multiple parametrized roles? Or maybe I could, using host_vars or something like that)?

Upvotes: 2

Views: 1078

Answers (1)

Christian
Christian

Reputation: 4249

What I'm doing now is to create a directory deploy inside each of my client's project directories. These directories contain a host file with the hosts of the client (often its only one) and two playbooks: configure.yml and deploy.yml. I group the hosts and assign the roles to the groups:

- name: Basic configuration
  hosts: all
  user: root
  roles:
  - common

I don't use a host file containing all my different clients' hosts because I guess I never want to play a book on all these hosts at the same run.

The common roles are linked to the deploy directories (one could also use the roles_path option).

Upvotes: 3

Related Questions