summaryrefslogtreecommitdiff
path: root/ansible/roles/http/tasks/main.yml
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-08-11 21:44:26 +0100
committerJoe Carstairs <me@joeac.net>2026-08-11 21:44:26 +0100
commit74b9185a404ace70030e57e0ad493478227a5eac (patch)
tree5f32d05d842ef726412ead2932d9157fd2f1df58 /ansible/roles/http/tasks/main.yml
parent4e73a59d76e8c4949908e766657f5d634d39fb67 (diff)
ansible installs joeac.net website
Diffstat (limited to 'ansible/roles/http/tasks/main.yml')
-rw-r--r--ansible/roles/http/tasks/main.yml107
1 files changed, 107 insertions, 0 deletions
diff --git a/ansible/roles/http/tasks/main.yml b/ansible/roles/http/tasks/main.yml
new file mode 100644
index 0000000..05fce26
--- /dev/null
+++ b/ansible/roles/http/tasks/main.yml
@@ -0,0 +1,107 @@
+- name: Install composer, make, nginx, PHP, PHP-FPM, and PHP-PDO (SQLITE)
+ community.general.apk:
+ name:
+ - composer
+ - make
+ - nginx
+ - php85-fpm
+ - php85-pdo
+ - php85-pdo_sqlite
+
+- name: Start nginx service and configure to restart on boot
+ ansible.builtin.service:
+ name: nginx
+ enabled: true
+ state: started
+
+- name: Start PHP-FPM service and configure to restart on boot
+ ansible.builtin.service:
+ name: php-fpm85
+ enabled: true
+ state: started
+
+- name: Remove default PHP-FPM pool
+ register: default_phpfpm_pool
+ ansible.builtin.file:
+ path: /etc/php85/php-fpm.d/www.conf
+ state: absent
+
+- name: Install PHP-FPM pool for joeac.net website
+ register: joeacnet_phpfpm_pool
+ ansible.builtin.template:
+ src: php-fpm/joeac.net.conf
+ dest: /etc/php85/php-fpm.d/joeac.net.conf
+ owner: nginx
+ group: nginx
+ mode: "600"
+
+- name: Restart PHP-FPM service if config changed
+ when: default_phpfpm_pool is changed or joeacnet_phpfpm_pool is changed
+ ansible.builtin.service:
+ name: php-fpm85
+ state: restarted
+
+- name: Remove default nginx site config
+ register: default_nginx_site_config
+ ansible.builtin.file:
+ path: /etc/nginx/http.d/default.conf
+ state: absent
+
+- name: Install joeac.net nginx site config
+ register: joeacnet_nginx_site_config
+ ansible.builtin.template:
+ src: nginx/joeac.net.conf
+ dest: /etc/nginx/http.d/joeac.net.conf
+
+- name: Restart nginx service if config changed
+ when: default_nginx_site_config is changed or joeacnet_nginx_site_config is changed
+ ansible.builtin.service:
+ name: nginx
+ state: restarted
+
+- name: Checkout joeac.net source code
+ ansible.builtin.git:
+ repo: https://git.joeac.net/joeac/joeac.net.git
+ dest: "{{ joeacnet_src_dir }}"
+ depth: 1
+ version: main
+
+- name: Build joeac.net website
+ community.general.make:
+ chdir: "{{ joeacnet_src_dir }}/http"
+
+- name: Create joeac.net public directory
+ ansible.builtin.file:
+ path: "{{ http_files_dir }}"
+ state: directory
+
+- name: Configure website PHP
+ ansible.builtin.template:
+ src: config.ini
+ dest: "{{ http_files_dir }}/config.ini"
+
+- name: Symlink vendor to public directory
+ ansible.builtin.file:
+ src: "{{ joeacnet_src_dir }}/http/vendor"
+ dest: "{{ http_files_dir }}/vendor"
+ state: link
+
+- name: Symlink php to public directory
+ ansible.builtin.file:
+ src: "{{ joeacnet_src_dir }}/http/php"
+ dest: "{{ http_files_dir }}/php"
+ state: link
+
+- name: Symlink html to public directory
+ ansible.builtin.file:
+ src: "{{ joeacnet_src_dir }}/http/out"
+ dest: "{{ http_files_dir }}/html"
+ state: link
+
+- name: Touch database and grant rw permissions to nginx user
+ ansible.builtin.file:
+ path: "{{ http_files_dir }}/{{ http_database_filename }}"
+ state: touch
+ owner: nginx
+ group: nginx
+ mode: "600"