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

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/provisioner/ansible/os.rb,
lib/kitchen/provisioner/ansible/os/suse.rb,
lib/kitchen/provisioner/ansible/os/alpine.rb,
lib/kitchen/provisioner/ansible/os/amazon.rb,
lib/kitchen/provisioner/ansible/os/darwin.rb,
lib/kitchen/provisioner/ansible/os/debian.rb,
lib/kitchen/provisioner/ansible/os/fedora.rb,
lib/kitchen/provisioner/ansible/os/redhat.rb,
lib/kitchen/provisioner/ansible/os/freebsd.rb,
lib/kitchen/provisioner/ansible/os/openbsd.rb

Direct Known Subclasses

Alpine, Darwin, Debian, Fedora, Freebsd, Openbsd, Redhat, Suse

Defined Under Namespace

Classes: Alpine, Amazon, Darwin, Debian, Fedora, Freebsd, Openbsd, Redhat, Suse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config) ⇒ Os

Returns a new instance of Os.



37
38
39
40
# File 'lib/kitchen/provisioner/ansible/os.rb', line 37

def initialize(name, config)
  @config = config
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



35
36
37
# File 'lib/kitchen/provisioner/ansible/os.rb', line 35

def name
  @name
end

Class Method Details

.make(platform, config) ⇒ Object



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
# File 'lib/kitchen/provisioner/ansible/os.rb', line 42

def self.make(platform, config)
  return nil if platform == ''

  case platform
  when 'debian', 'ubuntu'
    return Debian.new(platform, config)
  when 'redhat', 'centos'
    return Redhat.new(platform, config)
  when 'fedora'
    return Fedora.new(platform, config)
  when 'amazon'
    return Amazon.new(platform, config)
  when 'suse', 'opensuse', 'sles'
    return Suse.new(platform, config)
  when 'darwin', 'mac', 'macos', 'macosx'
    return Darwin.new(platform, config)
  when 'alpine'
    return Alpine.new(platform, config)
  when 'openbsd'
    return Openbsd.new(platform, config)
  when 'freebsd'
    return Freebsd.new(platform, config)
  end

  nil
end

Instance Method Details

#sudo(script) ⇒ Object



78
79
80
# File 'lib/kitchen/provisioner/ansible/os.rb', line 78

def sudo(script)
  @config[:sudo] ? "#{@config[:sudo_command]} #{script}" : script
end

#sudo_env(pm) ⇒ Object

Helpers



70
71
72
73
74
75
# File 'lib/kitchen/provisioner/ansible/os.rb', line 70

def sudo_env(pm)
  s = @config[:https_proxy] ? "https_proxy=#{@config[:https_proxy]}" : nil
  p = @config[:http_proxy] ? "http_proxy=#{@config[:http_proxy]}" : nil
  n = @config[:no_proxy] ? "no_proxy=#{@config[:no_proxy]}" : nil
  p || s ? "#{sudo('env')} #{p} #{s} #{n} #{pm}" : "#{sudo(pm)}"
end