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

Conversation

Frazew
Copy link

@Frazew Frazew commented Oct 10, 2024

Summary

In some cases, specifying a known src path in mysql_config_include_files is not possible / complicated and it may be much cleaner to provide raw file content to be sent. In that case, we need to use the ansible.builtin.copy module. We can extend the current implementation by simply filtering on whether src or content is set in each item in mysql_config_include_files

This PR also adds a label definition to the loop, that becomes necessary to avoid printing entire files with the default loop label

Example

For example if you want to use mysql_config_include_files with a file stored inside another role (because that's where it's the most practical place to store it currently), you need to:

mysql_config_include_files:
  - { src: "{{ role_path }}/../myrole/files/mysql/myconfig.cnf", force: yes }

Instead, for very simple configuration snippets it's cleaner to store them in the inventory / group_vars, and this PR then allows you to do that:

mysql_config_include_files:
  - dst: myconfig.cnf
    content: |
      [mysqld]
      # ...

In some cases, specifying a known src path in `mysql_config_include_files`
is not possible / complicated and it may be much cleaner to provide raw
file content to be sent. In that case, we need to use the
`ansible.builtin.copy` module. We can extend the current implementation
by simply filtering on whether `src` or `content` is set in each item
in `mysql_config_include_files`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant