diff --git a/README.md b/README.md index d5f8b40..02e0019 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,9 @@ Currently, the playbook will: * Install dependencies (nodejs, caddy, unzip) * Create a foundry user/group * Extract the Foundry app onto the remote server +* Set up a data directory for Foundry to use * Configure caddy to reverse proxy the app - -Things it still needs: -* Unit file to run the app -* Configuration file for Foundry itself -* A data directory for Foundry to use - +* Set up a systemd unit to run the app # Usage instructions diff --git a/foundry_playbook.yml b/foundry_playbook.yml index 317455f..e612f48 100644 --- a/foundry_playbook.yml +++ b/foundry_playbook.yml @@ -7,11 +7,22 @@ environment: DATA_DIRECTORY: /home/foundry/data tasks: - - name: Apt repos - shell: | - curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - - curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add - - curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee -a /etc/apt/sources.list.d/caddy-stable.list + - name: Node GPG keys + apt_key: + url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key + state: present + - name: Caddy GPG keys + apt_key: + url: https://dl.cloudsmith.io/public/caddy/stable/gpg.key + state: present + - name: Node apt repo + apt_repository: + repo: deb https://deb.nodesource.com/node_14.x focal main + state: present + - name: Caddy apt repo + apt_repository: + repo: deb https://dl.cloudsmith.io/public/caddy/stable/deb/ubuntu focal main + state: present - name: Dependencies apt: update_cache: yes @@ -34,18 +45,50 @@ state: directory owner: foundry group: foundry - mode: '0644' - - name: Foundry archive - unarchive: - src: ./foundryvtt.zip - dest: /home/foundry/foundry_app + mode: '0744' + - name: Foundry data directory + file: + path: /home/foundry/foundry_data + state: directory owner: foundry group: foundry - mode: '0644' + mode: '0744' + - name: Foundry archive + copy: + src: ./foundryvtt.zip + dest: /home/foundry/foundryvtt.zip + owner: foundry + group: foundry + mode: '0744' + register: foundry_archive + - name: Foundry extract + unarchive: + src: /home/foundry/foundryvtt.zip + dest: /home/foundry/foundry_app + remote_src: yes + owner: foundry + group: foundry + mode: '0744' + when: foundry_archive.changed - name: Caddyfile template: src: ./Caddyfile.j2 dest: /etc/caddy/Caddyfile - owner: root - group: root - mode: '0644' + owner: caddy + group: caddy + mode: '0744' + - name: Foundry unit file + copy: + src: ./foundryvtt.service + dest: /etc/systemd/system/foundryvtt.service + - name: Refresh systemd + systemd: + daemon_reload: yes + - name: Foundry service + systemd: + name: foundryvtt.service + state: restarted + - name: Caddy service + systemd: + name: caddy.service + state: restarted diff --git a/foundryvtt.service b/foundryvtt.service new file mode 100644 index 0000000..bfe14ad --- /dev/null +++ b/foundryvtt.service @@ -0,0 +1,15 @@ +[Unit] +Description=Foundry VTT +Documentation=https://foundryvtt.com +After=network.target + +[Service] +Type=simple +User=foundry +Group=foundry +ExecStart=/home/foundry/foundry_app/resources/app/main.js --dataPath=/home/foundry/foundry_data +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target