Class: Kitchen::Provisioner::Ansible::Os::Redhat

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

Direct Known Subclasses

Amazon

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_package_nameObject



61
62
63
64
65
66
67
# File 'lib/kitchen/provisioner/ansible/os/redhat.rb', line 61

def ansible_package_name
  if @config[:ansible_package_name]
    "#{@config[:ansible_package_name]}#{ansible_package_version_suffix}"
  else
    "ansible#{ansible_package_version_suffix}"
  end
end

#ansible_package_version_suffixObject



51
52
53
54
55
56
57
58
59
# File 'lib/kitchen/provisioner/ansible/os/redhat.rb', line 51

def ansible_package_version_suffix
  return unless @config[:ansible_version] && @config[:ansible_version] != 'latest'

  if @config[:ansible_package_name]
    "-#{@config[:ansible_version]}"
  else
    "#{@config[:ansible_version][0..2]}-#{@config[:ansible_version]}"
  end
end

#install_commandObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kitchen/provisioner/ansible/os/redhat.rb', line 25

def install_command
  <<-INSTALL

  if [ ! $(which ansible) ]; then
  #{install_epel_repo}
  #{redhat_yum_repo}
  #{update_packages_command}
  EL_RELEASE=$(rpm -E %{rhel})

  if [ "${EL_RELEASE}" -lt 8 ]; then
    #{sudo_env('yum')} -y install #{ansible_package_name} libselinux-python git
  else
    #{sudo_env('yum')} -y install #{ansible_package_name} python3-libselinux git
  fi
  fi
  INSTALL
end

#install_epel_repoObject



47
48
49
# File 'lib/kitchen/provisioner/ansible/os/redhat.rb', line 47

def install_epel_repo
  @config[:enable_yum_epel] ? sudo_env('yum install epel-release -y') : nil
end

#redhat_yum_repoObject



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/kitchen/provisioner/ansible/os/redhat.rb', line 69

def redhat_yum_repo
  if @config[:ansible_yum_repo]
    <<-INSTALL
    #{sudo_env('rpm')} -ivh #{@config[:ansible_yum_repo]}
    INSTALL
  else
    <<-INSTALL
    if ! yum repolist epel | grep -q epel; then
      #{sudo_env('rpm')} -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-`rpm -E %dist | sed -n 's/.*el\\([0-9]\\).*/\\1/p'`.noarch.rpm
    fi
    INSTALL
  end
end

#update_packages_commandObject



43
44
45
# File 'lib/kitchen/provisioner/ansible/os/redhat.rb', line 43

def update_packages_command
  @config[:update_package_repos] ? "#{sudo_env('yum')} makecache" : nil
end