--- - name: Deploy gomoku project hosts: all become: yes vars: app_user: 'gomoku' app_home: '/home/{{ app_user }}' tasks: - name: Ensure user exists user: name: '{{ app_user }}' shell: /bin/bash create_home: yes home: '{{ app_home }}' - name: Create data directory file: path: '{{ app_home }}/public' state: directory owner: '{{ app_user }}' group: '{{ app_user }}' - name: Copy binary to target location copy: src: ../target/gomoku dest: '{{ app_home }}/gomoku' owner: '{{ app_user }}' group: '{{ app_user }}' mode: '0755' - name: Copy data directory synchronize: src: ../public/ dest: '{{ app_home }}/public/' recursive: yes owner: no group: no archive: yes delete: yes - name: Ensure Caddy directory exists file: path: /etc/caddy/sites state: directory - name: Copy Caddy configuration copy: src: gomoku.caddy dest: /etc/caddy/sites/gomoku.caddy owner: root group: root mode: '0644' register: caddy_config_copy - name: Restart Caddy service if config changed systemd: name: caddy state: restarted daemon_reload: yes when: caddy_config_copy.changed - name: Ensure Supervisor directory exists file: path: /etc/supervisor/conf.d state: directory - name: Copy Supervisor configuration copy: src: gomoku.supervisor dest: /etc/supervisor/conf.d/gomoku.conf owner: root group: root mode: '0644' - name: Reload Supervisor supervisorctl: name: gomoku state: present - name: Restart the service supervisorctl: name: gomoku state: restarted