# Playbooks

## Playbooks

A playbook is a yaml file which list a set of action to run, and in which order. You can create your own tasks in a playbook, but most of the time, you'll just assign roles to hosts, or group of hosts in a playbook.

You can create your playbooks where you want, for example, in a playbook subdirectory

```shell
mkdir playbooks
vim playbooks/fws.yml
```

Here's a real world example

```YAML
- name: Deploy outbound proxy server
  hosts: proxyout.fws.fr
  roles:
    - repo_base
    - squid

- name: Deploy AD DC
  hosts: fws_dc
  roles:
    - system_proxy
    - repo_base
    - samba
    - letsencrypt

- name: Deploy common profiles
  hosts: fws
  roles:
    - common
    - backup
    - filebeat

- name: Deploy Proxmox hosts
  hosts: fws_pve
  roles:
    - pve

- name: Deploy databases servers
  hosts: db.fws.fr
  roles:
    - mysql_server
    - postgresql_server

```

In this example, if the playbook is ran, it'll do the following :

- <div>On the host **proxyout.fws.fr**, it will deploy the roles **repo\_base** and **squid**</div>
- <div>On the hosts members of group **fws\_dc**, it'll deploy the roles **system\_proxy**, **repo\_base**, **samba** and **letsencrypt**</div>
- <div>On all the hosts members of the group **fws**, it'll deploy the roles **common**, **backup** and **filebeat**</div>
- <div>etc.</div>

So, you have to define your playbook with what you want to do