<commit_before>#
# Copyright (c) 2013, <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module VagrantPlugins
  module PuppetInstall
    module Action
      # @author <NAME> <<EMAIL>>
      #
      # This action installs Puppet packages at the desired version.
      class InstallPuppet

        ubuntu_codename = %x[lsb_release --codename | awk '{ print $2 }'].chomp
        APT_PACKAGE_FILE = "puppetlabs-release-lucid.deb"
        APT_PACKAGE_FILE_URL = "http://apt.puppetlabs.com/#{APT_PACKAGE_FILE}".freeze

        def initialize(app, env)
          @app = app
          # Config#finalize! SHOULD be called automatically
          env[:global_config].puppet_install.finalize!
        end

        def call(env)
          desired_puppet_version = env[:global_config].puppet_install.version

          unless desired_puppet_version.nil?
            env[:ui].info("Ensuring Puppet is installed at requested version of #{desired_puppet_version}.")
            if env[:installed_puppet_version] == desired_puppet_version
              env[:ui].info("Puppet #{desired_puppet_version} package is already installed...skipping installation.")
            else
              env[:ui].info("Puppet #{desired_puppet_version} package is not installed...installing now.")
              env[:ssh_run_command] = install_puppet_command(desired_puppet_version)
            end
          end

          @app.call(env)
        end

        private

        def install_puppet_command(version='*')
          <<-INSTALL_PUPPET
cd /tmp
if command -v wget &>/dev/null; then
  wget --quiet #{APT_PACKAGE_FILE_URL}
elif command -v curl &>/dev/null; then
  curl --location --remote-name #{APT_PACKAGE_FILE_URL}
else
  echo "Neither wget nor curl found. Please install one and try again." >&2
  exit 1
fi
sudo dpkg --install #{APT_PACKAGE_FILE}
sudo apt-get update --quiet
sudo apt-get install puppet-common=#{version}*
INSTALL_PUPPET
        end
      end
    end
  end
end<commit_msg>Adding 'assume yes' to puppet apt-get install<commit_after>#
# Copyright (c) 2013, <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module VagrantPlugins
  module PuppetInstall
    module Action
      # @author <NAME> <<EMAIL>>
      #
      # This action installs Puppet packages at the desired version.
      class InstallPuppet

        ubuntu_codename = %x[lsb_release --codename | awk '{ print $2 }'].chomp
        APT_PACKAGE_FILE = "puppetlabs-release-lucid.deb"
        APT_PACKAGE_FILE_URL = "http://apt.puppetlabs.com/#{APT_PACKAGE_FILE}".freeze

        def initialize(app, env)
          @app = app
          # Config#finalize! SHOULD be called automatically
          env[:global_config].puppet_install.finalize!
        end

        def call(env)
          desired_puppet_version = env[:global_config].puppet_install.version

          unless desired_puppet_version.nil?
            env[:ui].info("Ensuring Puppet is installed at requested version of #{desired_puppet_version}.")
            if env[:installed_puppet_version] == desired_puppet_version
              env[:ui].info("Puppet #{desired_puppet_version} package is already installed...skipping installation.")
            else
              env[:ui].info("Puppet #{desired_puppet_version} package is not installed...installing now.")
              env[:ssh_run_command] = install_puppet_command(desired_puppet_version)
            end
          end

          @app.call(env)
        end

        private

        def install_puppet_command(version='*')
          <<-INSTALL_PUPPET
cd /tmp
if command -v wget &>/dev/null; then
  wget --quiet #{APT_PACKAGE_FILE_URL}
elif command -v curl &>/dev/null; then
  curl --location --remote-name #{APT_PACKAGE_FILE_URL}
else
  echo "Neither wget nor curl found. Please install one and try again." >&2
  exit 1
fi
sudo dpkg --install #{APT_PACKAGE_FILE}
sudo apt-get update --quiet
sudo apt-get install puppet-common=#{version}* -y
INSTALL_PUPPET
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09202330721318062, 'fraction_numerical': 0.004420333534257585, 'mean_word_length': 2.9196850393700786, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5146543', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1477, 'n_words': 456}