Skip to content

Commit

Permalink
Set limit for uploaded file size (#3)
Browse files Browse the repository at this point in the history
* Set max_allowed_packet MySQL

* Fix MySQL (on restarted service)

* Set php limit

* Rewrite php limit

* Set mysql collation

* Set max_allowed_packet for mysqldump
  • Loading branch information
PawelPodkalicki authored Oct 24, 2022
1 parent 7541f48 commit 95dda98
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
23 changes: 21 additions & 2 deletions tasks/setup/mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@
update_cache: true
when: "'percona-server-server-5.7' not in ansible_facts.packages"

- name: "{{ service_name }} | setup | mysql | Set mysqld variables"
ansible.builtin.lineinfile:
path: "/etc/mysql/percona-server.conf.d/mysqld.cnf"
regexp: "^{{ it.key }}\\s*="
line: "{{ it.key }}={{ it.value }}"
loop:
- { key: 'character_set_server', value: 'utf8mb4' }
- { key: 'collation_server', value: 'utf8mb4_unicode_520_ci' }
- { key: 'max_allowed_packet', value: '32M' }
loop_control:
label: "{{ it.key }}"
loop_var: 'it'

- name: "{{ service_name }} | setup | mysql | Set mysqldump variables"
ansible.builtin.lineinfile:
path: "/etc/mysql/conf.d/mysqldump.cnf"
regexp: "^max_allowed_packet\\s*="
line: "max_allowed_packet=32M"

- name: "{{ service_name }} | setup | mysql | Start Percona"
ansible.builtin.service:
name: mysql
Expand All @@ -22,10 +41,10 @@
- name: "{{ service_name }} | setup | mysql | Create DB '{{ service_user }}_{{ service_name }}'" # noqa no-changed-when risky-shell-pipe
ansible.builtin.shell: echo "CREATE DATABASE IF NOT EXISTS {{ service_user }}_{{ service_name | replace('-', '_') }};" | mysql

- name: "{{ service_name }} | setup | mysql | Grant privileges'" # noqa no-changed-when risky-shell-pipe
- name: "{{ service_name }} | setup | mysql | Grant privileges" # noqa no-changed-when risky-shell-pipe
ansible.builtin.shell: echo "GRANT ALL ON {{ service_user }}_{{ service_name | replace('-', '_') }}.* TO '{{ service_user }}'@'localhost';" | mysql

- name: "{{ service_name }} | setup | mysql | Flush privileges'" # noqa no-changed-when risky-shell-pipe
- name: "{{ service_name }} | setup | mysql | Flush privileges" # noqa no-changed-when risky-shell-pipe
ansible.builtin.shell: echo "FLUSH PRIVILEGES;" | mysql

- name: "{{ service_name }} | setup | mysql | Cleanup"
Expand Down
10 changes: 8 additions & 2 deletions tasks/setup/php.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@
- name: "{{ service_name }} | setup | php | Config PHP upload size"
ansible.builtin.lineinfile:
path: "/etc/php/{{ php_version }}/fpm/php.ini"
regexp: '^upload_max_filesize ='
line: "upload_max_filesize = 32M"
regexp: "^{{ it.key }} ="
line: "{{ it.key }} = {{ it.value }}"
loop:
- { key: 'post_max_size', value: '32M' }
- { key: 'upload_max_filesize', value: '32M' }
loop_control:
label: "{{ it.key }}"
loop_var: 'it'

- name: "{{ service_name }} | setup | php | Config PHP-FPM pool"
ansible.builtin.template:
Expand Down

0 comments on commit 95dda98

Please sign in to comment.