From 71b8e5a503d3607a42636a04ce7a8c437daa21cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20H=C3=B6sel?= Date: Sun, 5 Dec 2021 20:46:10 +0100 Subject: [PATCH] feat(pterodactyl_wings): use new config layout (#23) --- roles/pterodactyl_wings/README.md | 79 ++++++++++++++----- roles/pterodactyl_wings/defaults/main.yml | 35 ++++---- .../molecule/default/converge.yml | 25 ++++-- roles/pterodactyl_wings/tasks/main.yml | 23 +----- 4 files changed, 99 insertions(+), 63 deletions(-) diff --git a/roles/pterodactyl_wings/README.md b/roles/pterodactyl_wings/README.md index 3b5a09b..08cd6c2 100644 --- a/roles/pterodactyl_wings/README.md +++ b/roles/pterodactyl_wings/README.md @@ -26,6 +26,8 @@ This role follows the official installation instructions on the pterodactyl [doc - Directory in which the config file is stored - Default: `/etc/pterodactyl` +### Docker + ##### `pterodactyl_wings_docker_install` - Whether to handle the docker installation. - Set to `false` if you already have a docker install running and don't want this role to touch anything @@ -40,25 +42,46 @@ This role follows the official installation instructions on the pterodactyl [doc ### Wings Configuration -Prefix for all variables: `pterodactyl_wings_` - -| Name | Description | Required | Default | -|------|-------------|:--------:|---------| -| `remote` | Full URL of the panel instance (including http(s):// and port) | | `"https://127.0.0.1:443"` | -| `uuid` | UUID assigned to the node by the panel | X | not set | -| `token_id` | ID of the token assigned to the node by the panel | X | not set | -| `token` | Token assigned to the node by the panel | X | not set | -| `port` | Port on which the daemon will listen for requests | | 8080 | -| `ssl_cert` | SSL certificate file for the daemon. Must already be present | | `"/etc/letsencrypt/live/{{ ansible_fqdn }}/fullchain.pem"` | -| `ssl_key` | SSL key file for the daemon. Must already be present | | `"/etc/letsencrypt/live/{{ ansible_fqdn }}/privkey.pem"` | -| `data_dir` | Directory under which the servers will be stored | | `/var/lib/pterodactyl/volumes` -| `upload_limit` | Maximum file upload size in MB | | 100 | -| `sftp_port` | Port on which the SFTP server will listen on | | 2022 | -| `allowed_mounts` | Allowed mounts on this node as configured in the panel | | `[]` | +The `pterodactyl_wings_config` is a dictionary representing the configuration file of the wings daemon. This configuration +will be merged with any existing configuration already present on the node. -## Example Playbooks +To get started, you can adjust the configuration below. To get a more complete configuration file, use the panel to generate one +or read it from an existing wings daemon. + +**NOTE**: You must provide your own uuid, token_id and token values. These can be viewed in the node settings in the panel. + +**NOTE**: The TLS certificate for the wings daemon must be present at the supplied path (defaults to Let's Encrypt). +Default configuration: + +```yaml +pterodactyl_wings_config: + debug: false + # Secrets generated by the panel for the wings client + uuid: #your-uuid-here + token_id: #your-token-id-here + token: #your-token-here + api: + host: 0.0.0.0 # Address to bind the wings daemon to + port: 8080 # Port to bind the wings daemon to + # SSL Settings, including certificate path and key. Defaults to the path used by certbot/Let's Encrypt + ssl: + enabled: true + cert: "/etc/letsencrypt/live/{{ ansible_fqdn }}/fullchain.pem" + key: "/etc/letsencrypt/live/{{ ansible_fqdn }}/privkey.pem" + upload_limit: 100 # File browser upload limit in MB + remote: https://127.0.0.1:443 # The address of the Panel + system: + data: /var/lib/pterodactyl/volumes # Path under which to save server data + sftp: + bind_port: 2022 # Port on which sftp should listen on + allowed_mounts: [] + # add additional configuration options here, if required ``` + +## Example Playbooks + +```yaml # Performs a basic wings installation # such as ansible-vault or via vars-prompt - hosts: all @@ -66,9 +89,23 @@ Prefix for all variables: `pterodactyl_wings_` - role: maxhoesel.pterodactyl.pterodactyl_wings become: yes vars: - pterodactyl_wings_remote: https://mypanel.example.com:443 - # Get these values from your panel - pterodactyl_wings_uuid: 12544f88-cfbf-40b6-9432-a2bc14312112 - pterodactyl_wings_token_id: m9TVwtaw6FQQZt8H - pterodactyl_wings_token: dPigfaWa4I4xcY3o5sM3Hi3ST3duxHqCqu30fc3eO44lPj7msGY6R14YKCR6QZJ2 + pterodactyl_wings_config: + debug: false + uuid: 12544f88-cfbf-40b6-9432-a2bc14312112 + token_id: m9TVwtaw6FQQZt8H + token: dPigfaWa4I4xcY3o5sM3Hi3ST3duxHqCqu30fc3eO44lPj7msGY6R14YKCR6QZJ2 + api: + host: 0.0.0.0 + port: 8080 + ssl: + enabled: true + cert: "/etc/letsencrypt/live/{{ ansible_fqdn }}/fullchain.pem" + key: "/etc/letsencrypt/live/{{ ansible_fqdn }}/privkey.pem" + upload_limit: 100 + remote: https://mypanel.example.com:443 + system: + data: /var/lib/pterodactyl/volumes + sftp: + bind_port: 2022 + allowed_mounts: [] ``` diff --git a/roles/pterodactyl_wings/defaults/main.yml b/roles/pterodactyl_wings/defaults/main.yml index 3fd85a0..2602967 100644 --- a/roles/pterodactyl_wings/defaults/main.yml +++ b/roles/pterodactyl_wings/defaults/main.yml @@ -3,20 +3,27 @@ pterodactyl_wings_version: latest pterodactyl_wings_config_dir: /etc/pterodactyl -pterodactyl_wings_remote: "https://127.0.0.1:443" -#pterodactyl_wings_uuid: -#pterodactyl_wings_token_id: -#pterodactyl_wings_token: - -pterodactyl_wings_port: 8080 -pterodactyl_wings_ssl_cert: "/etc/letsencrypt/live/{{ ansible_fqdn }}/fullchain.pem" -pterodactyl_wings_ssl_key: "/etc/letsencrypt/live/{{ ansible_fqdn }}/privkey.pem" - -pterodactyl_wings_data_dir: /var/lib/pterodactyl/volumes -pterodactyl_wings_upload_limit: 100 - -pterodactyl_wings_sftp_port: 2022 -pterodactyl_wings_allowed_mounts: [] +pterodactyl_wings_config: + debug: false + # Secrets generated by the panel for the wings client + uuid: #your-uuid-here + token_id: #your-token-id-here + token: #your-token-here + api: + host: 0.0.0.0 # Address to bind the wings daemon to + port: 8080 # Port to bind the wings daemon to + # SSL Settings, including certificate path and key. Defaults to the path used by certbot/Let's Encrypt + ssl: + enabled: true + cert: "/etc/letsencrypt/live/{{ ansible_fqdn }}/fullchain.pem" + key: "/etc/letsencrypt/live/{{ ansible_fqdn }}/privkey.pem" + upload_limit: 100 # File browser upload limit in MB + remote: https://127.0.0.1:443 # The address of the Panel + system: + data: /var/lib/pterodactyl/volumes # Path under which to save server data + sftp: + bind_port: 2022 # Port on which sftp should listen on + allowed_mounts: [] pterodactyl_wings_docker_install: true pterodactyl_wings_docker_source: stable diff --git a/roles/pterodactyl_wings/molecule/default/converge.yml b/roles/pterodactyl_wings/molecule/default/converge.yml index 523ab91..b9e0c2b 100644 --- a/roles/pterodactyl_wings/molecule/default/converge.yml +++ b/roles/pterodactyl_wings/molecule/default/converge.yml @@ -7,9 +7,22 @@ name: "pterodactyl_wings" vars: pterodactyl_wings_docker_source: stable - pterodactyl_wings_cert: /etc/ssl/private/pterodactyl.crt - pterodactyl_wings_key: /etc/ssl/private/pterodactyl.key - # Placeholder values - pterodactyl_wings_token: dPigfaWa4I4xcY3o5sM3Hi3ST3duxHqCqu30fc3eO44lPj7msGY6R14YKCR6QZJ2 - pterodactyl_wings_token_id: m9TVwtaw6FQQZt8H - pterodactyl_wings_uuid: 12544f88-cfbf-40b6-9432-a2bc14312112 + pterodactyl_wings_config: + debug: false + uuid: 12544f88-cfbf-40b6-9432-a2bc14312112 + token_id: m9TVwtaw6FQQZt8H + token: dPigfaWa4I4xcY3o5sM3Hi3ST3duxHqCqu30fc3eO44lPj7msGY6R14YKCR6QZJ2 + api: + host: 0.0.0.0 + port: 8080 + ssl: + enabled: true + cert: "/etc/ssl/private/pterodactyl.crt" + key: "/etc/ssl/private/pterodactyl.key" + upload_limit: 100 + remote: https://mypanel.example.com:443 + system: + data: /var/lib/pterodactyl/volumes + sftp: + bind_port: 2022 + allowed_mounts: [] diff --git a/roles/pterodactyl_wings/tasks/main.yml b/roles/pterodactyl_wings/tasks/main.yml index 46bad70..1912323 100644 --- a/roles/pterodactyl_wings/tasks/main.yml +++ b/roles/pterodactyl_wings/tasks/main.yml @@ -30,27 +30,6 @@ mode: "755" notify: restart wings -- name: Generate wings configuration - set_fact: - pterodactyl_wings_config: - debug: false - uuid: "{{ pterodactyl_wings_uuid }}" - token_id: "{{ pterodactyl_wings_token_id }}" - token: "{{ pterodactyl_wings_token }}" - api: - host: 0.0.0.0 - port: "{{ pterodactyl_wings_port }}" - ssl: - enabled: true - cert: "{{ pterodactyl_wings_ssl_cert }}" - key: "{{ pterodactyl_wings_ssl_key }}" - upload_limit: "{{ pterodactyl_wings_upload_limit }}" - system: - data: "{{ pterodactyl_wings_data_dir }}" - sftp: - bind_port: "{{ pterodactyl_wings_sftp_port }}" - allowed_mounts: "{{ pterodactyl_wings_allowed_mounts }}" - remote: "{{ pterodactyl_wings_remote }}" - name: Look for existing config file stat: path: "{{ pterodactyl_wings_config_dir }}/config.yml" @@ -64,7 +43,7 @@ check_mode: no - name: Merge existing configuration new config set_fact: - pterodactyl_wings_config: "{{ _pterodactyl_wings_config_current.stdout|from_yaml | combine(pterodactyl_wings_config, recursive=True, list_merge='keep') }}" + pterodactyl_wings_config: "{{ _pterodactyl_wings_config_current.stdout|from_yaml | combine(pterodactyl_wings_config, recursive=True) }}" when: _pterodactyl_wings_config_file.stat.exists - name: Wings config file is installed