Class: Bolt::Target
- Inherits:
-
Object
- Object
- Bolt::Target
- Defined in:
- lib/bolt/target.rb
Instance Attribute Summary collapse
-
#inventory ⇒ Object
Returns the value of attribute inventory.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.from_asserted_args(uri = nil, name = nil, safe_name = nil, target_alias = nil, config = nil, facts = nil, vars = nil, features = nil, plugin_hooks = nil, resources = nil) ⇒ Object
TODO: Disallow any positional argument other than URI.
-
.from_asserted_hash(hash) ⇒ Object
Target.new from a plan initialized with a hash.
-
.from_hash(hash, inventory) ⇒ Object
Target.new from a data hash.
Instance Method Summary collapse
- #config ⇒ Object
- #detail ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #facts ⇒ Object
-
#feature_set ⇒ Object
Use feature_set internally to access set.
-
#features ⇒ Object
features returns an array to be compatible with plans.
- #hash ⇒ Object
- #host ⇒ Object
-
#initialize(name, inventory = nil) ⇒ Target
constructor
rubocop:enable Lint/UnusedMethodArgument.
- #inventory_target ⇒ Object
- #password ⇒ Object
- #plugin_hooks ⇒ Object
- #port ⇒ Object
- #protocol ⇒ Object
- #remote? ⇒ Boolean
- #resources ⇒ Object
- #safe_name ⇒ Object
-
#set_resource(resource) ⇒ Object
rubocop:disable Naming/AccessorMethodName.
- #target_alias ⇒ Object
-
#to_h ⇒ Object
rubocop:enable Naming/AccessorMethodName.
- #to_s ⇒ Object
- #transport ⇒ Object
- #transport_config ⇒ Object (also: #options)
- #uri ⇒ Object
- #user ⇒ Object
- #vars ⇒ Object
Constructor Details
#initialize(name, inventory = nil) ⇒ Target
rubocop:enable Lint/UnusedMethodArgument
40 41 42 43 |
# File 'lib/bolt/target.rb', line 40 def initialize(name, inventory = nil) @name = name @inventory = inventory end |
Instance Attribute Details
#inventory ⇒ Object
Returns the value of attribute inventory.
8 9 10 |
# File 'lib/bolt/target.rb', line 8 def inventory @inventory end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
126 127 128 |
# File 'lib/bolt/target.rb', line 126 def name @name end |
Class Method Details
.from_asserted_args(uri = nil, name = nil, safe_name = nil, target_alias = nil, config = nil, facts = nil, vars = nil, features = nil, plugin_hooks = nil, resources = nil) ⇒ Object
TODO: Disallow any positional argument other than URI. Target.new from a plan with just a uri. Puppet requires the arguments to this method to match (by name) the attributes defined on the datatype. rubocop:disable Lint/UnusedMethodArgument
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bolt/target.rb', line 26 def self.from_asserted_args(uri = nil, name = nil, safe_name = nil, target_alias = nil, config = nil, facts = nil, vars = nil, features = nil, plugin_hooks = nil, resources = nil) from_asserted_hash('uri' => uri) end |
.from_asserted_hash(hash) ⇒ Object
Target.new from a plan initialized with a hash
17 18 19 20 |
# File 'lib/bolt/target.rb', line 17 def self.from_asserted_hash(hash) inventory = Puppet.lookup(:bolt_inventory) from_hash(hash, inventory) end |
.from_hash(hash, inventory) ⇒ Object
Target.new from a data hash
11 12 13 14 |
# File 'lib/bolt/target.rb', line 11 def self.from_hash(hash, inventory) target = inventory.create_target_from_hash(hash) new(target.name, inventory) end |
Instance Method Details
#config ⇒ Object
67 68 69 |
# File 'lib/bolt/target.rb', line 67 def config inventory_target.config end |
#detail ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/bolt/target.rb', line 101 def detail { 'name' => name, 'uri' => uri, 'alias' => target_alias, 'config' => { 'transport' => transport, transport => .to_h }, 'vars' => vars, 'features' => features, 'facts' => facts, 'plugin_hooks' => plugin_hooks, 'groups' => @inventory.group_names_for(name) } end |
#eql?(other) ⇒ Boolean Also known as: ==
165 166 167 |
# File 'lib/bolt/target.rb', line 165 def eql?(other) self.class.equal?(other.class) && @name == other.name end |
#facts ⇒ Object
59 60 61 |
# File 'lib/bolt/target.rb', line 59 def facts @inventory.facts(self) end |
#feature_set ⇒ Object
Use feature_set internally to access set
51 52 53 |
# File 'lib/bolt/target.rb', line 51 def feature_set @inventory.features(self) end |
#features ⇒ Object
features returns an array to be compatible with plans
46 47 48 |
# File 'lib/bolt/target.rb', line 46 def features @inventory.features(self).to_a end |
#hash ⇒ Object
170 171 172 |
# File 'lib/bolt/target.rb', line 170 def hash @name.hash end |
#host ⇒ Object
122 123 124 |
# File 'lib/bolt/target.rb', line 122 def host inventory_target.host end |
#inventory_target ⇒ Object
118 119 120 |
# File 'lib/bolt/target.rb', line 118 def inventory_target @inventory.targets[@name] end |
#password ⇒ Object
157 158 159 |
# File 'lib/bolt/target.rb', line 157 def password inventory_target.password end |
#plugin_hooks ⇒ Object
161 162 163 |
# File 'lib/bolt/target.rb', line 161 def plugin_hooks inventory_target.plugin_hooks end |
#port ⇒ Object
136 137 138 |
# File 'lib/bolt/target.rb', line 136 def port inventory_target.port end |
#protocol ⇒ Object
149 150 151 |
# File 'lib/bolt/target.rb', line 149 def protocol inventory_target.protocol || inventory_target.transport end |
#remote? ⇒ Boolean
132 133 134 |
# File 'lib/bolt/target.rb', line 132 def remote? protocol == 'remote' end |
#resources ⇒ Object
79 80 81 |
# File 'lib/bolt/target.rb', line 79 def resources inventory_target.resources end |
#safe_name ⇒ Object
71 72 73 |
# File 'lib/bolt/target.rb', line 71 def safe_name inventory_target.safe_name end |
#set_resource(resource) ⇒ Object
rubocop:disable Naming/AccessorMethodName
84 85 86 |
# File 'lib/bolt/target.rb', line 84 def set_resource(resource) inventory_target.set_resource(resource) end |
#target_alias ⇒ Object
75 76 77 |
# File 'lib/bolt/target.rb', line 75 def target_alias inventory_target.target_alias end |
#to_h ⇒ Object
rubocop:enable Naming/AccessorMethodName
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/bolt/target.rb', line 89 def to_h .to_h.merge( 'name' => name, 'uri' => uri, 'protocol' => protocol, 'user' => user, 'password' => password, 'host' => host, 'port' => port ) end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/bolt/target.rb', line 63 def to_s safe_name end |
#transport ⇒ Object
140 141 142 |
# File 'lib/bolt/target.rb', line 140 def transport inventory_target.transport end |
#transport_config ⇒ Object Also known as: options
144 145 146 |
# File 'lib/bolt/target.rb', line 144 def transport_config inventory_target.transport_config.to_h end |
#uri ⇒ Object
128 129 130 |
# File 'lib/bolt/target.rb', line 128 def uri inventory_target.uri end |
#user ⇒ Object
153 154 155 |
# File 'lib/bolt/target.rb', line 153 def user inventory_target.user end |
#vars ⇒ Object
55 56 57 |
# File 'lib/bolt/target.rb', line 55 def vars @inventory.vars(self) end |