Class: Simp::Cli::Config::Item::RsyncServer
- Inherits:
-
Simp::Cli::Config::Item
- Object
- Simp::Cli::Config::Item
- Simp::Cli::Config::Item::RsyncServer
- Defined in:
- lib/simp/cli/config/item/rsync_server.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
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 ⇒ RsyncServer
constructor
A new instance of RsyncServer.
- #os_value ⇒ Object
- #recommended_value ⇒ Object
- #validate(item) ⇒ 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 ⇒ RsyncServer
Returns a new instance of RsyncServer.
10 11 12 13 14 15 16 17 |
# File 'lib/simp/cli/config/item/rsync_server.rb', line 10 def initialize super @key = 'rsync::server' @description = 'rsync server (usually the primary puppet master)' @__warning = false @file = '/etc/rsyncd.conf' @skip_query = true end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
9 10 11 |
# File 'lib/simp/cli/config/item/rsync_server.rb', line 9 def file @file end |
Instance Method Details
#os_value ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/simp/cli/config/item/rsync_server.rb', line 19 def os_value if File.readable?(@file) res = File.readlines(@file).grep( /address\s*=/ ){|x| x.split('=').last.strip} res.empty? ? nil : res.first else # only show the FIRST warning if !@__warning warning = "WARNING: cannot read #{file}" say "<%= color(%q{#{warning}}, YELLOW) %>\n" unless @silent @__warning = true end nil end end |
#recommended_value ⇒ Object
34 35 36 |
# File 'lib/simp/cli/config/item/rsync_server.rb', line 34 def recommended_value os_value || '127.0.0.1' end |
#validate(item) ⇒ Object
38 39 40 41 42 |
# File 'lib/simp/cli/config/item/rsync_server.rb', line 38 def validate item ( Simp::Cli::Config::Utils.validate_ip( item ) || Simp::Cli::Config::Utils.validate_fqdn( item ) || Simp::Cli::Config::Utils.validate_hostname( item ) ) end |