3 phút đọc
puppetlabs/puppetlabs-mysql: MySQL Puppet Module / Manifests + Types & Providers – Repository puppetlabs/puppetlabs-mysql. Mô tả: MySQL Puppet Module / Manifests + Types & Providers. 376 stars, 787 forks, ngôn ngữ chính Ruby, cập nhật 2026-10-15.
1. Repository làm gì?
The mysql module installs, configures, and manages the MySQL service.
This module manages both the installation and configuration of MySQL, as well as extending Puppet to allow management of MySQL resources, such as databases, users, and grants.
To install a server with the default options:
To customize options, such as the root password or /etc/my.cnf settings, you must also pass in an override hash:
Nota bene: Configuration changes will only be applied to the running MySQL server if you pass true as restart to mysql::server.
See Customize Server Options below for examples of the hash structure for $override_options.
2. Dữ liệu và cấu trúc đáng chú ý
All interaction for the server is done via mysql::server. To install the client, use mysql::client. To install bindings, use mysql::bindings.
To define server options, structure a hash structure of overrides in mysql::server. This hash resembles a hash in the my.cnf file:
For options that you would traditionally represent in this format:
Entries can be created as thing => true, thing => value, or thing => "" in the hash. Alternatively, you can pass an array as thing => ['value', 'value2'] or list each thing => value separately on individual lines.
You can pass a variable in the hash without setting a value for it; the variable would then use MySQL's default settings. To exclude an option from the my.cnf file — for example, when using override_options to revert to a default value — pass thing => undef.
If an option needs multiple instances, pass an array. For example,
To implement version specific parameters, specify the version, such as [mysqld-5.5]. This allows one config for different versions of MySQL.
3. Khả năng ứng dụng và giới hạn
If you don’t want to use the default configuration, you can also supply your options to the $options parameter instead of $override_options. Please note that $options and $override_options are mutually exclusive, you can only use one of them.
By default, the puppet won't reload/restart mysqld when you change an existing configuration. If you want to do that, you can set mysql::server::reload_on_config_change to true.
To create a database with a user and some assigned privileges:
To use a different resource name with exported resources:
Then you can collect it on the remote DB server:
If you set the sql parameter to a file when creating a database, the file is imported into the new database.
For large sql files, increase the import_timeout parameter, which defaults to 300 seconds.
If you have installed the mysql client in a non standard bin/sbin path you can set this with mysql_exec_path .
To add custom MySQL configuration, place additional files into includedir. This allows you to override settings or add additional ones, which is helpful if you don't use override_options in mysql::server. The includedir location is by default set to /etc/mysql/conf.d.
Số liệu repository có thể thay đổi; nên mở liên kết nguồn để kiểm tra README, giấy phép và trạng thái phát hành.
Nguồn tham khảo: Xem bài gốc