How to manage images versions via docker-compose with Ansible I planned to use docker-compose and a few scripts to manage the deployment of my app on staging and production.
My idea was to use one docker-compose.yml with one .env file for each environment. In those .env files I would have set some specific values and the version of the different images that compose my application.

But then I discovered Ansible and it looks like my few scripts powered by a community of experts. So I started to investigate it and I would like to use it. 

Based on the best practices, I can easily imagine having a standard directory layout[1] with the one inventory for each environment. And a couple of roles. 

However, I have no idea how to manage the versions; how to describe which version is executed in one environment?

Ideally, I would like to find a simple solution where my CI can update this version.

Thanks

[1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#directory-layout
The best way is of course (like Zeitounator comments) to use a inventory var. Either you use the version number in the docker-compose task as a variable or you create a Jinja2 template docker-compose.yml.j2 and use the variable there. That's what I do.

Example:

all:
  hosts:
    host1.prod:
      image: "xyz/12"
    host2.dev:
      image: "xyz/latest"


And the docker-compose.yml.j2 contains the variable:

version: '2.1'

services:
  myservice:
    image: "{{ image }}"
    ...