How to best manage several containers in ansible

12 views
Skip to first unread message

Stefan Rasmusson

unread,
Dec 6, 2022, 7:57:09 AM12/6/22
to Ansible Project

I have a home server where I run 15+ containers. Some use common databases and some write to volumes. I have some tasks that need to be run before some of the containers and some tasks used to pull configuration from the server to the ansible controller.

How do I best arrange all of these containers in ansible? Right now I have every container in its own role, but that leads to a lot of code duplication. 

I have looked into compose, but as I need to run task before some containers start, it does not seem like a good fit.

Another idea is to try and write a role for all containers that then creates containers based on a config file, but that seem like recreating docker compose with some small extensions.


Any best practise here or suggestions and experience?


Richard Megginson

unread,
Dec 6, 2022, 9:15:08 AM12/6/22
to ansible...@googlegroups.com
The podman team and the linux-system-roles team have developed a podman role https://github.com/linux-system-roles/podman/ - you describe your containers/pods using the kubernetes yaml format and the role manages them for you.  Requires podman 4.2 or later.  The role also manages the various podman configuration files.  If you need more lower level container management, there is the containers.podman collection of modules.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/511d445d-8f48-4d35-86d4-341c29f48221n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages