Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mysql_config_include_files to contain raw content #551

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Whether the global my.cnf should be overwritten each time this role is run. Sett
mysql_config_include_files: []
```

A list of files that should override the default global my.cnf. Each item in the array requires a "src" parameter which is a path to a file. An optional "force" parameter can force the file to be updated each time ansible runs.
A list of files that should override the default global my.cnf. Each item in the array requires either a "src" parameter which is a path to a file, or both a "content" (file contents) and a "dst" (file name) parameter. An optional "force" parameter can force the file to be updated each time ansible runs.

```yaml
mysql_databases: []
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ mysql_log: ""
mysql_config_include_files: []
# - src: path/relative/to/playbook/file.cnf
# - { src: path/relative/to/playbook/anotherfile.cnf, force: yes }
# - content: |
# # some included configuration here
# dst: yetanotherfile.cnf

# Databases.
mysql_databases: []
Expand Down
19 changes: 17 additions & 2 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,30 @@
mode: 0755
when: mysql_config_include_files | length

- name: Copy my.cnf override files into include directory.
- name: Template my.cnf override files into include directory.
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ mysql_config_include_dir }}/{{ item.src | basename }}"
owner: root
group: root
mode: 0644
force: "{{ item.force | default(False) }}"
with_items: "{{ mysql_config_include_files }}"
with_items: "{{ mysql_config_include_files | selectattr('src', 'defined') }}"
loop_control:
label: "{{ item.src | basename }}"
notify: restart mysql

- name: Copy my.cnf override files into include directory.
ansible.builtin.copy:
content: "{{ item.content }}"
dest: "{{ mysql_config_include_dir }}/{{ item.dst }}"
owner: root
group: root
mode: 0644
force: "{{ item.force | default(False) }}"
with_items: "{{ mysql_config_include_files | selectattr('content', 'defined') }}"
loop_control:
label: "{{ item.dst }}"
notify: restart mysql

- name: Create slow query log file (if configured).
Expand Down
Loading