1 #####################################
2 ### someone's ansible provisioner ###
3 #####################################
4 # Part of: https://git.somenet.org/root/pub/somesible.git
5 # 2017-2024 by someone <someone@somenet.org>
17 when: vhost_type|lower() in ["php", "custom+php"]
19 ignore_errors: "{{ignore_online_errors | bool}}"
22 - name: install custom php modules
24 pkg: "{{vhost_php_custom}}"
27 when: vhost_type|lower() in ["php", "custom+php"] and vhost_php_custom != []
29 ignore_errors: "{{ignore_online_errors | bool}}"
32 - name: copy php-fpm-www.conf
35 dest: "/etc/php/8.2/fpm/pool.d/www.conf"
40 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/php-fpm-www.conf"
41 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/php-fpm-www.conf"
42 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/php-fpm-www.conf"
43 - "default/php-fpm-www.conf"
44 when: vhost_type|lower() in ["php", "custom+php"]
45 notify: restart php-fpm.service
48 - name: copy php-fpm.service to /etc/systemd/system/
51 dest: "/etc/systemd/system/php-fpm.service"
56 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/php-fpm.service"
57 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/php-fpm.service"
58 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/php-fpm.service"
59 - "default/php-fpm.service"
60 when: vhost_type|lower() in ["php", "custom+php"]
63 - name: enable and start phpsessionclean.timer
64 include_role: name="base/systemd/enable-and-start"
66 service_name: phpsessionclean.timer
67 when: vhost_type|lower() in ["php", "custom+php"]
70 - name: enable and start php-fpm.service
71 include_role: name="base/systemd/enable-and-start"
73 service_name: php-fpm.service
74 when: vhost_type|lower() in ["php", "custom+php"]
77 - name: request letsencrypt cert for "{{vhost_name}}"
79 name: util/letsencrypt-cert
81 letsencrypt_cert_domain: "{{vhost_name}}"
82 letsencrypt_cert_domain_alias: "{{vhost_aliases}}"
83 when: vhost_https_on|bool or vhost_https_force_letsencrypt|bool
86 - name: set up webroot-dir for "{{vhost_name}}"
88 path: "/var/www/{{vhost_name}}"
95 - name: get or update content via git for "{{vhost_name}}"
97 repo: "{{vhost_git_repo}}"
98 dest: "/var/www/{{vhost_name}}/"
103 track_submodules: "yes"
105 version: "{{vhost_git_version}}"
106 when: vhost_git_repo != ""
107 tags: "nginx-vhost-content-update"
110 - name: deploy some custom files
113 dest: "/var/www/{{vhost_name}}/"
118 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/{{vhost_name}}-deploy-files/"
119 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/{{vhost_name}}-deploy-files/"
120 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/{{vhost_name}}-deploy-files/"
121 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/deploy-files/"
122 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/deploy-files/"
123 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/deploy-files/"
124 - "default/deploy-files/"
125 when: item.state == "file"
126 tags: "nginx-vhost-content-update"
129 - name: "fix webroot-dir permissions for {{vhost_name}}"
131 path: "/var/www/{{vhost_name}}"
134 mode: "u=rwX,g=rX,o-rwx"
137 when: vhost_fix_perms|bool
138 tags: "nginx-vhost-content-update"
141 - name: "include vhost_custom and vhost_custom_pre_server for {{vhost_name}}"
146 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/{{vhost_name}}-vars_vhost_custom.yml"
147 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/{{vhost_name}}-vars_vhost_custom.yml"
148 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/{{vhost_name}}-vars_vhost_custom.yml"
149 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/vars_vhost_custom.yml"
150 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/vars_vhost_custom.yml"
151 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/vars_vhost_custom.yml"
152 - "default/vars_vhost_custom.yml"
153 when: vhost_custom.vhost_custom == "" and vhost_custom.vhost_custom_pre_server == ""
156 - name: generate vhost config for "{{vhost_name}}"
159 dest: "/etc/nginx/sites-enabled/{{vhost_name}}.vhost"
164 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/{{vhost_name}}-vhost.j2"
165 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/{{vhost_name}}-vhost.j2"
166 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/{{vhost_name}}-vhost.j2"
167 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/vhost.j2"
168 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/vhost.j2"
169 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/vhost.j2"
171 notify: restart nginx.service
174 - name: generate awstats config for "{{vhost_name}}"
177 dest: "/etc/awstats/awstats.{{vhost_name}}.conf"
182 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/{{vhost_name}}-awstats.j2"
183 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/{{vhost_name}}-awstats.j2"
184 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/{{vhost_name}}-awstats.j2"
185 - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/awstats.j2"
186 - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/awstats.j2"
187 - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/awstats.j2"
188 - "default/awstats.j2"
191 - name: reset vhost_custom and vhost_custom_pre_server
193 file: "default/vars_vhost_custom.yml"
195 when: vhost_custom.vhost_custom != "" or vhost_custom.vhost_custom_pre_server != ""