Compare commits

...

2 Commits

Author SHA1 Message Date
VC
f6ad6af695 🚨: fix linting errors on web_hostname_block vars
All checks were successful
ansible-lint / lint-everything (push) Successful in 1m24s
2025-04-04 20:50:39 +02:00
VC
bcc1551244 : move phpbb to app dir
All checks were successful
ansible-lint / lint-everything (push) Successful in 1m27s
2025-04-04 20:46:58 +02:00
14 changed files with 276 additions and 2 deletions

1
.ansible-lint-ignore Normal file
View File

@@ -0,0 +1 @@
roles/nsd/tasks/zones.yml no-tabs

View File

@@ -6,6 +6,7 @@ web_hostname:
- host: www.nintendojo.fr
- host: wwwdev.nintendojo.fr
- host: forum.nintendojo.fr
type: phpbb
- host: nintendojofr.com
- host: www.nintendojofr.com
type: retrodojo
@@ -19,6 +20,16 @@ mariadb_root_pass: !vault |
3437653064323138310a663363373736623931336432376466316666616234356133383263373136
31343534663063663134306464306234366430323762656165653930333134326231
phpbb_maria_database: "dojo_forum"
phpbb_maria_user: "adm_forum"
phpbb_maria_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
65306237643235363962653566336537303632386466646462656234333836396630306438336632
3334663566303963646135313265643235623538633463650a663637386436306538616266626232
36373332396338326437663832383237623836643137323432323435333231633363386432303830
3465306161666563630a356462363561653431303438653935346564343861303962363030323633
3632
wordpress_maria_database: "dojo_wp"
wordpress_maria_user: "adm_wp"
wordpress_maria_password: !vault |

View File

@@ -23,5 +23,9 @@
hosts: web2
diff: true
roles:
- wordpress
- retrodojo
- role: wordpress
tags: [never, wordpress]
- role: phpbb
tags: [never, phpbb]
- role: retrodojo
tags: [never, retrodojo]

View File

@@ -0,0 +1,7 @@
---
name: DojoPeertube
host: p.nintendojo.fr
example: https://p.nintendojo.fr/videos/embed/19bc46e8-7640-4417-86a1-03aa2b439508
extract: "!//p.nintendojo.fr/videos/embed/(?'id'[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12})!"
iframe:
src: "https://p.nintendojo.fr/videos/embed/{@id}"

View File

@@ -0,0 +1,18 @@
---
name: "Mastodon"
host: m.nintendojo.fr
example: https://mastodon.social/@HackerNewsBot/100181134752056592
extract: "!//(?'host'[-.\\w]+)/@(?'name'\\w+)/(?'id'\\d+)!"
oembed:
endpoint: https://m.nintendojo.fr/api/oembed
scheme: https://m.nintendojo.fr/@{@name}/{@id}
scrape:
- extract: "!\"url\":\"https://(?'host'[-.\\w]+)/@(?'name'\\w+)/(?'id'\\d+)\"!"
- match: "!^(?'origin'https://[^/]+)/@\\w+@[-.\\w]+/(?'id'\\d+)!"
- url: "{@origin}/api/v1/statuses/{@id}"
iframe:
data-s9e-livepreview-ignore-attrs: "style"
onload: "let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+'px';this.contentWindow.postMessage('s9e:init','*',[c.port2])"
width: "550"
height: "300"
src: https://s9e.github.io/iframe/2/mastodon.min.html#<xsl:value-of select="@name"/><xsl:if test="@host and@host!='mastodon.social'">@<xsl:value-of select="@host"/></xsl:if>/<xsl:value-of select="@id"/>

10
roles/phpbb/tasks/db.yml Normal file
View File

@@ -0,0 +1,10 @@
---
- name: Create phpbb db user
community.mysql.mysql_user:
login_unix_socket: "/var/run/mysqld/mysqld.sock"
login_user: root
login_password: "{{ mariadb_root_pass }}"
name: "{{ phpbb_maria_user }}"
password: "{{ phpbb_maria_password }}"
priv: "{{ phpbb_maria_database }}.*:ALL"

View File

@@ -0,0 +1,24 @@
---
- name: Init db
ansible.builtin.include_tasks: db.yml
- name: Install phpbb
ansible.builtin.include_tasks: phpbb.yml
- name: Install phpbbs styles
ansible.builtin.include_tasks: phpbb_styles.yml
loop: "{{ phpbb_styles }}"
- name: Install phpbbs languages
ansible.builtin.include_tasks: phpbb_languages.yml
loop: "{{ phpbb_languages }}"
- name: Install phpbbs extensions
ansible.builtin.include_tasks: phpbb_exts.yml
loop: "{{ phpbb_exts }}"
loop_control:
loop_var: ext
- name: Custom part
ansible.builtin.include_tasks: phpbb_customs.yml

View File

