aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-10-21 14:50:44 -0700
committerelijah <elijah@riseup.net>2014-10-21 14:50:44 -0700
commit7a0022a0a5fa214892b29221a2fae904dbc5b856 (patch)
treec25672a5cd7df2f6d249f4d81065b3137a947719 /lib
parent34e346d039091723912d4ccbb1673ffc438b293b (diff)
downloadleap_cli-7a0022a0a5fa214892b29221a2fae904dbc5b856.tar.gz
leap_cli-7a0022a0a5fa214892b29221a2fae904dbc5b856.tar.bz2
removed constants.rb, now defined in platform.rb
Diffstat (limited to 'lib')
-rw-r--r--lib/leap/platform.rb16
-rw-r--r--lib/leap_cli/commands/deploy.rb43
-rw-r--r--lib/leap_cli/commands/test.rb4
-rw-r--r--lib/leap_cli/constants.rb8
-rw-r--r--lib/leap_cli/remote/leap_plugin.rb4
-rw-r--r--lib/leap_cli/remote/puppet_plugin.rb2
-rw-r--r--lib/leap_cli/remote/tasks.rb2
-rw-r--r--lib/leap_cli/version.rb2
8 files changed, 30 insertions, 51 deletions
diff --git a/lib/leap/platform.rb b/lib/leap/platform.rb
index 89b1bc1..c1103d4 100644
--- a/lib/leap/platform.rb
+++ b/lib/leap/platform.rb
@@ -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
diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb
index 75ac977..f1ba5b8 100644
--- a/lib/leap_cli/commands/deploy.rb
+++ b/lib/leap_cli/commands/deploy.rb
@@ -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(',')
diff --git a/lib/leap_cli/commands/test.rb b/lib/leap_cli/commands/test.rb
index 2584a69..2f146b7 100644
--- a/lib/leap_cli/commands/test.rb
+++ b/lib/leap_cli/commands/test.rb
@@ -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
index 5abe630..0000000
--- a/lib/leap_cli/constants.rb
+++ /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
diff --git a/lib/leap_cli/remote/leap_plugin.rb b/lib/leap_cli/remote/leap_plugin.rb
index a284712..af88c2a 100644
--- a/lib/leap_cli/remote/leap_plugin.rb
+++ b/lib/leap_cli/remote/leap_plugin.rb
@@ -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
#
diff --git a/lib/leap_cli/remote/puppet_plugin.rb b/lib/leap_cli/remote/puppet_plugin.rb
index 9c41380..e3f6be2 100644
--- a/lib/leap_cli/remote/puppet_plugin.rb
+++ b/lib/leap_cli/remote/puppet_plugin.rb
@@ -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
diff --git a/lib/leap_cli/remote/tasks.rb b/lib/leap_cli/remote/tasks.rb
index e66b0a8..7fd8d64 100644
--- a/lib/leap_cli/remote/tasks.rb
+++ b/lib/leap_cli/remote/tasks.rb
@@ -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|
diff --git a/lib/leap_cli/version.rb b/lib/leap_cli/version.rb
index 62819de..019e267 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.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']