ansible:basic: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 host in a playbook.

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

mkdir playbooks
vim playbooks/fws.yml

Here's a real world example

- 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 :

  • On the host proxyout.fws.fr, it will deploy the roles repo_base and squid
  • On the hosts members of group fws_dc, it'll deploy the roles system_proxy, repo_base, samba and letsencrypt
  • On all the hosts members of the group fws, it'll deploy the roles common, backup and filebeat
  • etc.

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

  • ansible/basic/playbooks.txt
  • Dernière modification: 12/02/2021 17:04
  • de dani