Class: Kitchen::Provisioner::Ansible::Os::Debian

Inherits:
Kitchen::Provisioner::Ansible::Os show all
Defined in:
lib/kitchen/provisioner/ansible/os/debian.rb

Instance Attribute Summary

Attributes inherited from Kitchen::Provisioner::Ansible::Os

#name

Instance Method Summary collapse

Methods inherited from Kitchen::Provisioner::Ansible::Os

#initialize, make, #sudo, #sudo_env

Constructor Details

This class inherits a constructor from Kitchen::Provisioner::Ansible::Os

Instance Method Details

#ansible_debian_versionObject



29
30
31
32
33
34
35
# File 'lib/kitchen/provisioner/ansible/os/debian.rb', line 29

def ansible_debian_version
  if @config[:ansible_version] == 'latest' || @config[:ansible_version] == nil
    ''
  else
    "=#{@config[:ansible_version]}"
  end
end

#install_commandObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kitchen/provisioner/ansible/os/debian.rb', line 37

def install_command
  <<-INSTALL

  if [ ! $(which ansible) ]; then
    #{update_packages_command}

    ## 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
    #{sudo_env('apt-get')} -y install apt-utils git dirmngr

    ## Fix debconf tty warning messages
    export DEBIAN_FRONTEND=noninteractive

    if [ -f /etc/os-release ] && [ `grep 'ID=debian' /etc/os-release` ]; then
      #{sudo_env('echo')} "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list
      #{sudo_env('apt-key')} adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
    else
      ## 13.10, 14.04 include add-apt-repository in software-properties-common
      #{sudo_env('apt-get')} -y install software-properties-common

      ## 10.04, 12.04 include add-apt-repository in
      if [apt-cache pkgnames | grep -q 'python-software-properties']; then
         #{sudo_env('apt-get')} -y install python-software-properties
      fi

      ## 10.04 version of add-apt-repository doesn't accept --yes
      ## later versions require interaction from user, so we must specify --yes
      ## First try with -y flag, else if it fails, try without.
      ## "add-apt-repository: error: no such option: -y" is returned but is ok to ignore, we just retry
      #{sudo_env('add-apt-repository')} -y #{@config[:ansible_apt_repo]} || #{sudo_env('add-apt-repository')} #{@config[:ansible_apt_repo]}
    fi
    #{sudo_env('apt-get')} update
    #{sudo_env('apt-get')} -y install ansible#{ansible_debian_version}
  fi
  INSTALL
end

#update_packages_commandObject



25
26
27
# File 'lib/kitchen/provisioner/ansible/os/debian.rb', line 25

def update_packages_command
  @config[:update_package_repos] ? "#{sudo_env('apt-get')} update" : nil
end