I am trying to fill an ansible variable with:
- "docker-ce" if on RedHat
- "docker" otherwise
the following works, but is not very clean:
docker_edition: 'ce'
docker_package: docker{{ "-" if (ansible_os_family == "RedHat") else "" }}{{ docker_edition if (ansible_os_family == "RedHat") else "" }}
I would like to write this in a single ternary expression, I have tried the following:
docker_package: "docker{{ (ansible_os_family == "RedHat") | ternary("","-{{ docker_edition }}") }}"
docker_package: docker{{ (ansible_os_family == "RedHat") | ternary("","-{{ docker_edition }}") }}
docker_package: docker{{ -{{ docker_edition }} if (ansible_os_family == "RedHat") else "" }}
but I fail to get this working.
For clarification, the following would work:
{{ "docker-ce" if (ansible_os_family == "RedHat") else "docker" }}
but I want to keep the docker_edition
variable separate since it is used elsewhere.