class Kitchen::Yansible::Tools::Install::Debian

Public Instance Methods

alternatives_command() click to toggle source
# File lib/kitchen-yansible/tools/install/debian.rb, line 34
def alternatives_command
  "#{sudo('update-alternatives')}"
end
install_python() click to toggle source
# File lib/kitchen-yansible/tools/install/debian.rb, line 84
def install_python
  """
    installPython () {
      echo 'Checking Python installation.'
      #{command_exists('python')} || {
        echo 'Python is not installed, attempt to install via virtual packages.'
        #{install_package} python
        echo 'Checking for installed alternatives.'
        #{command_exists('python')} || {
          searchAlternatives 'python'
        }
      }
      #{command_exists('python')} || {
        echo \"===> Couldn't determine Python executable - exiting now! <===\"
        exit 1
      }
    }
  """
end
install_ruby() click to toggle source
# File lib/kitchen-yansible/tools/install/debian.rb, line 128
def install_ruby
  """
    installRuby () {
      echo 'Checking Ruby installation.'
      searchAlternatives 'ruby'
      #{command_exists('ruby')} || {
        RUBY_PACKAGE=$(apt-cache search ruby|grep '^ruby\\([0-9\\.]\\+\\)\\?\\s'|sort -r|head -n1|awk '{print $1}')
        RUBY_VERSION=$(echo ${RUBY_PACKAGE}|grep -o '\\([0-9\\.]\\+\\)')
        dpkg --compare-versions ${RUBY_VERSION} ge 2.2.0 || {
          echo 'Adding ppa:brightbox/ruby-ng'
          #{install_package} ca-certificates
          source /etc/os-release
          if [[ \"${VERSION_ID}\" = \"12.04\" ]]; then
            #{install_package} python-software-properties
          else
            #{install_package} software-properties-common
          fi
          #{sudo('apt-add-repository')} -y ppa:brightbox/ruby-ng
          if [[ \"${VERSION_ID}\" = \"8\" && \"${ID}\" = \"debian\" ]]; then
            #{sudo('sed')} -i 's/jessie/trusty/g' /etc/apt/sources.list.d/brightbox-ruby-ng-jessie.list
          fi
          #{update_cache}
          RUBY_PACKAGE=$(apt-cache search ruby|grep '^ruby\\([0-9\\.]\\+\\)\\?\\s'|sort -r|head -n1|awk '{print $1}')
          RUBY_VERSION=$(echo ${RUBY_PACKAGE}|grep -o '\\([0-9\\.]\\+\\)')
        }
        echo 'Rechecking available versions'
        RUBY_PACKAGE=$(apt-cache search ruby|grep '^ruby\\([0-9\\.]\\+\\)\\?\\s'|sort -r|head -n1|awk '{print $1}')
        RUBY_VERSION=$(echo ${RUBY_PACKAGE}|grep -o '\\([0-9\\.]\\+\\)')
        dpkg --compare-versions ${RUBY_VERSION} ge 2.2.0 || {
          echo \"===> Only ${RUBY_VERSION} which is less than 2.2.0 found. <===\"
          echo \"===> Couldn't find acceptable Ruby version - exiting now! <===\"
          exit 1
        }
        #{install_package} ${RUBY_PACKAGE}

        echo 'Checking for installed alternatives.'
        #{command_exists('ruby')} || {
          searchAlternatives 'ruby'
        }
        grep 'gem: --no-rdoc --no-ri -​-no-document' /etc/gemrc &> /dev/null || {
          #{sudo('echo')} 'gem: --no-rdoc --no-ri -​-no-document' | #{sudo('tee')} /etc/gemrc
        }
      }
      #{command_exists('ruby')} || {
        echo \"===> Couldn't determine Ruby executable - exiting now! <===\"
        exit 1
      }
      echo 'Install Busser'
      #{command_exists('gem')} || {
        #{install_package} rubygems
      }
      #{command_exists('rdoc')} || {
        #{install_package} rubygem-rdoc
      }
      #{sudo('gem')} list | grep busser || {
        #{sudo('gem')} install busser
      }
      test -d /opt/chef/embedded/bin || {
        #{sudo('mkdir')} -p /opt/chef/embedded/bin
      }
      echo 'Making links for Chef'
      for binary in ruby gem busser; do
        test -L /opt/chef/embedded/bin/${binary} || {
          #{sudo('ln')} -sf \"$(command -v ${binary})\" /opt/chef/embedded/bin/${binary}
        }
      done
    }
  """
