-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
186 lines (180 loc) · 6.36 KB
/
main.yml
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
---
- hosts: all
vars:
homebrew_formulas:
- git
- php
- caddy
- composer
- mailhog
- dnsmasq
php_versions:
- 7.4
- 8.1
- 8.2
- 8.3
pecl_exec_locations:
- /usr/local/opt/[email protected]/bin/pecl
- /usr/local/opt/[email protected]/bin/pecl
- /usr/local/opt/[email protected]/bin/pecl
- /usr/local/opt/[email protected]/bin/pecl
tasks:
- name: Create directory for ansible custom facts
ansible.builtin.file:
state: directory
recurse: true
path: /usr/local/etc/ansible/facts.d
- name: Install custom PHP version fact
ansible.builtin.copy:
src: files/php_version.fact
dest: /usr/local/etc/ansible/facts.d
mode: preserve
- name: Tap shivammathur/php for [email protected]
community.general.homebrew_tap:
name: shivammathur/php
state: present
- name: Ensure that required homebrew packages are installed (PHP, Caddy, MariaDB, etc.)
community.general.homebrew:
name: "{{ item }}"
state: latest
loop: "{{ homebrew_formulas }}"
- name: Re-read facts after adding custom fact and installing/updating PHP
ansible.builtin.setup:
filter: ansible_local
fact_path: /usr/local/etc/ansible/facts.d
- name: Unlink all but php 8.2
community.general.homebrew:
name: "{ item }"
state: unlinked
when: ansible_local['php_version'] != "8.2"
loop:
- php
- name: Link php 8.2 for CLI use
community.general.homebrew:
name: [email protected]
state: linked
when: ansible_local['php_version'] != "8.2"
- name: Ensure pecl apcu package is installed for all PHP versions
community.general.pear:
executable: "{{ item }}"
name: pecl/apcu
state: latest
prompts:
- (.*)Enable internal debugging in APCu \[no\]
loop: "{{ pecl_exec_locations }}"
# Note that as of 3.2.0, xdebug no longer supports PHP 7.x. So we don't try to install the latest.
- name: Ensure pecl xdebug package is installed for PHP 7.4
community.general.pear:
executable: /usr/local/opt/[email protected]/bin/pecl
name: pecl/xdebug
state: present
- name: Ensure pecl xdebug package is installed for all PHP 8.x versions
community.general.pear:
executable: "{{ item }}"
name: pecl/xdebug
state: latest
loop:
- /usr/local/opt/[email protected]/bin/pecl
- /usr/local/opt/[email protected]/bin/pecl
- /usr/local/opt/[email protected]/bin/pecl
- name: Remove php.ini changes from apcu pecl install
ansible.builtin.lineinfile:
path: /usr/local/etc/php/{{ item }}/php.ini
line: extension="apcu.so"
state: absent
loop: "{{ php_versions }}"
- name: Add or update PHP extension ini files
ansible.builtin.copy:
src: files/{{ item.src }}
dest: /usr/local/etc/{{ item.dest }}
loop:
- { src: ext-acpu.ini, dest: php/7.4/conf.d/ext-apcu.ini }
- { src: ext-acpu.ini, dest: php/8.1/conf.d/ext-apcu.ini }
- { src: ext-acpu.ini, dest: php/8.2/conf.d/ext-apcu.ini }
- { src: ext-acpu.ini, dest: php/8.3/conf.d/ext-apcu.ini }
- { src: ext-xdebug.7.4.ini, dest: php/7.4/conf.d/ext-xdebug.ini }
- { src: ext-xdebug.8.1.ini, dest: php/8.1/conf.d/ext-xdebug.ini }
- { src: ext-xdebug.8.2.ini, dest: php/8.2/conf.d/ext-xdebug.ini }
- { src: ext-xdebug.8.3.ini, dest: php/8.3/conf.d/ext-xdebug.ini }
- name: Remove php.ini changes from xdebug pecl install
ansible.builtin.lineinfile:
path: /usr/local/etc/php/{{ item }}/php.ini
line: zend_extension="xdebug.so"
state: absent
loop: "{{ php_versions }}"
- name: Configure PHP memory_limit
ansible.builtin.lineinfile:
path: /usr/local/etc/php/{{ item }}/php.ini
regexp: '^memory_limit ='
line: memory_limit = 1024M
loop: "{{ php_versions }}"
- name: Configure PHP max_execution_time
ansible.builtin.lineinfile:
path: /usr/local/etc/php/{{ item }}/php.ini
regexp: '^max_execution_time ='
line: max_execution_time = 90
loop: "{{ php_versions }}"
- name: Configure PHP max_input_time
ansible.builtin.lineinfile:
path: /usr/local/etc/php/{{ item }}/php.ini
regexp: '^max_input_time ='
line: max_input_time = 90
loop: "{{ php_versions }}"
- name: Configure PHP to use Mailhog
ansible.builtin.lineinfile:
path: /usr/local/etc/php/{{ item }}/php.ini
regexp: '^;?sendmail_path ='
line: sendmail_path = /usr/local/bin/MailHog sendmail
loop: "{{ php_versions }}"
- name: Configure PHP upload_max_filesize
ansible.builtin.lineinfile:
path: /usr/local/etc/php/{{ item }}/php.ini
regexp: '^upload_max_filesize ='
line: upload_max_filesize = 8M
loop: "{{ php_versions }}"
- name: Add or update Caddy and PHP-FPM config files
ansible.builtin.template:
src: templates/{{ item.src }}
dest: /usr/local/etc/{{ item.dest }}
loop:
- { src: Caddyfile.j2, dest: Caddyfile }
- { src: php-fpm_7.4_www-xdebug.conf.j2, dest: php/7.4/php-fpm.d/www-xdebug.conf }
- { src: php-fpm_7.4_www.conf.j2, dest: php/7.4/php-fpm.d/www.conf }
- { src: php-fpm_8.1_www-xdebug.conf.j2, dest: php/8.1/php-fpm.d/www-xdebug.conf }
- { src: php-fpm_8.1_www.conf.j2, dest: php/8.1/php-fpm.d/www.conf }
- { src: php-fpm_8.2_www-xdebug.conf.j2, dest: php/8.2/php-fpm.d/www-xdebug.conf }
- { src: php-fpm_8.2_www.conf.j2, dest: php/8.2/php-fpm.d/www.conf }
- { src: php-fpm_8.3_www-xdebug.conf.j2, dest: php/8.3/php-fpm.d/www-xdebug.conf }
- { src: php-fpm_8.3_www.conf.j2, dest: php/8.3/php-fpm.d/www.conf }
- name: Ensure that the Caddy configuration import directory exists
ansible.builtin.file:
path: /usr/local/etc/Caddy.conf.d
state: directory
mode: '0755'
- name: Ensure that the ~/sites/ directory exists
ansible.builtin.file:
path: ~/sites
state: directory
mode: '0755'
- name: Add or update dnsmasq configuration file
ansible.builtin.copy:
src: files/dnsmasq.conf
dest: /usr/local/etc/dnsmasq.conf
- name: Ensure that the /etc/resolver directory exists
ansible.builtin.file:
path: /etc/resolver
state: directory
mode: '0755'
become: yes
- name: Ensure that the /etc/resolver/test file exists
ansible.builtin.copy:
src: files/test-resolver
dest: /etc/resolver/test
mode: '0744'
become: yes