• 20 Posts
  • 119 Comments
Joined 2 years ago
cake
Cake day: September 29th, 2023

help-circle

  • You can use host_vars to set different variables per host. You’d still run the same playbook against both hosts, but each has different services activated.

    1. Make the folder host_vars in the repo root
    2. Make subfolders for every host with their hostname
    3. Enable services you want by writing the variables into a yaml file for your host (any file name as long as it ends with .yml
    4. Write an Ansible inventory for your hosts
    5. Run the playbook with your inventory

    Slightly fancier would be using group_vars instead, you can add a host to multiple groups. Then deploying the same services on a new hosts would simply be adding it to the group