- name: Download docker repository gpg key get_url: url: https://download.docker.com/linux/ubuntu/gpg dest: /usr/share/keyrings/docker.asg - name: Add docker repository apt_repository: repo: deb [arch=amd64 signed-by=/usr/share/keyrings/docker.asg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable - name: Install docker apt: update_cache: true name: - docker-ce - docker-ce-cli - python3-docker - name: Enable docker service systemd: name: docker state: started enabled: yes - name: Create home-assistant config directory file: path: /opt/homeassistant/config state: directory - name: Create home-assistant extra config directories file: path: '{{ item }}' state: directory with_items: - /opt/homeassistant/config/binary_sensors - /opt/homeassistant/config/mqtt - /opt/homeassistant/config/automations - name: Copy home-assistant config copy: src: configuration.yaml dest: /opt/homeassistant/config/configuration.yaml - name: Start home-assistant docker_container: name: home-assistant image: ghcr.io/home-assistant/home-assistant:{{ homeassistant.version }} state: started restart_policy: unless-stopped privileged: true network_mode: host volumes: - /opt/homeassistant/config:/config # - /run/dbus:/run/dbus:ro