|
4 | 4 | name: "{{ item }}"
|
5 | 5 | state: latest
|
6 | 6 | loop:
|
| 7 | + - composer |
7 | 8 | - libapache2-mpm-itk
|
8 |
| - - libapache2-mod-php |
| 9 | + - php-fpm |
9 | 10 | - php-sqlite3
|
| 11 | + - php-xml |
10 | 12 | - python3-certbot-apache
|
11 | 13 |
|
12 | 14 | - name: Create virtual host for the mf website
|
|
15 | 17 | dest: /etc/apache2/sites-available/mobileforces.conf
|
16 | 18 | mode: "644"
|
17 | 19 |
|
18 |
| -- name: Ensure website directories exist |
19 |
| - ansible.builtin.file: |
20 |
| - path: "{{ website_path }}/{{ item }}" |
21 |
| - state: directory |
22 |
| - owner: "{{ server_user }}" |
23 |
| - group: "{{ server_user }}" |
24 |
| - mode: "755" |
25 |
| - loop: |
26 |
| - - "" |
27 |
| - - admin |
28 |
| - - includes/ |
29 |
| - - includes/php/ |
30 |
| - - includes/css |
31 |
| - - includes/images |
32 |
| - - includes/js |
33 |
| - |
34 |
| -- name: Copy static files into the webserver folder |
| 20 | +- name: Copy website files |
35 | 21 | ansible.builtin.copy:
|
36 |
| - src: "templates/webserver/website/{{ item[0] }}" |
37 |
| - dest: "{{ website_path }}/{{ item[1] }}" |
| 22 | + src: "templates/webserver/website/{{ item }}" |
| 23 | + dest: "{{ website_path }}/" |
38 | 24 | owner: "{{ server_user }}"
|
39 | 25 | group: "{{ server_user }}"
|
40 | 26 | mode: "644"
|
41 | 27 | loop:
|
42 |
| - - [index.php, index.php] |
43 |
| - - [stats.php, stats.php] |
44 |
| - - [donate_notify.php, donate_notify.php] |
45 |
| - - [favicon.ico, favicon.ico] |
46 |
| - - [admin/, admin/] |
47 |
| - - [includes/css/, includes/css/] |
48 |
| - - [includes/images/, includes/images/] |
49 |
| - - [includes/js/, includes/js/] |
50 |
| - - [includes/php/body.php, includes/php/body.php] |
51 |
| - - [includes/php/db.php, includes/php/db.php] |
| 28 | + - bin |
| 29 | + - config |
| 30 | + - migrations |
| 31 | + - public |
| 32 | + - src |
| 33 | + - templates |
| 34 | + - .env |
| 35 | + - composer.json |
| 36 | + - composer.lock |
| 37 | + - symfony.lock |
| 38 | + - sync_paypal.php |
52 | 39 |
|
53 |
| -- name: Copy dynamic website files |
54 |
| - ansible.builtin.template: |
55 |
| - src: "templates/webserver/website/{{ item[0] }}" |
56 |
| - dest: "{{ website_path }}/{{ item[1] }}" |
57 |
| - owner: "{{ server_user }}" |
58 |
| - group: "{{ server_user }}" |
59 |
| - mode: "644" |
60 |
| - loop: |
61 |
| - - [includes/php/kofi.j2, includes/php/kofi.php] |
62 |
| - - [includes/php/cookies.j2, includes/php/cookies.php] |
63 |
| - - [../kofi_sync_paypal.j2, ../kofi_sync_paypal.php] |
| 40 | +- name: Install website |
| 41 | + ansible.builtin.shell: | |
| 42 | + cd "{{ website_path }}" && |
| 43 | + export APP_ENV=prod APP_DEBUG=0 && |
| 44 | + composer install --no-dev --optimize-autoloader && |
| 45 | + composer dump-env prod && rm -f .env && |
| 46 | + ADMIN_PASSWORD="{{ AdminPassword }}" php bin/console doctrine:migrations:migrate -n |
| 47 | + become_user: "{{ server_user }}" |
64 | 48 |
|
65 |
| -- name: Remove previous verisons of elFinder |
66 |
| - ansible.builtin.shell: "rm -rf {{ website_path }}/admin/elFinder-*" |
| 49 | +- name: Enable the mobileforces website |
| 50 | + ansible.builtin.shell: |
| 51 | + cmd: a2enmod proxy_fcgi speling mpm_event && a2dismod mpm_prefork && a2ensite mobileforces.conf |
| 52 | + creates: /etc/apache2/sites-enabled/mobileforces.conf |
67 | 53 |
|
68 |
| -- name: Extract elFinder zip onto server |
69 |
| - ansible.builtin.unarchive: |
70 |
| - src: "{{ item }}" |
71 |
| - dest: "{{ website_path }}/admin/" |
72 |
| - owner: "{{ server_user }}" |
73 |
| - group: "{{ server_user }}" |
74 |
| - mode: "755" |
75 |
| - with_fileglob: |
76 |
| - - "templates/webserver/elFinder-*.zip" |
| 54 | +- name: Request LE certificate |
| 55 | + ansible.builtin.command: |
| 56 | + cmd: "certbot --apache -n --email {{ ServerAdmin }} --agree-tos --no-redirect -d {{ ServerName }}" |
| 57 | + creates: /etc/apache2/sites-enabled/mobileforces-le-ssl.conf |
77 | 58 |
|
78 |
| -- name: Install & configure elFinder for MF |
79 |
| - ansible.builtin.shell: cd "{{ website_path }}"/admin/elFinder-*/php && mv connector.minimal.php-dist connector.minimal.php && sed -i "s/uploadAllow' => array(/uploadAllow' => array('application\/octet-stream', 'text\/html', /g" connector.minimal.php |
| 59 | +- name: Get PHP version |
| 60 | + ansible.builtin.shell: readlink -f /usr/bin/php | grep -oP '/usr/bin/php\K.+' |
| 61 | + register: php |
80 | 62 |
|
81 |
| -- name: Create symbolic links for elFinder |
82 |
| - ansible.builtin.shell: "cd {{ website_path }}/admin/elFinder-*/files && ln -f -s {{ item }} ." |
| 63 | +- name: Configure PHP fpm pool |
| 64 | + ansible.builtin.replace: |
| 65 | + path: "/etc/php/{{ php.stdout }}/fpm/pool.d/www.conf" |
| 66 | + regexp: "{{ item[0] }}" |
| 67 | + replace: "{{ item[1] }}" |
83 | 68 | loop:
|
84 |
| - - "{{ game_path }}" |
85 |
| - - "{{ website_path }}" |
| 69 | + - [= www-data, "= {{ server_user }}"] |
| 70 | + - [/run/php/php8.3-fpm.sock, /run/php/www.sock] |
86 | 71 |
|
87 |
| -- name: Request LE certificate |
88 |
| - ansible.builtin.shell: "certbot --apache -n --email {{ ServerAdmin }} --agree-tos --no-redirect -d {{ ServerName }}" |
| 72 | +- name: Reload the apache and PHP fpm services |
| 73 | + ansible.builtin.service: |
| 74 | + name: "{{ item }}" |
| 75 | + state: reloaded |
| 76 | + loop: |
| 77 | + - apache2 |
| 78 | + - "php{{ php.stdout }}-fpm" |
89 | 79 |
|
90 | 80 | - name: Allow the website to restart game services
|
91 | 81 | ansible.builtin.template:
|
92 | 82 | src: templates/webserver/scripts/01-mobileforces.j2
|
93 |
| - dest: /etc/polkit-1/rules.d/01-mobileforces |
| 83 | + dest: /etc/polkit-1/rules.d/01-mobileforces.rules |
94 | 84 | owner: root
|
95 | 85 | group: root
|
96 |
| - mode: "440" |
97 |
| - |
98 |
| -- name: Enable the mobileforces website |
99 |
| - ansible.builtin.shell: a2enmod speling && a2ensite mobileforces.conf |
100 |
| - notify: Reload apache |
| 86 | + mode: "644" |
101 | 87 |
|
102 | 88 | - name: Create cron job for syncing paypal
|
103 | 89 | ansible.builtin.cron:
|
104 | 90 | name: Gets transfer fees for donations
|
105 | 91 | minute: 0
|
106 | 92 | hour: 4
|
107 | 93 | user: "{{ server_user }}"
|
108 |
| - job: "php {{ install_path }}/kofi_sync_paypal.php" |
| 94 | + job: "PAYPAL_CLIENTID={{ paypal_clientid }} PAYPAL_SECRETKEY={{ paypal_secretkey }} php {{ website_path }}/sync_paypal.php" |
109 | 95 | cron_file: mobileforces-kofi_sync_paypal
|
| 96 | + |
| 97 | +- name: Create cron job for cleaning the site |
| 98 | + ansible.builtin.cron: |
| 99 | + name: Clean the site |
| 100 | + minute: 30 |
| 101 | + hour: 4 |
| 102 | + weekday: 0 |
| 103 | + user: "{{ server_user }}" |
| 104 | + job: "cd {{ website_path }} && rm -rf donation_log.txt var/cache var/log && php bin/console cache:warmup" |
| 105 | + cron_file: mobileforces-clean |
0 commit comments