summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-10-21 02:18:23 -0700
committerelijah <elijah@riseup.net>2014-10-21 02:18:23 -0700
commit34e346d039091723912d4ccbb1673ffc438b293b (patch)
tree1134467d5732428f11c105a2ffa215d4d95aa962
parentbbed56bfccd84e6d7056dee25c508571ce3082c6 (diff)
added support for custom-puppet
-rw-r--r--lib/leap_cli/commands/deploy.rb66
-rw-r--r--lib/leap_cli/constants.rb3
-rw-r--r--lib/leap_cli/version.rb2
3 files changed, 50 insertions, 21 deletions
diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb
index 54c2bdb..75ac977 100644
--- a/lib/leap_cli/commands/deploy.rb
+++ b/lib/leap_cli/commands/deploy.rb
@@ -171,7 +171,13 @@ module LeapCli
end
end
+ #
+ # 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)
@@ -190,6 +196,37 @@ module LeapCli
nil
end
end
+
+ # sync files to /srv/leap/files
+ dest_dir = File.join(LeapCli::PUPPET_DESTINATION, "files")
+ source_files = []
+ if 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|
+ node = manager.node(server.host)
+ files_to_sync = node.file_paths.collect {|path| Path.relative_path(path, Path.provider) }
+ files_to_sync += source_files
+ if files_to_sync.any?
+ ssh.leap.log(files_to_sync.join(', ') + ' -> ' + node.name + ':' + dest_dir)
+ {
+ :chdir => Path.named_path(:files_dir),
+ :source => ".",
+ :dest => dest_dir,
+ :excludes => "*",
+ :includes => calculate_includes_from_files(files_to_sync, '/files'),
+ :flags => "-rltp --chmod=u+rX,go-rwx --relative --delete --delete-excluded --copy-links"
+ }
+ else
+ nil
+ end
+ end
end
def sync_puppet_files(ssh)
@@ -204,21 +241,6 @@ module LeapCli
:flags => "-rlt --relative --delete --copy-links"
}
end
- ssh.rsync.update do |server|
- custom_site = Path.provider + LeapCli::CUSTOM_PUPPET_SITE
- custom_modules = Path.provider + LeapCli::CUSTOM_PUPPET_MODULES
- if !file_exists?(custom_site)
- write_file!(custom_site, "# custom puppet configuration" + "\n" + "tag 'leap_base'" + "\n")
- end
- ensure_dir custom_modules
- ssh.leap.log(Path.provider + LeapCli::CUSTOM_PUPPET_SOURCE + ' -> ' + server.host + ':' + LeapCli::CUSTOM_PUPPET_DESTINATION)
- {
- :dest => LeapCli::CUSTOM_PUPPET_DESTINATION,
- :source => Path.provider + LeapCli::CUSTOM_PUPPET_SOURCE,
- :chdir => Path.platform,
- :flags => "-rlt --delete --copy-links"
- }
- end
end
#
@@ -240,11 +262,17 @@ module LeapCli
end
end
- def calculate_includes_from_files(files)
+ #
+ # converts an array of file paths into an array
+ # suitable for --include of rsync
+ #
+ # if set, `prefix` is stripped off.
+ #
+ def calculate_includes_from_files(files, prefix=nil)
return nil unless files and files.any?
# prepend '/' (kind of like ^ for rsync)
- includes = files.collect {|file| '/' + file}
+ includes = files.collect {|file| file =~ /^\// ? file : '/' + file }
# include all sub files of specified directories
includes.size.times do |i|
@@ -262,6 +290,10 @@ module LeapCli
end
end
+ if prefix
+ includes.map! {|path| path.sub(/^#{Regexp.escape(prefix)}/, '')}
+ end
+
return includes
end
diff --git a/lib/leap_cli/constants.rb b/lib/leap_cli/constants.rb
index dcb66be..5abe630 100644
--- a/lib/leap_cli/constants.rb
+++ b/lib/leap_cli/constants.rb
@@ -2,9 +2,6 @@ module LeapCli
PUPPET_DESTINATION = '/srv/leap'
CUSTOM_PUPPET_DESTINATION = '/srv/leap/custom-puppet'
- CUSTOM_PUPPET_SOURCE = '/files/custom-puppet/'
- CUSTOM_PUPPET_SITE = "#{CUSTOM_PUPPET_SOURCE}/manifests/site.pp"
- CUSTOM_PUPPET_MODULES = "#{CUSTOM_PUPPET_SOURCE}/modules"
INITIALIZED_FILE = "#{PUPPET_DESTINATION}/initialized"
DEFAULT_TAGS = ['leap_base','leap_service']
diff --git a/lib/leap_cli/version.rb b/lib/leap_cli/version.rb
index 019e267..62819de 100644
--- a/lib/leap_cli/version.rb
+++ b/lib/leap_cli/version.rb
@@ -1,7 +1,7 @@
module LeapCli
unless defined?(LeapCli::VERSION)
VERSION = '1.5.9'
- COMPATIBLE_PLATFORM_VERSION = '0.5.3'..'1.99'
+ COMPATIBLE_PLATFORM_VERSION = '0.5.5'..'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']