diff options
Diffstat (limited to 'lib/leap_cli')
| -rw-r--r-- | lib/leap_cli/path.rb | 5 | ||||
| -rw-r--r-- | lib/leap_cli/remote/leap_plugin.rb | 37 | ||||
| -rw-r--r-- | lib/leap_cli/remote/puppet_plugin.rb | 40 | ||||
| -rw-r--r-- | lib/leap_cli/remote/tasks.rb | 39 | 
4 files changed, 12 insertions, 109 deletions
| diff --git a/lib/leap_cli/path.rb b/lib/leap_cli/path.rb index 62ea013..fd2e3fc 100644 --- a/lib/leap_cli/path.rb +++ b/lib/leap_cli/path.rb @@ -106,4 +106,9 @@ module LeapCli; module Path    def self.vagrant_ssh_pub_key_file      File.join(LEAP_CLI_BASE_DIR, 'vendor', 'vagrant_ssh_keys', 'vagrant.pub')    end + +  def self.node_init_script +    File.join(@platform, 'bin', 'node_init') +  end +  end; end diff --git a/lib/leap_cli/remote/leap_plugin.rb b/lib/leap_cli/remote/leap_plugin.rb index 21e69ee..9e255ea 100644 --- a/lib/leap_cli/remote/leap_plugin.rb +++ b/lib/leap_cli/remote/leap_plugin.rb @@ -5,14 +5,6 @@  module LeapCli; module Remote; module LeapPlugin -  def required_packages -    "puppet rsync lsb-release locales" -  end - -  def required_wheezy_packages -    "puppet ruby-hiera-puppet rsync lsb-release locales" -  end -    def log(*args, &block)      LeapCli::Util::log(*args, &block)    end @@ -61,10 +53,6 @@ module LeapCli; module Remote; module LeapPlugin      end    end -  def mark_initialized -    run "touch #{Leap::Platform.init_path}" -  end -    #    # dumps debugging information    # # @@ -196,29 +184,4 @@ module LeapCli; module Remote; module LeapPlugin      STDOUT.flush    end -  #def mkdir(dir) -  #  run "mkdir -p #{dir}" -  #end - -  #def chown_root(dir) -  #  run "chown root -R #{dir} && chmod -R ag-rwx,u+rwX #{dir}" -  #end - -  #def logrun(cmd) -  #  @streamer ||= LeapCli::Remote::LogStreamer.new -  #  run cmd do |channel, stream, data| -  #    @streamer.collect_output(channel[:host], data) -  #  end -  #end - -#    return_code = nil -#    run "something; echo return code: $?" do |channel, stream, data| -#      if data =~ /return code: (\d+)/ -#        return_code = $1.to_i -#      else -#        Capistrano::Configuration.default_io_proc.call(channel, stream, data) -#      end -#    end -#    puts "finished with return code: #{return_code}" -  end; end; end diff --git a/lib/leap_cli/remote/puppet_plugin.rb b/lib/leap_cli/remote/puppet_plugin.rb index 77bb4a3..5a6e908 100644 --- a/lib/leap_cli/remote/puppet_plugin.rb +++ b/lib/leap_cli/remote/puppet_plugin.rb @@ -24,43 +24,3 @@ module LeapCli; module Remote; module PuppetPlugin    end  end; end; end - - -    # def puppet(command = :noop) -    #   #puppet_cmd = "cd #{puppet_destination} && #{sudo_cmd} #{puppet_command} --modulepath=#{puppet_lib} #{puppet_parameters}" -    #   puppet_cmd = "cd #{puppet_destination} && #{sudo_cmd} #{puppet_command} #{puppet_parameters}" -    #   flag = command == :noop ? '--noop' : '' - -    #   writer = if puppet_stream_output -    #              SupplyDrop::Writer::Streaming.new(logger) -    #            else -    #              SupplyDrop::Writer::Batched.new(logger) -    #            end - -    #   writer = SupplyDrop::Writer::File.new(writer, puppet_write_to_file) unless puppet_write_to_file.nil? - -    #   begin -    #     exitcode = nil -    #     run "#{puppet_cmd} #{flag}; echo exitcode:$?" do |channel, stream, data| -    #       if data =~ /exitcode:(\d+)/ -    #         exitcode = $1 -    #         writer.collect_output(channel[:host], "Puppet #{command} complete (#{exitcode_description(exitcode)}).\n") -    #       else -    #         writer.collect_output(channel[:host], data) -    #       end -    #     end -    #   ensure -    #     writer.all_output_collected -    #   end -    # end - -    # def exitcode_description(code) -    #   case code -    #     when "0" then "no changes" -    #     when "2" then "changes made" -    #     when "4" then "failed" -    #     when "6" then "changes and failures" -    #     else code -    #   end -    # end - diff --git a/lib/leap_cli/remote/tasks.rb b/lib/leap_cli/remote/tasks.rb index 9d4587e..d08d19a 100644 --- a/lib/leap_cli/remote/tasks.rb +++ b/lib/leap_cli/remote/tasks.rb @@ -29,40 +29,15 @@ task :install_insecure_vagrant_key, :max_hosts => MAX_HOSTS do    end  end -BAD_APT_GET_UPDATE = /(BADSIG|NO_PUBKEY|KEYEXPIRED|REVKEYSIG|NODATA)/ -  task :install_prerequisites, :max_hosts => MAX_HOSTS do -  apt_get = "DEBIAN_FRONTEND=noninteractive apt-get -q -y -o DPkg::Options::=--force-confold" -  apt_get_update = "apt-get update -o Acquire::Languages=none" -  leap.mkdirs Leap::Platform.leap_dir -  run "echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen" -  leap.log :updating, "package list" do -    run apt_get_update do |channel, stream, data| -      # sadly exitcode is unreliable measure if apt-get update hit a failure. -      if data =~ BAD_APT_GET_UPDATE -        LeapCli::Util.bail! do -          LeapCli::Util.log :fatal_error, "in `apt-get update`: #{data}", :host => channel[:host] -        end -      else -        logger.log(1, data, channel[:host]) -      end -    end -  end -  leap.log :updating, "server time" do -    run "( test -f /etc/init.d/ntp && /etc/init.d/ntp stop ) || true" -    run "test -f /usr/sbin/ntpdate || #{apt_get} install ntpdate" -    leap.log :running, "ntpdate..." do -      run "test -f /usr/sbin/ntpdate && ntpdate 0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org" -    end -    run "( test -f /etc/init.d/ntp && /etc/init.d/ntp start ) || true" -  end -  leap.log :installing, "required packages" do -    run %[#{apt_get} install $( (egrep -q '(^wheezy|^7\.)' /etc/debian_version && echo #{leap.required_wheezy_packages}) || echo #{leap.required_packages} )] +  bin_dir = File.join(Leap::Platform.leap_dir, 'bin') +  node_init_path = File.join(bin_dir, 'node_init') + +  leap.log :running, "node_init script" do +    leap.mkdirs bin_dir +    upload LeapCli::Path.node_init_script, node_init_path, :mode => '500' +    run node_init_path    end -  #run "locale-gen" -  leap.mkdirs Leap::Platform.hiera_dir -  run "chmod 0755 #{Leap::Platform.hiera_dir}" -  leap.mark_initialized  end  # | 