end
install_virtualenv() click to toggle source
# File lib/kitchen-yansible/tools/install/debian.rb, line 104
def install_virtualenv
  """
    installVirtualenv () {
      echo 'Checking Virtualenv installation.'
      searchAlternatives 'virtualenv'
      #{command_exists('virtualenv')} || {
        echo 'Attempt to guess Virtualenv package.'
        venvPackage=python$(python -c 'import sys; print(\"\".join(map(str, sys.version_info[:#{python_version_size}])))')-virtualenv
        #{install_package} ${venvPackage}||#{install_package} python-virtualenv
        #{install_package} virtualenv

        echo 'Checking for installed alternatives.'
        #{command_exists('virtualenv')} || {
          searchAlternatives 'virtualenv'
        }
      }
      #{command_exists('virtualenv')} || {
        echo \"===> Couldn't install Virtualenv - exiting now! <===\"
        exit 1
      }
    }
  """
end
package_manager() click to toggle source
# File lib/kitchen-yansible/tools/install/debian.rb, line 26
def package_manager
  "#{sudo_env('apt-get')}"
end
preinstall_command() click to toggle source
# File lib/kitchen-yansible/tools/install/debian.rb, line 38
def preinstall_command
  """
    preInstall () {
      ## Fix debconf tty warning messages
      export DEBIAN_FRONTEND=noninteractive

      #{update_cache}

      ## https://github.com/neillturner/kitchen-ansible/blob/master/lib/kitchen/provisioner/ansible/os/debian.rb#L43
      ## Install apt-utils to silence debconf warning: http://serverfault.com/q/358943/77156
      ## Install dirmngr to handle GPG key management for stretch,
      ## addressing https://github.com/neillturner/kitchen-ansible/issues/257
      #{install_package} apt-utils dirmngr

      source /etc/os-release
      if [[ \"${ID}\" = \"debian\" && \"${VERSION_ID}\" = \"7\" ]]; then
        echo 'Switching Debian Wheezy to archive repository'
        #{sudo('sed')}  -i -e \"s@deb.\\(debian.org\\)@archive.\\1@g;s@\\(.*updates\\)@#\\1@g\" /etc/apt/sources.list
        PIP_ARGS=\"-i https://pypi.python.org/simple/\"

        #{command_exists('ruby')} || {
          RUBY_VERSION=2.5.7
          echo '============================================================================================'
          echo \"Compiling Ruby ${RUBY_VERSION} because we need Ruby >= 2.2 for Busser\"
          echo \"Please consider custom docker image use with precompiled Ruby for speedup converge actions.\"
          echo '============================================================================================'
          sleep 10
          #{install_package} wget ca-certificates
          #{install_package} --force-yes libssl1.0.0=1.0.1e-2+deb7u20 \\
            libc6=2.13-38+deb7u10 \\
            libc-bin=2.13-38+deb7u10 \\
            zlib1g-dev libssl-dev libreadline-dev libgdbm-dev \\
            patch gcc make libreadline-dev
          mkdir -p /tmp/ruby && cd /tmp/ruby
          wget -qO- https://cache.ruby-lang.org/pub/ruby/$(echo ${RUBY_VERSION}|cut -c 1-3)/ruby-${RUBY_VERSION}.tar.gz|tar -xz \\
            && cd /tmp/ruby/ruby-${RUBY_VERSION}
          ./configure --disable-install-rdoc && make
          #{sudo('make')} install
          #{ruby_alternatives('/usr/bin', "/usr/local/bin")}
          rm -rf /tmp/ruby
        }
      fi
    }
  """
end
update_cache() click to toggle source
# File lib/kitchen-yansible/tools/install/debian.rb, line 30
def update_cache
  "#{package_manager} update"
end