You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
183 lines
4.7 KiB
YAML
183 lines
4.7 KiB
YAML
---
|
|
|
|
- name: Add domain to host file
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/hosts
|
|
search_string: '127.0.0.1 {{ pterodactyl_domain }}'
|
|
line: '127.0.0.1 {{ pterodactyl_domain }}'
|
|
state: present
|
|
|
|
- name: Setup mariadb
|
|
include_role:
|
|
name: mariadb
|
|
vars:
|
|
mysql_databases:
|
|
- name: panel
|
|
mysql_users:
|
|
- name: pterodactyl
|
|
password: "{{ pterodactyl_mysql_user_pwd }}"
|
|
priv: "panel.*:ALL,GRANT"
|
|
|
|
- name: Install dependencies
|
|
apt:
|
|
pkg:
|
|
- curl
|
|
- tar
|
|
- unzip
|
|
- git
|
|
- redis-server
|
|
- nginx
|
|
- php
|
|
- php-cli
|
|
- php-gd
|
|
- php-mysql
|
|
- php-bcmath
|
|
- php-xml
|
|
- php-dom
|
|
- php-curl
|
|
- php-zip
|
|
- php-fpm
|
|
- composer
|
|
- certbot
|
|
- python3-certbot-nginx
|
|
update_cache: yes
|
|
state: present
|
|
|
|
- name: Enable and start redis-server
|
|
systemd:
|
|
name: redis-server.service
|
|
state: started
|
|
enabled: yes
|
|
|
|
- name: Download the panel
|
|
get_url:
|
|
url: "https://github.com/pterodactyl/panel/releases/latest/download/panel.tar.gz"
|
|
checksum: "sha256:https://github.com/pterodactyl/panel/releases/latest/download/checksum.txt"
|
|
dest: /var/tmp/panel.tar.gz
|
|
register: register_download
|
|
|
|
- name: Ensure panel directory exists
|
|
file:
|
|
path: /var/www/pterodactyl/
|
|
state: directory
|
|
register: register_directory
|
|
|
|
- name: Enter maintenance mode if updating
|
|
command: php artisan down
|
|
args:
|
|
chdir: /var/www/pterodactyl/
|
|
when: register_download.changed and not register_directory.changed
|
|
|
|
- name: Install the panel
|
|
unarchive:
|
|
src: /var/tmp/panel.tar.gz
|
|
remote_src: yes
|
|
dest: /var/www/pterodactyl/
|
|
owner: www-data
|
|
group: www-data
|
|
|
|
- name: Install panel dependencies
|
|
community.general.composer:
|
|
command: install
|
|
working_dir: /var/www/pterodactyl/
|
|
optimize_autoloader: yes
|
|
no_dev: yes
|
|
|
|
- name: Configure the panel
|
|
template:
|
|
src: env.j2
|
|
dest: /var/www/pterodactyl/.env
|
|
owner: www-data
|
|
group: www-data
|
|
|
|
- name: Clear view cache after update
|
|
command: php artisan view:clear
|
|
args:
|
|
chdir: /var/www/pterodactyl/
|
|
when: register_download.changed and not register_directory.changed
|
|
|
|
- name: Clear config cache after update
|
|
command: php artisan config:clear
|
|
args:
|
|
chdir: /var/www/pterodactyl/
|
|
when: register_download.changed and not register_directory.changed
|
|
|
|
- name: Migrate database
|
|
command: php artisan migrate --seed --force
|
|
args:
|
|
chdir: /var/www/pterodactyl/
|
|
when: register_download.changed
|
|
|
|
- name: Add pterodactyl panel users
|
|
command: php artisan p:user:make -n --no-ansi --email "{{ item.email }}" --username "{{ item.username }}" --name-first "{{ item.firstname }}" --name-last "{{ item.lastname }}" --password "{{ item.password }}" --admin {{ 1 if item.admin else 0 | default(0) }}
|
|
args:
|
|
chdir: /var/www/pterodactyl/
|
|
loop: "{{ pterodactyl_users }}"
|
|
register: register_adduser
|
|
changed_when: '"been taken" not in register_adduser.stdout'
|
|
failed_when: 'register_adduser.rc != 0 and "been taken" not in register_adduser.stdout'
|
|
no_log: "{{ enable_no_log | default('true') }}"
|
|
|
|
|
|
- name: Restart queue worker after update
|
|
command: php artisan queue:restart
|
|
args:
|
|
chdir: /var/www/pterodactyl/
|
|
when: register_download.changed and not register_directory.changed
|
|
|
|
- name: Exit maintenance mode after update
|
|
command: php artisan up
|
|
args:
|
|
chdir: /var/www/pterodactyl/
|
|
when: register_download.changed and not register_directory.changed
|
|
|
|
- name: Create cron job for panel
|
|
cron:
|
|
name: "pterodactyl panel"
|
|
job: "/usr/bin/php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1"
|
|
month: "*"
|
|
day: "*"
|
|
hour: "*"
|
|
minute: "*"
|
|
|
|
- name: Create pterodactyl queue worker service
|
|
template:
|
|
src: pteroq.j2
|
|
dest: /etc/systemd/system/pteroq.service
|
|
|
|
- name: Enable and start pterodactyl queue worker service
|
|
systemd:
|
|
name: pteroq.service
|
|
state: started
|
|
enabled: yes
|
|
|
|
- name: Enable and start nginx
|
|
systemd:
|
|
name: nginx
|
|
state: started
|
|
enabled: yes
|
|
|
|
- name: Generate ssl certificate with certbot
|
|
command: certbot certonly -n --nginx --email "{{ pterodactyl_email }}" --agree-tos -d "{{ pterodactyl_domain }}"
|
|
args:
|
|
creates: "/etc/letsencrypt/live/{{ pterodactyl_domain }}/fullchain.pem"
|
|
|
|
- name: Remove default nginx config
|
|
file:
|
|
path: /etc/nginx/sites-enabled/default
|
|
state: absent
|
|
|
|
- name: Add pterodactyl nginx config
|
|
template:
|
|
src: nginx.j2
|
|
dest: /etc/nginx/sites-available/pterodactyl.conf
|
|
notify: Restart nginx
|
|
|
|
- name: Enable pterodactyl nginx config
|
|
file:
|
|
src: "/etc/nginx/sites-available/pterodactyl.conf"
|
|
path: "/etc/nginx/sites-enabled/pterodactyl.conf"
|
|
state: link
|
|
notify: Restart nginx
|
|
|