File: cfengine_needs_bootstrap.rb

package info (click to toggle)
vagrant 2.2.14%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,800 kB
  • sloc: ruby: 97,301; sh: 375; makefile: 16; lisp: 1
file content (34 lines) | stat: -rw-r--r-- 1,227 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require "log4r"

module VagrantPlugins
  module CFEngine
    module Cap
      module Linux
        module CFEngineNeedsBootstrap
          def self.cfengine_needs_bootstrap(machine, config)
            logger = Log4r::Logger.new("vagrant::plugins::cfengine::cap_linux_cfengine_bootstrap")

            machine.communicate.tap do |comm|
              # We hardcode fixing the permissions on /var/cfengine/ppkeys/, if it exists,
              # because otherwise CFEngine will fail to bootstrap.
              if comm.test("test -d /var/cfengine/ppkeys", sudo: true)
                logger.debug("Fixing permissions on /var/cfengine/ppkeys")
                comm.sudo("chmod -R 600 /var/cfengine/ppkeys")
              end

              logger.debug("Checking if CFEngine is bootstrapped...")
              bootstrapped = comm.test("test -f /var/cfengine/policy_server.dat", sudo: true)
              if bootstrapped && !config.force_bootstrap
                logger.info("CFEngine already bootstrapped, no need to do it again")
                return false
              end

              logger.info("CFEngine needs bootstrap.")
              return true
            end
          end
        end
      end
    end
  end
end