--- - name: Create Alloy directories file: path: "{{ item }}" state: directory owner: cbalders group: cbalders mode: '0755' loop: - /opt/alloy - /var/lib/alloy - name: Deploy Alloy compose template: src: docker-compose.yml.j2 dest: /opt/alloy/docker-compose.yml owner: cbalders group: cbalders mode: '0644' notify: restart alloy - name: Deploy Alloy config template: src: config.alloy.j2 dest: /opt/alloy/config.alloy owner: cbalders group: cbalders mode: '0644' notify: restart alloy # Bring Alloy up (idempotent — docker compose up -d is a no-op if running # and config hasn't changed). The handler force-recreates on config edit. - name: Ensure Alloy is running command: docker compose -f /opt/alloy/docker-compose.yml up -d args: chdir: /opt/alloy changed_when: false