Class: Simp::Cli::Config::Item::LdapBaseDn
- Inherits:
-
Simp::Cli::Config::Item
- Object
- Simp::Cli::Config::Item
- Simp::Cli::Config::Item::LdapBaseDn
- Defined in:
- lib/simp/cli/config/item/ldap_base_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
-
#initialize ⇒ LdapBaseDn
constructor
A new instance of LdapBaseDn.
- #os_value ⇒ Object
- #recommended_value ⇒ Object
- #validate(x) ⇒ Object
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
#initialize ⇒ LdapBaseDn
Returns a new instance of LdapBaseDn.
9 10 11 12 13 |
# File 'lib/simp/cli/config/item/ldap_base_dn.rb', line 9 def initialize super @key = 'ldap::base_dn' @description = %Q{The Base DN of the LDAP server} end |
Instance Method Details
#os_value ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/simp/cli/config/item/ldap_base_dn.rb', line 16 def os_value # TODO: turn into custom fact? result = nil if File.readable?('/etc/openldap/ldap.conf') && `grep BASE /etc/openldap/ldap.conf` =~ /^\s*BASE\s+(\S+)\s*/ result = $1 end result end |
#recommended_value ⇒ Object
27 28 29 30 31 |
# File 'lib/simp/cli/config/item/ldap_base_dn.rb', line 27 def recommended_value if item = @config_items.fetch( 'hostname', nil ) item.value.split('.')[1..-1].map{ |domain| "dc=#{domain}" }.join(',') end end |
#validate(x) ⇒ Object
34 35 36 |
# File 'lib/simp/cli/config/item/ldap_base_dn.rb', line 34 def validate( x ) (x.to_s =~ /^dc=/) ? true : false end |