Class: MintPress::Infrastructure::Host
- Inherits:
-
Object
- Object
- MintPress::Infrastructure::Host
- Defined in:
- src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb,
src/mintpress-resources/lib/mintpress-resources/resource.rb,
src/mintpress-resources/lib/mintpress-resources/host_interface.rb,
src/mintpress-utils/lib/mintpress-utils/instance.rb
Overview
Direct Known Subclasses
Aws::EC2::Instance, Aws::Lightsail::Instance, ContainerHost, LocalHost, VMHost
Properties (Read/Write)
-
#name ⇒ String
The name of this resource
Property Attributes37
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 37 property :name, type: String
-
#hostname ⇒ String (Default Value: Proc.new { r = self.name.split('.')[0] ; r = nil if r == ''; r })
The hostname of the box _without_ the DNS domain name - note that individual network interfaces can have different hostnames!
Property Attributes- default ⇒ Proc.new { r = self.name.split('.')[0] ; r = nil if r == ''; r }
40
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 40 property :hostname, type: String, default: Proc.new { r = self.name.split('.')[0] ; r = nil if r == ''; r }
-
#dns_domain ⇒ String (Default Value: Proc.new { r = self.name.split('.')[1..-1].join('.') ; r = nil if r == '.' ; r })
Just the DNS domain name of the box - again, individual network interfaces _can_ override this!
Property Attributes- default ⇒ Proc.new { r = self.name.split('.')[1..-1].join('.') ; r = nil if r == '.' ; r }
42
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 42 property :dns_domain, type: String, default: Proc.new { r = self.name.split('.')[1..-1].join('.') ; r = nil if r == '.' ; r }
-
#max_connections ⇒ Integer
How many connections, at most, do we allow to this host?
Property Attributes49
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 49 property :max_connections, type: Integer
-
#max_connections_per_second ⇒ Float
How many connections per second, at most, do we allow to this host? This internally defaults to 1.0
Property Attributes52
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 52 property :max_connections_per_second, type: Float
-
#affinity_group ⇒ String (Default Value: Proc.new{self.hostname.gsub(/[0-9]/,'').split('.')[0].split('-')[0]})
Create, by default, an affinity group with no number - note that some infra types don't support named affinity groups, and so this won't work in those cases, and it will always use the node ID in that case
Property Attributes- default ⇒ Proc.new{self.hostname.gsub(/[0-9]/,'').split('.')[0].split('-')[0]}
56
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 56 property :affinity_group, type: String, default: Proc.new{self.hostname.gsub(/[0-9]/,'').split('.')[0].split('-')[0]}
-
#strict_anti_affinity ⇒ [TrueClass, FalseClass] (Default Value: false)
Do we strictly enforce anti-affinity, or is it just advisory. Note that if you don't have enough nodes or availability zones to seperate all of your resources, setting this to true _will_ result in failures!
Property Attributes- default ⇒ false
60
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 60 property :strict_anti_affinity, type: [TrueClass, FalseClass], default: false
-
#host_number ⇒ Integer (Default Value: Proc.new { self.hostname.split('.')[0].split('-')[0].tr("^0-9",'').to_i })
The numeric ID of this host within an affinity group - this is derived, by default, from the host number. Implementations that have "full" access to the system should convert this back to their own set, so things can be enforced...
Property Attributes- default ⇒ Proc.new { self.hostname.split('.')[0].split('-')[0].tr("^0-9",'').to_i }
63
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 63 property :host_number, type: Integer, default: Proc.new { self.hostname.split('.')[0].split('-')[0].tr("^0-9",'').to_i }
-
#connect_address ⇒ String (Default Value: Proc.new { self.fqdn })
This one should be overridden by children - usually we'll get a useful IP from our provider. Failing that, potentially it should come from network_interfaces if they exist! This might be replaced by an action function at some point, though it'll always be through a prop so that it's overridable
Property Attributes- default ⇒ Proc.new { self.fqdn }
68
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 68 property :connect_address, type: String, default: Proc.new { self.fqdn }
-
#mounts ⇒ Hash of ⇒ MintPress::Infrastructure::MountPoint
Shares such as NasShare/CifsShare are children of this, so we don't have to repeat ourselves!
Property Attributes71
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 71 property :mounts, type: MintPress::Infrastructure::MountPoint, hash: true
-
#network_interfaces ⇒ Hash of ⇒ MintPress::Infrastructure::NetworkInterface
Network interfaces to be attached to this host
Property Attributes74
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 74 property :network_interfaces, type: MintPress::Infrastructure::NetworkInterface, hash: true
-
#interfaces ⇒ Hash of ⇒ MintPress::Infrastructure::HostInterface
"The list of interfaces on the host."
Property Attributes77
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 77 property :interfaces, type: MintPress::Infrastructure::HostInterface, hash: true, description: "The list of interfaces on the host."
-
#block_devices ⇒ Hash of ⇒ MintPress::Infrastructure::BlockDevice
Which block devcies should be attached to this virtual machine. Block devices are generally either attached disks, FC luns, or iscsi
Property Attributes- canonical ⇒ true
80
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 80 property :block_devices, type: MintPress::Infrastructure::BlockDevice, hash: true, canonical: true
-
#nas_shares ⇒ Hash of ⇒ MintPress::Infrastructure::NasShare
Which NAS shares should be attached to this system? NAS shares can be either NFS or CIFS shares
Property Attributes- canonical ⇒ true
82
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 82 property :nas_shares, type: MintPress::Infrastructure::NasShare, hash: true, canonical: true
-
#admin_connect_user ⇒ String
Which user should be used to connect as an administrive user. Different providers will default this differnetly - for example, ec2-user for AWS.
Property Attributes85
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 85 property :admin_connect_user, type: String
-
#admin_final_user ⇒ String
The final user for admin will almost always be root, but you _could_ change it for a particularly weird environment
Property Attributes87
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 87 property :admin_final_user, type: String
-
#admin_keys ⇒ Array of ⇒ String (Default Value: Proc.new { self.keys })
SSH keys for connecting as an administrative user (these have an in-code default of [ "~/.ssh/id_rsa","~/.ssh/id_dsa" ])
Property Attributes- default ⇒ Proc.new { self.keys }
90
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 90 property :admin_keys, type: String, array: true, default: Proc.new { self.keys }
-
#admin_password ⇒ String
Password for connecting as an administrtive user
Property Attributes92
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 92 property :admin_password, type: String
-
#admin_key_data ⇒ String (Default Value: Proc.new { self.key_data })
SSH key data (ie the actual contents of the key file) as an administrative user
Property Attributes- default ⇒ Proc.new { self.key_data }
94
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 94 property :admin_key_data, type: String, default: Proc.new { self.key_data }
-
#environment_variables ⇒ Hash of ⇒ String
Environment variables to set on the unprivleged transport
Property Attributes97
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 97 property :environment_variables, type: String, hash: true
-
#admin_environment_variables ⇒ Hash of ⇒ String
Environment variables to set on the privleged transport
Property Attributes100
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 100 property :admin_environment_variables, type: String, hash: true
-
#never_transform ⇒ [TrueClass, FalseClass] (Default Value: false)
Disable using the connection proxy server? This can be required on certain systems that don't support our ruby, such as EL5 systems, but generally should be avoided
Property Attributes- default ⇒ false
104
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 104 property :never_transform, type: [TrueClass, FalseClass], default: false
-
#os_family ⇒ String (Default Value: Proc.new { self.detect_os_family })
Some details about the OS
Property Attributes- default ⇒ Proc.new { self.detect_os_family }
107
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 107 property :os_family, type: String, default: Proc.new { self.detect_os_family }
-
#os_release ⇒ Hash (Default Value: Proc.new { self.detect_os_release })
Some details about the OS Release
Property Attributes- default ⇒ Proc.new { self.detect_os_release }
110
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 110 property :os_release, type: Hash, default: Proc.new { self.detect_os_release }
-
#os_arch ⇒ String (Default Value: Proc.new { self.detect_os_arch })
Some details about the OS Architecture
Property Attributes- default ⇒ Proc.new { self.detect_os_arch }
113
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 113 property :os_arch, type: String, default: Proc.new { self.detect_os_arch }
-
#os_cpu_count ⇒ Integer (Default Value: Proc.new { self.detect_os_cpu_count })
Some details about the OS CPU Count
Property Attributes- default ⇒ Proc.new { self.detect_os_cpu_count }
116
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 116 property :os_cpu_count, type: Integer, default: Proc.new { self.detect_os_cpu_count }
-
#os_memory_total ⇒ Integer (Default Value: Proc.new { self.detect_os_memory_total })
Some details about the OS Memory Total
Property Attributes- default ⇒ Proc.new { self.detect_os_memory_total }
119
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 119 property :os_memory_total, type: Integer, default: Proc.new { self.detect_os_memory_total }
-
#os_swap_total ⇒ Integer (Default Value: Proc.new { self.detect_os_swap_total })
Some details about the OS Swap Total
Property Attributes- default ⇒ Proc.new { self.detect_os_swap_total }
122
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 122 property :os_swap_total, type: Integer, default: Proc.new { self.detect_os_swap_total }
-
#connect_user ⇒ String
Which user should be used to connect as an ordinary user. Different providers will default this differnetly - for example, ec2-user for AWS.
Property Attributes125
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 125 property :connect_user, type: String
-
#final_user ⇒ String
Which user should we finally end up as, either by being the same as connect_user, or via sudo/su. It is possible to leave both this and connect user black, in which case you will have a host which is not contactable via SSH, but can still be contacted via an external means (docker transport, for example, does not require a user)
Property Attributes129
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 129 property :final_user, type: String
-
#keys ⇒ Array of ⇒ String
SSH keys to connect (these have an in-code default of [ "~/.ssh/id_rsa","~/.ssh/id_dsa" ])
Property Attributes131
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 131 property :keys, type: String, array: true
-
#password ⇒ String
Password to use to authenticate the user
Property Attributes133
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 133 property :password, type: String
-
#key_data ⇒ String
SSH key data (ie the actual contents of the key file)
Property Attributes135
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 135 property :key_data, type: String
-
#protocol ⇒ String (Default Value: Proc.new { r=nil
if self.name.to_s == 'local'
r='local'
else
r='ssh'
end
r })
These would generally be overriden by children as well - sensible options are 'ssh','winrm','httprpc','docker', and 'local'.
Property Attributes- default ⇒ Proc.new { r=nil if self.name.to_s == 'local' r='local' else r='ssh' end r }
139 140 141 142 143 144 145
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 139 property :protocol, type: String, default: Proc.new { r=nil if self.name.to_s == 'local' r='local' else r='ssh' end r }
-
#user_switch_type ⇒ String
Which user switch type should be used - the options for this depend on your protocol, however usually "sudo", "su", and "direct" are the sensible options. Generally this will default to something sane.
Property Attributes148
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 148 property :user_switch_type, type: String
-
#connect_port ⇒ Integer
The port on which to connect - default is 22 for ssh, and 443 for HTTP/RPC, and nil for local
Property Attributes150
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 150 property :connect_port, type: Integer
-
#jump_host ⇒ MintPress::Infrastructure::Host
What jump box is required to access this? This will be used via add_hop in las-rpc-utils
Property Attributes153
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 153 property :jump_host, type: MintPress::Infrastructure::Host
-
#temp_folder ⇒ String (Default Value: Proc.new { self.guess_tmp_folder })
a temporary folder on the remote system. If this is nil, it'll try and work one out
Property Attributes- default ⇒ Proc.new { self.guess_tmp_folder }
- cached_proc ⇒ true
156
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 156 property :temp_folder, type: String, default: Proc.new { self.guess_tmp_folder }, cached_proc: true
-
#factory ⇒ MintPress::Infrastructure::TransportFactory (Default Value: Proc.new {
$mintpress_transport_factory = MintPress::Infrastructure::TransportFactory.new if $mintpress_transport_factory.nil?
$mintpress_transport_factory
})
Use a non-default transport factory (See the TransportFactory resource for details)
Property Attributes- default ⇒ Proc.new { $mintpress_transport_factory = MintPress::Infrastructure::TransportFactory.new if $mintpress_transport_factory.nil? $mintpress_transport_factory }
159 160 161 162
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 159 property :factory, type: MintPress::Infrastructure::TransportFactory, default: Proc.new { $mintpress_transport_factory = MintPress::Infrastructure::TransportFactory.new if $mintpress_transport_factory.nil? $mintpress_transport_factory }
-
#bootstrapper ⇒ Array of ⇒ MintPress::Infrastructure::Bootstrapper (Default Value: MintPress::Infrastructure::Bootstrapper.new(host: self))
Which bootstrap provider to use for creating new hosts
Property Attributes- default ⇒ MintPress::Infrastructure::Bootstrapper.new(host: self)
- canonical ⇒ true
165
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 165 property :bootstrapper, type: MintPress::Infrastructure::Bootstrapper, default: MintPress::Infrastructure::Bootstrapper.new(host: self), canonical: true, array: true
-
#always_use_mintpress_bootstrap ⇒ [TrueClass, FalseClass] (Default Value: true)
Should we always use the mintpress internal bootstrap provider, even when anotehr is seperately specified? This defaults to 'true', since usually you need things like disks formatted and so forth before calling out to a chef, puppet, ansible, or salt - but if your provider does handle everything you need, you are free to disable this.
Property Attributes- default ⇒ true
169
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 169 property :always_use_mintpress_bootstrap, type: [TrueClass, FalseClass], default: true
-
#bootstrap_with_dns ⇒ [TrueClass, FalseClass] (Default Value: false)
Should we create DNS entries?
Property Attributes- default ⇒ false
171
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 171 property :bootstrap_with_dns, type: [TrueClass, FalseClass], default: false
-
#bootstrap_dns_provider ⇒ String
Which DNS provider should we use for creating DNS entries?
Property Attributes173
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 173 property :bootstrap_dns_provider, type: String
-
#public_postfix ⇒ String
Public postfix if no network interfaces are defined.
Property Attributes183
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 183 property :public_postfix, type: String
-
#private_postfix ⇒ String
Private postfix if no network interfaces are defined.
Property Attributes185
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 185 property :private_postfix, type: String
Properties (Read Only)
-
#fqdn ⇒ String (Default Value: Proc.new { r = [self.hostname, self.dns_domain].join('.').gsub(/\.$/,'') ; r = nil if r=='.' or r=='' ; r })
The FQDN of the box. This is set to read_only since it should be formed by hostname/dns_domain, which also defaults from a FQDN name variable.
Property Attributes- default ⇒ Proc.new { r = [self.hostname, self.dns_domain].join('.').gsub(/\.$/,'') ; r = nil if r=='.' or r=='' ; r }
- read_only ⇒ true
46
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 46 property :fqdn, type: String, default: Proc.new { r = [self.hostname, self.dns_domain].join('.').gsub(/\.$/,'') ; r = nil if r=='.' or r=='' ; r }, read_only: true
-
#implemented_providers ⇒ Array of ⇒ String
'List of infrastructure providers that this class can work with'
Property Attributes- read_only ⇒ true
176
# File 'src/mintpress-infrastructure/lib/mintpress-infrastructure/host.rb', line 176 property :implemented_providers, type: String, array: true, read_only: true, description: 'List of infrastructure providers that this class can work with'
Constant Summary
Constants included from MintLogger
MintLogger::DEBUG, MintLogger::ERROR, MintLogger::FATAL, MintLogger::INFO, MintLogger::UNKNOWN, MintLogger::VERBOSE, MintLogger::WARN
Instance Attribute Summary
Attributes included from Mixins::Properties
#autopush_set_cache, #dynamic_create, #harvest_on_access, #harvest_undefined_only, #harvested, #tree_root
Instance Method Summary collapse
-
#admin_transport ⇒ Object
Retrive the privledged transport for this host.
- #background_bootstrap ⇒ Object
- #background_create ⇒ Object
- #background_destroy ⇒ Object
- #background_force_bootstrap ⇒ Object
- #background_unbootstrap ⇒ Object
- #bootstrap ⇒ Object
-
#create ⇒ Object
Create our children - other providers will implement creators for the actual machine.
- #create_admin_transport ⇒ Object
-
#create_default_network_interface ⇒ Object
Function to create a default network interface if one does not exist.
-
#create_transport ⇒ Object
We use transport factory for these, so that we can not constnatly create connections! Since the factory _can_ contain users, lets just let it through for now and let the other side sort it out....
-
#destroy ⇒ Object
Destroy our chidren - other providers will implement destroyers for the actual machine.
- #detect_os_arch ⇒ Object
- #detect_os_cpu_count ⇒ Object
-
#detect_os_family ⇒ Object
One day, this will be our own implementation.
- #detect_os_memory_total ⇒ Object
- #detect_os_release ⇒ Object
- #detect_os_swap_total ⇒ Object
-
#dns_propagated? ⇒ Boolean
This returns true/false if DNS propagation has happened yet.
- #force_bootstrap ⇒ Object
-
#get_local_ip(remote_addr) ⇒ Object
FIXME: this function should consider routes as well...
- #guess_primary_ip ⇒ Object
-
#guess_tmp_folder ⇒ Object
Determine location of the temp folder (a) get this from the factory (b) get it from the host (c) default to /tmp.
-
#initialize(opts = {}) ⇒ Host
constructor
A new instance of Host.
- #restart ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
-
#transport ⇒ Object
Retrieve the unpriv transport for this host.
- #transport_options(connect_user, final_user, keys, password, key_data, is_admin: false) ⇒ Object
- #unbootstrap ⇒ Object
- #uncreatable?(opts = nil) ⇒ Boolean
- #wait_for_connectable(ip_list, port, timeout = 300, oneshot: false) ⇒ Object
-
#wait_for_dns ⇒ Object
This function will block until all generated DNS has propagated for this host - it's the equivalent of setting `validate_propagated` on your DNS provider, but allows for more fine grained control as to how this occours - the reason you would want to do that, is the actual transport object this class provides _does not care_ if DNS is correct or not for most machine providers, since it gets the IP list from the cloud/vm/container/machine provider directly - so you can do your installs, and only wait for DNS propagation when it comes time to integrate the pieces.
- #wait_for_transport(admin: false) ⇒ Object
Methods included from Mixins::GenericProvider
included, #register_provider, #register_sub_provider
Methods included from MintLogger::Utils::Common
#boolean_val, #has_value?, #no_value?, #nvl, #path_as_symbol, #ruby_level_to_send
Methods included from Mixins::Backgroundable
#backgroundable, #wait_for_background_tasks
Methods included from Mixins::Properties
#[], #[]=, #add_validate_report_result, #armour_set_property, #array_contains?, #array_is_a?, #check_autopush, #check_stack_overflow, #clone_property_object, #cloner_handle_single_property, #coerce_single, #contains_as_string?, #display_validate_report_result, #double_initialize?, #dump_to_hash, #find_parent, #find_parent_by_identity, #generate_accessor_functions, #get_canonical_renamed, #get_from_opts, #get_my_name, #get_property, #get_property_item, #has?, included, #initialize_validate_report, #inspect, #is_cloned_object?, #is_mintpress_object?, #is_probably_canonical?, #is_set?, #local_debug, #local_info, #local_verbose, #mintpress_property_definitions, #place_object_by_identity, #process_properties, #prop_set?, #property, #property_definitions, #property_details, #property_is_simple_object?, #push_root!, #require_property, #require_update, #retrieve_docstring, #sanitize, #set_map_dirty, #set_property, #set_property_item, #show_short_array, #strip_defaults!, #synchronize, #uncloned_property_definitions, #update_map, #validate, #validate_generic, #validate_properties, #validate_property, #validate_required, #version_allowed?, #weakref