Ansible variable in key/value key
问题 I'm passing env variables to a Docker container in an ansible playbook, how do I set an Ansible variable in the key in the key/value of an env? So this: - name: webproxy container docker_container: name: "webproxy" image: "webproxy" env: SERVICE_443_NAME: "webproxy" becomes this: - name: webproxy container docker_container: name: "webproxy" image: "webproxy" env: SERVICE_{{ port_number }}_NAME: "webproxy" 回答1: Use JSON notation to define a dictionary with environment variables: - name: