]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
removed constants.rb, now defined in platform.rb
authorelijah <elijah@riseup.net>
Tue, 21 Oct 2014 21:50:44 +0000 (14:50 -0700)
committerelijah <elijah@riseup.net>
Tue, 21 Oct 2014 21:50:44 +0000 (14:50 -0700)
lib/leap/platform.rb
lib/leap_cli/commands/deploy.rb
lib/leap_cli/commands/test.rb
lib/leap_cli/constants.rb [deleted file]
lib/leap_cli/remote/leap_plugin.rb
lib/leap_cli/remote/puppet_plugin.rb
lib/leap_cli/remote/tasks.rb
lib/leap_cli/version.rb

index 89b1bc1a117af7b3ffa8ec0e2873303275b5b646..c1103d45d855ec703c3720db306519f158f21a9d 100644 (file)
@@ -16,9 +16,22 @@ module Leap
       attr_accessor :monitor_username
       attr_accessor :reserved_usernames
 
+      attr_accessor :hiera_path
+      attr_accessor :files_dir
+      attr_accessor :leap_dir
+      attr_accessor :init_path
+
+      attr_accessor :default_puppet_tags
+
       def define(&block)
-        # some sanity defaults:
+        # some defaults:
         @reserved_usernames = []
+        @hiera_path = '/etc/leap/hiera.yaml'
+        @leap_dir   = '/srv/leap'
+        @files_dir  = '/srv/leap/files'
+        @init_path  = '/srv/leap/initialized'
+        @default_puppet_tags = []
+
         self.instance_eval(&block)
       end
 
@@ -51,6 +64,7 @@ module Leap
         maximum_platform_version = Versionomy.parse(range.last)
         @version >= minimum_platform_version && @version <= maximum_platform_version
       end
+
     end
 
   end
index 75ac9778dd843197b05ecb0f5066de9c1a1ace0a..f1ba5b86805160af0270653b93010784dfa017ac 100644 (file)
@@ -22,7 +22,7 @@ module LeapCli
 
       # --tags
       c.flag :tags, :desc => 'Specify tags to pass through to puppet (overriding the default).',
-                    :default_value => DEFAULT_TAGS.join(','), :arg_name => 'TAG[,TAG]'
+                    :default_value => "see platform.rb", :arg_name => 'TAG[,TAG]'
 
       c.flag :port, :desc => 'Override the default SSH port.',
                     :arg_name => 'PORT'
@@ -158,14 +158,13 @@ module LeapCli
     end
 
     def sync_hiera_config(ssh)
-      dest_dir = provider.hiera_sync_destination
       ssh.rsync.update do |server|
         node = manager.node(server.host)
         hiera_file = Path.relative_path([:hiera, node.name])
-        ssh.leap.log hiera_file + ' -> ' + node.name + ':' + dest_dir + '/hiera.yaml'
+        ssh.leap.log hiera_file + ' -> ' + node.name + ':' + Leap::Platform.hiera_path
         {
           :source => hiera_file,
-          :dest => dest_dir + '/hiera.yaml',
+          :dest => Leap::Platform.hiera_path,
           :flags => "-rltp --chmod=u+rX,go-rwx"
         }
       end
@@ -173,40 +172,14 @@ module LeapCli
 
     #
     # sync various support files.
-    # TODO: move everything into /srv/leap instead of /etc/leap
     #
     def sync_support_files(ssh)
-      # sync files to /etc/leap
-      # TODO: remove this
-      dest_dir = provider.hiera_sync_destination
-      ssh.rsync.update do |server|
-        node = manager.node(server.host)
-        files_to_sync = node.file_paths.collect {|path| Path.relative_path(path, Path.provider) }
-        if files_to_sync.any?
-          ssh.leap.log(files_to_sync.join(', ') + ' -> ' + node.name + ':' + dest_dir)
-          {
-            :chdir => Path.provider,
-            :source => ".",
-            :dest => dest_dir,
-            :excludes => "*",
-            :includes => calculate_includes_from_files(files_to_sync),
-            :flags => "-rltp --chmod=u+rX,go-rwx --relative --delete --delete-excluded --filter='protect hiera.yaml' --copy-links"
-          }
-        else
-          nil
-        end
-      end
-
-      # sync files to /srv/leap/files
-      dest_dir = File.join(LeapCli::PUPPET_DESTINATION, "files")
+      dest_dir = Leap::Platform.files_dir
       source_files = []
-      if file_exists?(:custom_puppet_dir)
+      if Path.defined?(:custom_puppet_dir) && file_exists?(:custom_puppet_dir)
         source_files += [:custom_puppet_dir, :custom_puppet_modules_dir, :custom_puppet_manifests_dir].collect{|path|
           Path.relative_path(path, Path.provider) + '/' # rsync needs trailing slash
         }
-        if !file_exists?(:custom_puppet_site)
-          write_file!(:custom_puppet_site, "# custom puppet configuration" + "\n" + "tag 'leap_base'" + "\n")
-        end
         ensure_dir :custom_puppet_modules_dir
       end
       ssh.rsync.update do |server|
@@ -231,9 +204,9 @@ module LeapCli
 
     def sync_puppet_files(ssh)
       ssh.rsync.update do |server|
-        ssh.leap.log(Path.platform + '/[bin,tests,puppet] -> ' + server.host + ':' + LeapCli::PUPPET_DESTINATION)
+        ssh.leap.log(Path.platform + '/[bin,tests,puppet] -> ' + server.host + ':' + Leap::Platform.leap_dir)
         {
-          :dest => LeapCli::PUPPET_DESTINATION,
+          :dest => Leap::Platform.leap_dir,
           :source => '.',
           :chdir => Path.platform,
           :excludes => '*',
@@ -301,7 +274,7 @@ module LeapCli
       if options[:tags]
         tags = options[:tags].split(',')
       else
-        tags = LeapCli::DEFAULT_TAGS.dup
+        tags = Leap::Platform.default_puppet_tags.dup
       end
       tags << 'leap_slow' unless options[:fast]
       tags.join(',')
index 2584a6990122b499ba927c14a32a5ba1d52133fe..2f146b781e83db77200ff62e7d9efecd996bb630 100644 (file)
@@ -33,9 +33,9 @@ module LeapCli; module Commands
 
   def test_cmd(options)
     if options[:continue]
-      "#{PUPPET_DESTINATION}/bin/run_tests --continue"
+      "#{Leap::Platform.leap_dir}/bin/run_tests --continue"
     else
-      "#{PUPPET_DESTINATION}/bin/run_tests"
+      "#{Leap::Platform.leap_dir}/bin/run_tests"
     end
   end
 
diff --git a/lib/leap_cli/constants.rb b/lib/leap_cli/constants.rb
deleted file mode 100644 (file)
index 5abe630..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-module LeapCli
-
-  PUPPET_DESTINATION = '/srv/leap'
-  CUSTOM_PUPPET_DESTINATION = '/srv/leap/custom-puppet'
-  INITIALIZED_FILE = "#{PUPPET_DESTINATION}/initialized"
-  DEFAULT_TAGS = ['leap_base','leap_service']
-
-end
index a284712b135df69d72e67d4b0637f79e1fa545ad..af88c2a2cbff3cbe31da8bd5689b836284ab8a74 100644 (file)
@@ -26,7 +26,7 @@ module LeapCli; module Remote; module LeapPlugin
   #
   def assert_initialized
     begin
-      test_initialized_file = "test -f #{INITIALIZED_FILE}"
+      test_initialized_file = "test -f #{Leap::Platform.init_path}"
       check_required_packages = "! dpkg-query -W --showformat='${Status}\n' #{required_packages} 2>&1 | grep -q -E '(deinstall|no packages)'"
       run "#{test_initialized_file} && #{check_required_packages} && echo ok"
     rescue Capistrano::CommandError => exc
@@ -57,7 +57,7 @@ module LeapCli; module Remote; module LeapPlugin
   end
 
   def mark_initialized
-    run "touch #{INITIALIZED_FILE}"
+    run "touch #{Leap::Platform.init_path}"
   end
 
   #
index 9c4138023b8aff5c99e95960486569106887633f..e3f6be2a57b9099c904f9ab775373cc1b1cbb2fd 100644 (file)
@@ -6,7 +6,7 @@
 module LeapCli; module Remote; module PuppetPlugin
 
   def apply(options)
-    run "#{PUPPET_DESTINATION}/bin/puppet_command set_hostname apply #{flagize(options)}"
+    run "#{Leap::Platform.leap_dir}/bin/puppet_command set_hostname apply #{flagize(options)}"
   end
 
   private
index e66b0a8a5987524e57a457c87786f72752e36daf..7fd8d6420d64858d82095fee6a0cb589854218c6 100644 (file)
@@ -34,7 +34,7 @@ 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"
-  leap.mkdirs LeapCli::PUPPET_DESTINATION
+  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|
index 62819dee83a85aa9424a37efe64a0bbeca610216..019e267eaee7b97969d482ff9ffd1ea6c5145aa7 100644 (file)
@@ -1,7 +1,7 @@
 module LeapCli
   unless defined?(LeapCli::VERSION)
     VERSION = '1.5.9'
-    COMPATIBLE_PLATFORM_VERSION = '0.5.5'..'1.99'
+    COMPATIBLE_PLATFORM_VERSION = '0.5.3'..'1.99'
     SUMMARY = 'Command line interface to the LEAP platform'
     DESCRIPTION = 'The command "leap" can be used to manage a bevy of servers running the LEAP platform from the comfort of your own home.'
     LOAD_PATHS = ['lib', 'vendor/certificate_authority/lib', 'vendor/rsync_command/lib']