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

add support for Proxysql cluster #58

Merged
merged 21 commits into from
Sep 3, 2018

Conversation

MaxFedotov
Copy link
Contributor

@MaxFedotov MaxFedotov commented Aug 23, 2018

Add ability to automatically create ProxySQL cluster. $cluster_name determines the name of the cluster, ProxySQL instance will belong to. It will lookup host in PuppetDB and create proxysql_cluster resources with params,it will get from it. Also added $cluster_username and $cluster_password variables

@MaxFedotov MaxFedotov mentioned this pull request Aug 23, 2018
manifests/cluster.pp Outdated Show resolved Hide resolved
manifests/install.pp Outdated Show resolved Hide resolved
manifests/params.pp Outdated Show resolved Hide resolved
MaxFedotov added a commit to MaxFedotov/puppet-proxysql that referenced this pull request Aug 25, 2018
remove hardcode of mysql-client package (changed to variable in voxpupuli#58)
manifests/init.pp Outdated Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved
@bastelfreak
Copy link
Member

@MaxFedotov can you take a look at the used email address in your commits? It is not associated with your github account.

@MaxFedotov
Copy link
Contributor Author

MaxFedotov commented Aug 31, 2018

I've updated email and made a few more linting fixes + changed style for facts

@bastelfreak
Copy link
Member

The code looks good to me, thanks for the updates! @mcrauwel can you please review this as well?

@mcrauwel
Copy link
Member

mcrauwel commented Sep 1, 2018

@bastelfreak I have the further testing on my schedule for this week... I will try to finish all pending reviews

@bastelfreak
Copy link
Member

Maybe this would also be a good time to add acceptance tests? Something basic like https://github.com/voxpupuli/puppet-collectd/blob/master/spec/acceptance/class_spec.rb would already help a lot.

MaxFedotov added a commit to MaxFedotov/puppet-proxysql that referenced this pull request Sep 1, 2018
remove hardcode of mysql-client package (changed to variable in voxpupuli#58)
@mcrauwel
Copy link
Member

mcrauwel commented Sep 2, 2018

@MaxFedotov can you rebase on the current master?

MaxFedotov added a commit to MaxFedotov/puppet-proxysql that referenced this pull request Sep 3, 2018
remove hardcode of mysql-client package (changed to variable in voxpupuli#58)
@mcrauwel mcrauwel merged commit 5ed0236 into voxpupuli:master Sep 3, 2018
@tullis
Copy link

tullis commented Oct 10, 2018

@MaxFedotov - Could you possibly share your work on the proxysql::cluster class again please, either here or maybe in an example doc?

I'd be keen to see how you realize the proxysql_server table entries from the virtual resources, and whether that's with a collector, or a realize function.

Many thanks for all of your work on this.

@MaxFedotov
Copy link
Contributor Author

MaxFedotov commented Oct 10, 2018

@tullis
It's some type of profile (or our custom wrapper for default Proxysql module) with following (sorry for formatting issues):

class db::proxysql (
  Db::Common::Cluster_name $cluster_name = undef,
  Optional[String] $version = '1.4.10-1',
  Optional[Proxysql::Server] $mysql_servers = undef,
  Optional[Proxysql::User] $mysql_users = undef,
  Optional[Proxysql::Hostgroup] $mysql_hostgroups = undef,
  Optional[Proxysql::Rule] $mysql_rules = undef,
  Optional[Proxysql::Scheduler] $schedulers = undef,
  Optional[Hash] $override_config_settings = undef,
){
 #some custom code necessary for our environment like creating users and passwords in vault, adding repos and installing additional packages

class { 'proxysql':
    listen_ip => '127.0.0.1',
    mysql_client_package_name => 'Percona-Server-client-56',
    listen_port => 3306,
    admin_listen_ip => '0.0.0.0',
    monitor_username => 'proxysql_monitor',
    manage_proxy_config_file => false,
    split_config => true,
    package_ensure => $version,
    package_provider => 'yum',
    admin_password => $admin_password,
    monitor_password => $monitor_password,
    cluster_password => $cluster_password,
    cluster_name => $cluster_name,
    manage_hostgroup_for_servers => false,
    mysql_servers => $mysql_servers,
    mysql_users => $mysql_users,
    mysql_hostgroups => $mysql_hostgroups,
    mysql_rules => $mysql_rules,
    schedulers => $schedulers,
    sys_owner => 'proxysql',
    sys_group => 'proxysql',
    override_config_settings => $config,
  }

  resources { 'proxy_cluster':
    purge => true,
  }

$query = "resources[parameters] {type = 'Class' and title = 'Proxysql' and parameters.cluster_name = '${cluster_name}'}"
$nodes = puppetdb_query($query).map | $hash | { $hash['parameters']['node_name'] }
$cluster_nodes = length($nodes) ? {
    0       => [$proxysql::node_name],
    default => $nodes,
  }
$cluster_nodes.each |String $node| {
    proxy_cluster { $node:
      hostname => "${split($node, ':')[0]}",
      port     => split($node, ':')[1],
      require  => Class['proxysql']
    }
  }

@tullis
Copy link

tullis commented Oct 10, 2018

Thanks @MaxFedotov, that's really useful.

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.

4 participants