Class: Simp::Cli::Config::Item::LdapRootDn

Inherits:
Simp::Cli::Config::Item show all
Defined in:
lib/simp/cli/config/item/ldap_root_dn.rb

Instance Attribute Summary

Attributes inherited from Simp::Cli::Config::Item

#allow_user_apply, #config_items, #description, #die_on_apply_fail, #fact, #fail_on_missing_answer, #key, #next_items_tree, #silent, #skip_apply, #skip_query, #skip_yaml, #value

Instance Method Summary collapse

Methods inherited from Simp::Cli::Config::Item

#apply, #default_value, #highline_question_type, #next_items, #not_valid_message, #print_banner, #print_summary, #puppet_value, #query, #query_ask, #query_extras, #query_status, #safe_apply, #say_blue, #say_green, #say_red, #say_yellow, #to_yaml_s

Constructor Details

#initializeLdapRootDn

Returns a new instance of LdapRootDn.



9
10
11
12
13
14
# File 'lib/simp/cli/config/item/ldap_root_dn.rb', line 9

def initialize
  super
  @key         = 'ldap::root_dn'
  @description = %Q{The LDAP root DN.}

end

Instance Method Details

#os_valueObject



17
18
19
20
21
22
23
24
25
# File 'lib/simp/cli/config/item/ldap_root_dn.rb', line 17

def os_value
  # TODO: turn into custom fact?
  result = nil
  if File.readable?('/etc/openldap/ldap.conf') &&
    `grep rootdn /etc/openldap/slapd.conf` =~ /\Arootdn\s+[\"](.*)[\"]\s*/
    result = $1
  end
  result
end


34
35
36
# File 'lib/simp/cli/config/item/ldap_root_dn.rb', line 34

def recommended_value
  "cn=LDAPAdmin,ou=People,%{hiera('ldap::base_dn')}"
end

#validate(x) ⇒ Object



38
39
40
# File 'lib/simp/cli/config/item/ldap_root_dn.rb', line 38

def validate( x )
  (x.to_s =~ /^cn=/) ? true : false
end