<commit_before>module Vagrant
  module Provisioners

  class PuppetError < Vagrant::Errors::VagrantError
    error_namespace("vagrant.provisioners.puppet")
  end

  class PuppetConfig < Vagrant::Config::Base
    configures :puppet

    attr_accessor :manifest_file
    attr_accessor :manifests_path
    attr_accessor :pp_path
    attr_accessor :options

    def initialize
      @manifest_file = ""
      @manifests_path = "manifests"
      @pp_path = "/tmp/vagrant-puppet"
      @options = []
    end
  end

  class Puppet < Base

    def prepare
      check_manifest_dir
      share_manifests
    end

    def provision!
      verify_binary("puppet")
      create_pp_path
      set_manifest
      run_puppet_client
    end

    def check_manifest_dir
      Dir.mkdir(env.config.puppet.manifests_path) unless File.directory?(env.config.puppet.manifests_path)
    end

    def share_manifests
      env.config.vm.share_folder("manifests", env.config.puppet.pp_path, env.config.puppet.manifests_path)
    end

    def verify_binary(binary)
      vm.ssh.execute do |ssh|
        ssh.exec!("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
      end
    end

    def create_pp_path
      vm.ssh.execute do |ssh|
        ssh.exec!("sudo mkdir -p #{env.config.puppet.pp_path}")
        ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.puppet.pp_path}")
      end
    end

    def set_manifest
      @manifest = !env.config.puppet.manifest_file.empty? ? env.config.puppet.manifest_file : "#{env.config.vm.box}.pp"

      if File.exists?("#{env.config.puppet.manifests_path}/#{@manifest}")
         env.ui.info I18n.t("vagrant.provisioners.puppet.manifest_to_run", :manifest => @manifest)
         return @manifest
       else
         raise PuppetError, :_key => :manifest_missing, :manifest => @manifest
      end
    end

    def run_puppet_client
      options = env.config.puppet.options
      options = options.join(" ") if options.is_a?(Array)
      command = "cd #{env.config.puppet.pp_path} && sudo -E puppet #{options} #{@manifest}"

      env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet")

      vm.ssh.execute do |ssh|
        ssh.exec!(command) do |channel, type, data|
          ssh.check_exit_status(data, command) if type == :exit_status
          env.ui.info("#{data}: #{type}") if type != :exit_status
        end
      end
    end

  end
 end
end<commit_msg>Whitespace changes<commit_after>module Vagrant
  module Provisioners

  class PuppetError < Vagrant::Errors::VagrantError
    error_namespace("vagrant.provisioners.puppet")
  end

  class PuppetConfig < Vagrant::Config::Base
    configures :puppet

    attr_accessor :manifest_file
    attr_accessor :manifests_path
    attr_accessor :pp_path
    attr_accessor :options

    def initialize
      @manifest_file = ""
      @manifests_path = "manifests"
      @pp_path = "/tmp/vagrant-puppet"
      @options = []
    end
  end

  class Puppet < Base
    def prepare
      check_manifest_dir
      share_manifests
    end

    def provision!
      verify_binary("puppet")
      create_pp_path
      set_manifest
      run_puppet_client
    end

    def check_manifest_dir
      Dir.mkdir(env.config.puppet.manifests_path) unless File.directory?(env.config.puppet.manifests_path)
    end

    def share_manifests
      env.config.vm.share_folder("manifests", env.config.puppet.pp_path, env.config.puppet.manifests_path)
    end

    def verify_binary(binary)
      vm.ssh.execute do |ssh|
        ssh.exec!("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
      end
    end

    def create_pp_path
      vm.ssh.execute do |ssh|
        ssh.exec!("sudo mkdir -p #{env.config.puppet.pp_path}")
        ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.puppet.pp_path}")
      end
    end

    def set_manifest
      @manifest = !env.config.puppet.manifest_file.empty? ? env.config.puppet.manifest_file : "#{env.config.vm.box}.pp"

      if File.exists?("#{env.config.puppet.manifests_path}/#{@manifest}")
         env.ui.info I18n.t("vagrant.provisioners.puppet.manifest_to_run", :manifest => @manifest)
         return @manifest
       else
         raise PuppetError, :_key => :manifest_missing, :manifest => @manifest
      end
    end

    def run_puppet_client
      options = env.config.puppet.options
      options = options.join(" ") if options.is_a?(Array)
      command = "cd #{env.config.puppet.pp_path} && sudo -E puppet #{options} #{@manifest}"

      env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet")

      vm.ssh.execute do |ssh|
        ssh.exec!(command) do |channel, type, data|
          ssh.check_exit_status(data, command) if type == :exit_status
          env.ui.info("#{data}: #{type}") if type != :exit_status
        end
      end
    end
  end
 end
end
{'fraction_non_alphanumeric': 0.11562819203268641, 'fraction_numerical': 0.001634320735444331, 'mean_word_length': 2.8734177215189876, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '953963', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1665, 'n_words': 308}