Class: Demae::CLI
- Inherits:
-
Thor
- Object
- Thor
- Demae::CLI
- Defined in:
- lib/demae/cli.rb
Constant Summary collapse
- CONFIG_DIR =
'config/demae'
Instance Method Summary collapse
- #apply(environment) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #install ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
9 10 11 12 13 |
# File 'lib/demae/cli.rb', line 9 def initialize(*) super Itamae.logger.level = ::Logger.const_get('INFO') Itamae.logger.formatter.colored = true end |
Instance Method Details
#apply(environment) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/demae/cli.rb', line 25 def apply(environment) config = YAML.load_file(config_path(environment)) config.each do |server| server['hosts'].each do |host| = { host: host, vagrant: false, ask_password: false, sudo: true } o = server.reject { |k, _| %w(hosts recipes).include? k } o = o.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v } .merge!(o) runner = Itamae::Runner.run(server['recipes'], :ssh, ) end end end |
#install ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/demae/cli.rb', line 16 def install templates_dir = File.('../templates', __FILE__) FileUtils.mkdir_p(CONFIG_DIR) %w(staging production).each do |environment| FileUtils.copy("#{templates_dir}/environment.yml", config_path(environment)) end end |