Class: Bolt::Boltdir

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt/boltdir.rb

Constant Summary collapse

BOLTDIR_NAME =
'Boltdir'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, type = 'option') ⇒ Boltdir

Returns a new instance of Boltdir.



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bolt/boltdir.rb', line 33

def initialize(path, type = 'option')
  @path = Pathname.new(path).expand_path
  @config_file = @path + 'bolt.yaml'
  @inventory_file = @path + 'inventory.yaml'
  @modulepath = [(@path + 'modules').to_s, (@path + 'site-modules').to_s, (@path + 'site').to_s]
  @hiera_config = @path + 'hiera.yaml'
  @puppetfile = @path + 'Puppetfile'
  @rerunfile = @path + '.rerun.json'
  @resource_types = @path + '.resource_types'
  @type = type
end

Instance Attribute Details

#config_fileObject (readonly)

Returns the value of attribute config_file.



9
10
11
# File 'lib/bolt/boltdir.rb', line 9

def config_file
  @config_file
end

#hiera_configObject (readonly)

Returns the value of attribute hiera_config.



9
10
11
# File 'lib/bolt/boltdir.rb', line 9

def hiera_config
  @hiera_config
end

#inventory_fileObject (readonly)

Returns the value of attribute inventory_file.



9
10
11
# File 'lib/bolt/boltdir.rb', line 9

def inventory_file
  @inventory_file
end

#modulepathObject (readonly)

Returns the value of attribute modulepath.



9
10
11
# File 'lib/bolt/boltdir.rb', line 9

def modulepath
  @modulepath
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/bolt/boltdir.rb', line 9

def path
  @path
end

#puppetfileObject (readonly)

Returns the value of attribute puppetfile.



9
10
11
# File 'lib/bolt/boltdir.rb', line 9

def puppetfile
  @puppetfile
end

#rerunfileObject (readonly)

Returns the value of attribute rerunfile.



9
10
11
# File 'lib/bolt/boltdir.rb', line 9

def rerunfile
  @rerunfile
end

#resource_typesObject (readonly)

Returns the value of attribute resource_types.



9
10
11
# File 'lib/bolt/boltdir.rb', line 9

def resource_types
  @resource_types
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/bolt/boltdir.rb', line 9

def type
  @type
end

Class Method Details

.default_boltdirObject



12
13
14
# File 'lib/bolt/boltdir.rb', line 12

def self.default_boltdir
  Boltdir.new(File.join('~', '.puppetlabs', 'bolt'), 'user')
end

.find_boltdir(dir) ⇒ Object

Search recursively up the directory hierarchy for the Boltdir. Look for a directory called Boltdir or a file called bolt.yaml (for a control repo type Boltdir). Otherwise, repeat the check on each directory up the hierarchy, falling back to the default if we reach the root.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bolt/boltdir.rb', line 20

def self.find_boltdir(dir)
  dir = Pathname.new(dir)
  if (dir + BOLTDIR_NAME).directory?
    new(dir + BOLTDIR_NAME, 'embedded')
  elsif (dir + 'bolt.yaml').file?
    new(dir, 'local')
  elsif dir.root?
    default_boltdir
  else
    find_boltdir(dir.parent)
  end
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


49
50
51
# File 'lib/bolt/boltdir.rb', line 49

def eql?(other)
  path == other.path
end

#to_sObject



45
46
47
# File 'lib/bolt/boltdir.rb', line 45

def to_s
  @path.to_s
end