Sha256: 625e8d3d8e57c2c987ff11e0f2080087ab3585003aed14d309b6018d5e84bc3e

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

# Authors
# Seth Chisamore
# Seth Falcon
# Jeremiah Snapp

require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut

class PiabHelper

  VALID_OMNIBUS_ROOTS = %w{
    /opt/opscode
    /opt/chef-server
  }

  def self.omnibus_root
    @@root_path ||= begin
      root_path = VALID_OMNIBUS_ROOTS.detect{|path| File.exists?(path) }
      raise "Could not locate one of #{VALID_OMNIBUS_ROOTS.join(', ')}" unless root_path
      root_path
    end
  end

  def self.omnibus_bin_path
    self.omnibus_root + "/embedded/bin"
  end

  def self.private_chef_ha?
    File.exists?("/etc/opscode/private-chef.rb") && File.read("/etc/opscode/private-chef.rb") =~ /topology\s+.*ha/
  end

  def self.private_chef?
    File.exists?("/opt/opscode/bin/private-chef-ctl")
  end

  def self.open_source_chef?
    File.exists?("/opt/chef-server/bin/chef-server-ctl")
  end

  def self.existing_config
    config_files = {
      "private_chef" => "/etc/opscode/chef-server-running.json",
      "chef_server" => "/etc/chef-server/chef-server-running.json"
    }
    config_files.each do |key, path|
      if ::File.exists?(path)
        return Chef::JSONCompat.from_json(IO.read(path))[key]
      end
    end
    raise "No existing config found"
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dev-lxc-0.2.3 files/create_users/create_users.rb
dev-lxc-0.2.2 files/create_users/create_users.rb
dev-lxc-0.2.1 files/create_users/create_users.rb
dev-lxc-0.2.0 files/create_users/create_users.rb
dev-lxc-0.1.2 files/create_users/create_users.rb