summaryrefslogtreecommitdiff
path: root/roles/http/tasks/main.yml
blob: 9d2ae221f7b7b7c0f18306918e6d58639cc0754c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
- name: Install composer, make, PHP, PHP-FPM, and PHP-PDO (SQLITE)
  community.general.apk:
    name:
      - composer
      - make
      - php85-fpm
      - php85-pdo
      - php85-pdo_sqlite

- 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: 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: joeacnet_nginx_site_config is changed
  ansible.builtin.service:
    name: nginx
    state: restarted

- name: Checkout joeac.net source code
  ansible.builtin.git:
    repo: git://git.joeac.net/joeac.net.git
    dest: "{{ src_dir }}/joeac.net"
    depth: 1
    version: main

- name: Build joeac.net website
  community.general.make:
    chdir: "{{ src_dir }}/joeac.net/http"

- name: Create joeac.net public directory
  ansible.builtin.file:
    path: "{{ http_files_dir }}"
    state: directory
    owner: nginx
    group: nginx

- name: Configure website PHP with config.ini
  ansible.builtin.template:
    src: config.ini
    dest: "{{ src_dir }}/joeac.net/http/config.ini"

- name: Symlink config.ini
  ansible.builtin.file:
    src: "{{ src_dir }}/joeac.net/http/config.ini"
    dest: "{{ http_files_dir }}/config.ini"
    state: link

- name: Symlink vendor to public directory
  ansible.builtin.file:
    src: "{{ src_dir }}/joeac.net/http/vendor"
    dest: "{{ http_files_dir }}/vendor"
    state: link

- name: Symlink php to public directory
  ansible.builtin.file:
    src: "{{ src_dir }}/joeac.net/http/php"
    dest: "{{ http_files_dir }}/php"
    state: link

- name: Symlink html to public directory
  ansible.builtin.file:
    src: "{{ src_dir }}/joeac.net/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"

- name: Install script to update http
  ansible.builtin.template:
    src: update_http
    dest: /usr/bin/update_http
    mode: "755"

- name: Install daily crontab to update http
  ansible.builtin.cron:
    special_time: daily
    name: Update http
    job: /usr/bin/update_http