@@ -0,0 +1,77 @@
---
- name: Remove phpbb previous version
ansible.builtin.file:
state: absent
dest: "{{ phpbb_app_home }}"
## Handle app data
- name: Create app home
ansible.builtin.file:
state: directory
dest: "{{ phpbb_app_home }}"
owner: root
group: www-data
mode: "0o750"
- name: Install phpbb application
ansible.builtin.unarchive:
remote_src: true
src: "{{ phpbb_url }}"
dest: "{{ phpbb_app_home }}"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']
exclude: "{{ phpbb_userdata_app_dirs | map('regex_replace', '^^', 'phpBB' ~ phpbb_major_version ~ '/') }}"
- name: Check writable dirs
ansible.builtin.file:
state: directory
dest: "{{ phpbb_app_home }}/{{ item }}"
owner: www-data
group: www-data
mode: "a-rwx,u+rwX,g+rX"
recurse: true
loop: "{{ phpbb_writable_app_dirs }}"
## Handle user data
- name: Create data home
ansible.builtin.file:
state: directory
path: "{{ phpbb_data_home }}"
owner: www-data
group: www-data
mode: "a-rwx,u+rwX,g+rX"
- name: Get data dir
ansible.builtin.stat:
path: "{{ phpbb_data_home }}/{{ phpbb_userdata_app_dirs[0] }}"
register: _phpbb_userdata_dir_stat
- name: Install phpbb data dir
ansible.builtin.unarchive:
remote_src: true
src: "{{ phpbb_url }}"
dest: "{{ phpbb_data_home }}"
owner: www-data
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']
include: "{{ phpbb_userdata_app_dirs | map('regex_replace', '^^', 'phpBB' ~ phpbb_major_version ~ '/') }}"
when: not _phpbb_userdata_dir_stat.stat.exists
- name: Link phpbb userdata dirs
ansible.builtin.file:
state: link
src: "{{ phpbb_data_home }}/{{ item }}"
dest: "{{ phpbb_app_home }}/{{ item }}"
loop: "{{ phpbb_userdata_app_dirs }}"
- name: Put phpbb config file
ansible.builtin.template:
src: config.php.j2
dest: "{{ phpbb_app_home }}/config.php"
owner: www-data
group: www-data
mode: "0o640"

View File

@@ -0,0 +1,7 @@
---
- name: Replace logo
ansible.builtin.lineinfile:
path: "{{ phpbb_app_home }}/styles/prosilver/theme/colours.css"
search_string: "background-image: url(\"./images/site_logo.svg\");"
line: " background-image: url(\"./images/ndfr_casual.png\");"

View File

@@ -0,0 +1,29 @@
---
- name: Create phpbb ext path
ansible.builtin.file:
state: directory
dest: "{{ phpbb_app_home }}/ext/{{ ext.path }}"
owner: root
group: www-data
mode: "0o750"
- name: Extract phpbb ext
ansible.builtin.unarchive:
remote_src: true
src: "{{ ext.url | replace('%VERSION%', ext.version) }}"
dest: "{{ phpbb_app_home }}/ext/{{ ext.path }}"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']
- name: Put extra files
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ phpbb_app_home }}/ext/{{ ext.path }}/{{ item.dest }}"
owner: root
group: www-data
mode: "0o640"
loop: "{{ ext.extra_files }}"
when: ext.extra_files is defined

View File

@@ -0,0 +1,11 @@
---
- name: Extract phpbb language
ansible.builtin.unarchive:
remote_src: true
src: "{{ item.url | replace('%VERSION%', item.version) }}"
dest: "{{ phpbb_app_home }}"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']

View File

@@ -0,0 +1,11 @@
---
- name: Extract style
ansible.builtin.unarchive:
remote_src: true
src: "{{ item.url | replace('%VERSION%', item.version) }}"
dest: "{{ phpbb_app_home }}/styles/"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']

View File

@@ -0,0 +1,19 @@
<?php
// phpBB 3.0.x auto-generated configuration file
// Do not change anything in this file!
$dbms = 'mysqli';
$dbhost = 'localhost';
$dbport = '';
$dbname = '{{ phpbb_maria_database }}';
$dbuser = '{{ phpbb_maria_user }}';
$dbpasswd = '{{ phpbb_maria_password }}';
$table_prefix = 'phpbb_';
$acm_type = 'file';
$load_extensions = '';
libxml_disable_entity_loader(false);
@define('PHPBB_INSTALLED', true);
// @define('DEBUG', true);
// @define('DEBUG_EXTRA', true);
?>

45
roles/phpbb/vars/main.yml Normal file
View File

@@ -0,0 +1,45 @@
---
phpbb_version: "3.3.15"
phpbb_minor_version: "{{ phpbb_version | regex_replace('^([0-9])\\.([0-9]*).*', '\\1.\\2') }}"
phpbb_major_version: "{{ phpbb_version | regex_replace('^([0-9])\\..*', '\\1') }}"
phpbb_url: "https://download.phpbb.com/pub/release/{{ phpbb_minor_version }}/{{ phpbb_version }}/phpBB-{{ phpbb_version }}.tar.bz2"
phpbb_access_url: "{{ web_hostname | selectattr('type', 'defined') | selectattr('type', '==', 'phpbb') | map(attribute='host') | first }}"
# Access path
phpbb_app_home: "/var/www/{{ phpbb_access_url }}"
phpbb_data_home: "/srv/www-data/{{ phpbb_access_url }}"
phpbb_writable_app_dirs:
- cache
- store
phpbb_userdata_app_dirs:
- files
- images
phpbb_styles:
- name: black
version: 3.3.12
url: "https://github.com/cabot/black/archive/refs/tags/v%VERSION%.tar.gz"
phpbb_languages:
- name: fr
version: 4.15.0
url: "https://github.com/qiaeru/phpbb-language-fr/archive/refs/tags/v%VERSION%.tar.gz"
phpbb_exts:
- name: externallink
path: martin/externallinkinnewwindow
version: 1.2.0
url: "https://github.com/Mar-tin-G/ExternalLinkInNewWindow/archive/refs/tags/%VERSION%.tar.gz"
- name: mediaembed
path: phpbb/mediaembed
version: 2.0.2
url: "https://github.com/phpbb-extensions/mediaembed/archive/refs/tags/%VERSION%.tar.gz"
extra_files:
- src: files/mastodon.yml
dest: collection/sites/mastodon.yml
- src: files/dojopeertube.yml
dest: collection/sites/dojopeertube.yml