
- name: docker | install portainer | create directory
  file:
    path: "/opt/docker/portainer"
    state: directory
    owner: "root"  # not required. Name of the user that should own the file/directory, as would be fed to I(chown).

- name: docker | install portainer | docker run
  command:
    cmd: "docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /opt/docker/portainer/data:/data portainer/portainer:latest" # not required. The command to run.
    creates: /opt/docker/portainer/data