Skip to content

Commit

Permalink
fix a bug related to user update failed in case of proxysql cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxFedotov committed Nov 13, 2018
1 parent 41677ea commit a8305bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 18 additions & 4 deletions lib/puppet/provider/proxy_mysql_user/proxysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,28 @@ def create
schema_locked = @resource.value(:schema_locked) || 0
transaction_persistent = @resource.value(:transaction_persistent) || 1
fast_forward = @resource.value(:fast_forward) || 0
backend = @resource.value(:backend) || 1
frontend = @resource.value(:frontend) || 1
backend = @resource.value(:backend)
frontend = @resource.value(:frontend)
max_connections = @resource.value(:max_connections) || 10_000

query = 'INSERT INTO mysql_users (`username`, `password`, `active`, `use_ssl`, `default_hostgroup`, `default_schema`, '
query << ' `schema_locked`, `transaction_persistent`, `fast_forward`, `backend`, `frontend`, `max_connections`) '
query << ' `schema_locked`, `transaction_persistent`, `fast_forward`, '
if defined?(backend).nil?
query << ' `backend`,'
end
if defined?(frontend).nil?
query << ' `frontend`,'
end
query << ' `max_connections`)'
query << " VALUES ('#{name}', '#{password}', #{active}, #{use_ssl}, #{default_hostgroup}, '#{default_schema}', "
query << " #{schema_locked}, #{transaction_persistent}, #{fast_forward}, #{backend}, #{frontend}, #{max_connections})"
query << " #{schema_locked}, #{transaction_persistent}, #{fast_forward}, "
if defined?(backend).nil?
query << " #{backend},"
end
if defined?(frontend).nil?
query << " #{frontend},"
end
query << " #{max_connections})"
mysql([defaults_file, '-e', query].compact)
@property_hash[:ensure] = :present

Expand Down
2 changes: 0 additions & 2 deletions lib/puppet/type/proxy_mysql_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ def initialize(*args)

newproperty(:backend) do
desc 'Backend or not.'
defaultto 1
newvalue(%r{[01]})
end

newproperty(:frontend) do
desc 'Frontend or not.'
defaultto 1
newvalue(%r{[01]})
end

Expand Down

0 comments on commit a8305bf

Please sign in to comment.