Class: IntercityCLI::MySQL
- Inherits:
-
Thor
- Object
- Thor
- IntercityCLI::MySQL
- Defined in:
- lib/intercity/cli/mysql.rb
Instance Method Summary collapse
Instance Method Details
#install ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/intercity/cli/mysql.rb', line 49 def install configuration = IntercityCLI::Configuration.new() address = [:server] || configuration.active_server! node_file = File.join(configuration.nodes_directory, "#{address}.json") if File.exists?(node_file) raw_json = File.read(node_file) json = JSON.parse(raw_json) else json = {mysql: { server_root_password: [:root_password] }} end File.open(node_file, "w+") do |f| f.write(JSON.pretty_generate(json)) end server = address user = [:user] on server do |host| with debian_frontend: :noninteractive do host.user = user upload! node_file, "/root/server_config.json" execute 'chef-solo -c solo.rb -j ~/server_config.json -o recipe[mysql::server]' end end end |
#list ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/intercity/cli/mysql.rb', line 12 def list configuration = IntercityCLI::Configuration.new() address = [:server] || configuration.active_server! node_file = File.join(configuration.nodes_directory, "#{address}.json") raw_json = File.read(node_file) json = JSON.parse(raw_json) root_password = json["mysql"]["server_root_password"] puts "Local Configuration" puts "===================" json["active_applications"].each do |app, config| database_info = config["database_info"] puts database_info.inspect end puts user = [:user] on address do |host| host.user = user puts "On MySQL Server" puts "===============" databases = capture("mysql -u root --password=#{root_password} -e \"show databases;\"") puts databases end end |