Class: Sambot::Chef::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/sambot/chef/server.rb

Constant Summary collapse

SHORT_NAMES =
{
  'wsus' => 'WSUS',
  'nginx-proxy' => 'PRXY',
  'jetstream' => 'JTS',
  'task-scheduler' => 'TASKS',
  'queue-service' => 'QUE',
  'skylight' => 'SKY',
  'prometheus' => 'PRT',
  'octopus' => 'OCTO',
  'vault' => 'VAULT',
  'consul' => 'CONSUL',
  'rabbitmq' => 'RMQ',
  'etcd' => 'ETCD',
  'teamcity-agent' => 'TCA',
  'teamcity-server' => 'TCS',
  'bastion' =>   'BST',
  'base' => 'BASE',
  'grafana' => 'MON'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(ridley = nil) ⇒ Server

Returns a new instance of Server.



30
31
32
33
34
35
36
37
# File 'lib/sambot/chef/server.rb', line 30

def initialize(ridley = nil)
  @ridley = ridley || Ridley.new(
    server_url: "https://chef.brighter.io/organizations/#{ENV['CHEF_ORGANIZATION']}",
    client_name: ENV['CHEF_CLIENT_NAME'],
    client_key: ENV['CHEF_CLIENT_KEY'],
    proxy: ENV['FIXIE_URL']
  )
end

Instance Method Details

#cookbooksObject



39
40
41
# File 'lib/sambot/chef/server.rb', line 39

def cookbooks
  @cookbooks ||= @ridley.cookbook.all.select { |x| x =~ /as-/ }.keys.sort
end

#find_role_name(cookbook) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/sambot/chef/server.rb', line 47

def find_role_name(cookbook)
  naive_name = cookbook.gsub(/as-role-/, '').gsub(/as-app-role-/, '')
  if SHORT_NAMES.key?(naive_name)
    SHORT_NAMES[naive_name]
  else
    raise 'Could not generate an instance name'
  end
end

#rolesObject



43
44
45
# File 'lib/sambot/chef/server.rb', line 43

def roles
  cookbooks.select { |x| x =~ /role/ }
end