Class: Marionetta::Manipulators::Puppet

Inherits:
Object
  • Object
show all
Includes:
Commandable
Defined in:
lib/marionetta/manipulators/puppet.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Puppet

The key ‘[:puppet]` must be set in your `server` hash in order for `PuppetManipulator` to function correctly.



40
41
42
# File 'lib/marionetta/manipulators/puppet.rb', line 40

def initialize(server)
  @server = server
end

Class Method Details

.tasksObject

‘PupperManipulator` provides two rake tasks when used with `RakeHelper` namely `:install` and `:update`. When applied through `RakeHelper` they will appear namespaced under `:puppet` and your group name.

With a group name of ‘:staging` would appear as:

puppet:staging:install
puppet:staging:update


30
31
32
# File 'lib/marionetta/manipulators/puppet.rb', line 30

def self.tasks()
  [:install, :update]
end

Instance Method Details

#can?Boolean

Call ‘.can?()` to check if the `:manifest` key has been set in the `server`.

Returns:

  • (Boolean)


47
48
49
# File 'lib/marionetta/manipulators/puppet.rb', line 47

def can?()
  server[:puppet].has_key?(:manifest)
end

#installObject

‘PuppetManipulator` provides the `.install()` method to install puppet on debian or ubuntu servers.



56
57
58
59
60
61
62
63
64
# File 'lib/marionetta/manipulators/puppet.rb', line 56

def install()
  p = server[:puppet]
  
  unless p.has_key?(:use_distro_repo) and p[:use_distro_repo] == true
    install_deb_repo
  end

  install_deb
end

#updateObject

Use ‘.update()` to package up your manifest and optionally modules and send them to your remote machine. Once there they will be applied.

If puppet is not installed, we attempt to install it before applying the manifest.



75
76
77
78
79
# File 'lib/marionetta/manipulators/puppet.rb', line 75

def update()
  install unless installed?
  send_puppet_files
  apply_puppet_files
end