{% set docker = { 'Debian': {'pkg': 'docker.io'}, 'Suse': {'pkg': 'docker'}, 'RedHat': {'pkg': 'docker'} } %} docker installed: pkg.installed: - name: {{ docker.pkg }} python pip installed: pkg.installed: - name: python3-pip python docker installed: pip.installed: - name: docker-py - require: - pkg: python pip installed docker service running: service.running: - name: docker