Class: HttpdConfigmapGenerator::Base

Inherits:
Object
  • Object
show all
Includes:
Command, ConfigHelper, FileHelper, Kerberos, Network, Pam
Defined in:
lib/httpd_configmap_generator/base.rb,
lib/httpd_configmap_generator/base/pam.rb,
lib/httpd_configmap_generator/base/command.rb,
lib/httpd_configmap_generator/base/network.rb,
lib/httpd_configmap_generator/base/kerberos.rb,
lib/httpd_configmap_generator/base/file_helper.rb,
lib/httpd_configmap_generator/base/config_helper.rb

Direct Known Subclasses

ActiveDirectory, ConfigMap, Export, Ipa, Ldap, Oidc, Principal, Saml, Sssd, Update

Defined Under Namespace

Modules: Command, ConfigHelper, FileHelper, Kerberos, Network, Pam

Constant Summary collapse

APACHE_USER =
"apache".freeze
HTTP_KEYTAB =
"/etc/http.keytab".freeze
IPA_COMMAND =
"/usr/bin/ipa".freeze
KERBEROS_CONFIG_FILE =
"/etc/krb5.conf".freeze
LDAP_ATTRS =
{
  "mail"        => "REMOTE_USER_EMAIL",
  "givenname"   => "REMOTE_USER_FIRSTNAME",
  "sn"          => "REMOTE_USER_LASTNAME",
  "displayname" => "REMOTE_USER_FULLNAME",
  "domainname"  => "REMOTE_USER_DOMAIN"
}.freeze
PAM_CONFIG =
"/etc/pam.d/httpd-auth".freeze
SSSD_CONFIG =
"/etc/sssd/sssd.conf".freeze
TIMESTAMP_FORMAT =
"%Y%m%d_%H%M%S".freeze

Constants included from Network

Network::HOSTNAME_COMMAND

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Pam

#configure_pam

Methods included from Network

#domain, #domain_from_host, #fetch_network_file, #host_reachable?, #realm, #update_hostname

Methods included from Kerberos

#enable_kerberos_dns_lookups

Methods included from FileHelper

#cp_template, #create_target_directory, #delete_target_file, #file_binary?, #path_join, #rm_file, #template_directory

Methods included from ConfigHelper

#config_file_backup

Methods included from Command

#command_run, #command_run!, #log_command_error

Constructor Details

#initialize(opts = {}) ⇒ Base

Returns a new instance of Base.



38
39
40
41
# File 'lib/httpd_configmap_generator/base.rb', line 38

def initialize(opts = {})
  @opts = opts
  @realm = @domain = nil
end

Instance Attribute Details

#optsObject

Returns the value of attribute opts.



36
37
38
# File 'lib/httpd_configmap_generator/base.rb', line 36

def opts
  @opts
end

Instance Method Details

#debug_msg(msg) ⇒ Object



51
52
53
# File 'lib/httpd_configmap_generator/base.rb', line 51

def debug_msg(msg)
  STDOUT.puts(msg) if opts[:debug]
end

#err_msg(msg) ⇒ Object



43
44
45
# File 'lib/httpd_configmap_generator/base.rb', line 43

def err_msg(msg)
  STDERR.puts(msg)
end

#info_msg(msg) ⇒ Object



47
48
49
# File 'lib/httpd_configmap_generator/base.rb', line 47

def info_msg(msg)
  STDOUT.puts(msg)
end

#optional_optionsObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/httpd_configmap_generator/base.rb', line 61

def optional_options
  {
    :force => { :description => "Force configuration if configured already",
                :short       => "-f",
                :default     => false },
    :debug => { :description => "Enable debugging",
                :short       => "-d",
                :default     => false }
  }
end

#required_optionsObject



55
56
57
58
59
# File 'lib/httpd_configmap_generator/base.rb', line 55

def required_options
  {
    :output => { :description => "Configuration map file to create", :short => "-o" }
  }
end

#run_configure(opts) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'lib/httpd_configmap_generator/base.rb', line 72

def run_configure(opts)
  validate_options(opts)
  @opts = opts
  unconfigure if configured? && opts[:force]
  raise "#{self.class.name} Already Configured" if configured?
  unless ENV["HTTPD_AUTH_TYPE"]
    raise "Not running in httpd_configmap_generator container - Skipping #{self.class.name} configuration"
  end
  configure(opts)
end

#validate_options(_options) ⇒ Object



83
84
85
# File 'lib/httpd_configmap_generator/base.rb', line 83

def validate_options(_options)
  nil
end