Answer the question
In order to leave comments, you need to log in
What structure should I choose for an Ansible config with multiple sites on a host?
There is a certain infrastructure managed through Ansible. The infrastructure has virtual machines with sites on django. One virtual machine can have several sites or only one. How to organize the Ansible config to make it as easy as possible to add a new site (to an existing virtual machine or to a new one)?
(I call a site a separate instance of Django or something else that is given through nginx as a separate website on its own domain or on several. Each site is a separate server in the nginx config)
I see two options.
Cheat variant We
specify in inventory.ini each site as a separate host:
[real_host_name]
site_name.ru ansible_ssh_host=11.22.33.44
another_site.com ansible_ssh_host=11.22.33.44
- hosts: real_host_name
roles:
- common
- nginx
.... и другие общие задачи — настроить локаль, поставить пакеты, создать пользователей
- hosts: site_name.ru
roles:
- nginx_site
- deploy
- django
... и другие задачи, относящиеся к конкретному сайту — создать директории проектов,
выкатить код, положить локальные конфиги
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question