Mercurial > repos > other > Puppet
annotate modules/mysql/tasks/export.rb @ 482:d83de9b3a62b default tip
Update hiera.yaml within Puppet config
Forgot that we manage it from here. Now has content to match
new packages
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 30 Aug 2024 16:10:36 +0100 |
parents | adf6fe9bbc17 |
children |
rev | line source |
---|---|
244 | 1 #!/opt/puppetlabs/puppet/bin/ruby |
389 | 2 # frozen_string_literal: true |
3 | |
244 | 4 require 'json' |
5 require 'open3' | |
6 require 'puppet' | |
7 | |
8 def get(file, database, user, password) | |
9 cmd_string = 'mysqldump' | |
10 cmd_string << " --databases #{database}" unless database.nil? | |
11 cmd_string << " --user=#{user}" unless user.nil? | |
12 cmd_string << " --password=#{password}" unless password.nil? | |
13 cmd_string << " > #{file}" unless file.nil? | |
14 stdout, stderr, status = Open3.capture3(cmd_string) | |
15 raise Puppet::Error, _("stderr: '%{stderr}'" % { stderr: stderr }) if status != 0 | |
478
adf6fe9bbc17
Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents:
389
diff
changeset
|
16 |
244 | 17 { status: stdout.strip } |
18 end | |
19 | |
478
adf6fe9bbc17
Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents:
389
diff
changeset
|
20 params = JSON.parse($stdin.read) |
244 | 21 database = params['database'] |
22 user = params['user'] | |
23 password = params['password'] | |
24 file = params['file'] | |
25 | |
26 begin | |
27 result = get(file, database, user, password) | |
28 puts result.to_json | |
29 exit 0 | |
30 rescue Puppet::Error => e | |
31 puts({ status: 'failure', error: e.message }.to_json) | |
32 exit 1 | |
33 end |