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) ⇒ 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.
- #host ⇒ Object
-
#initialize(name, inventory = nil) ⇒ Target
constructor
rubocop:enable Lint/UnusedMethodArgument.
- #inventory_target ⇒ Object
- #options ⇒ Object
- #password ⇒ Object
- #plugin_hooks ⇒ Object
- #port ⇒ Object
- #protocol ⇒ Object
- #remote? ⇒ Boolean
- #safe_name ⇒ Object
- #target_alias ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
- #transport ⇒ Object
- #uri ⇒ Object
- #user ⇒ Object
- #vars ⇒ Object
Constructor Details
#initialize(name, inventory = nil) ⇒ Target
rubocop:enable Lint/UnusedMethodArgument
39 40 41 42 |
# File 'lib/bolt/target.rb', line 39 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.
111 112 113 |
# File 'lib/bolt/target.rb', line 111 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) ⇒ 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 |
# 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) 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
66 67 68 |
# File 'lib/bolt/target.rb', line 66 def config inventory_target.config end |
#detail ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/bolt/target.rb', line 90 def detail { 'name' => name, 'uri' => uri, 'alias' => target_alias, 'config' => Bolt::Util.deep_merge(config, 'transport' => transport, transport => ), 'vars' => vars, 'features' => features, 'facts' => facts, 'plugin_hooks' => plugin_hooks } end |
#eql?(other) ⇒ Boolean Also known as: ==
149 150 151 |
# File 'lib/bolt/target.rb', line 149 def eql?(other) self.class.equal?(other.class) && @name == other.name end |
#facts ⇒ Object
58 59 60 |
# File 'lib/bolt/target.rb', line 58 def facts @inventory.facts(self) end |
#feature_set ⇒ Object
Use feature_set internally to access set
50 51 52 |
# File 'lib/bolt/target.rb', line 50 def feature_set @inventory.features(self) end |
#features ⇒ Object
features returns an array to be compatible with plans
45 46 47 |
# File 'lib/bolt/target.rb', line 45 def features @inventory.features(self).to_a end |
#host ⇒ Object
107 108 109 |
# File 'lib/bolt/target.rb', line 107 def host inventory_target.host end |
#inventory_target ⇒ Object
103 104 105 |
# File 'lib/bolt/target.rb', line 103 def inventory_target @inventory.targets[@name] end |
#options ⇒ Object
141 142 143 |
# File 'lib/bolt/target.rb', line 141 def inventory_target. end |
#password ⇒ Object
137 138 139 |
# File 'lib/bolt/target.rb', line 137 def password inventory_target.password end |
#plugin_hooks ⇒ Object
145 146 147 |
# File 'lib/bolt/target.rb', line 145 def plugin_hooks inventory_target.plugin_hooks end |
#port ⇒ Object
121 122 123 |
# File 'lib/bolt/target.rb', line 121 def port inventory_target.port end |
#protocol ⇒ Object
129 130 131 |
# File 'lib/bolt/target.rb', line 129 def protocol inventory_target.protocol || inventory_target.transport end |
#remote? ⇒ Boolean
117 118 119 |
# File 'lib/bolt/target.rb', line 117 def remote? protocol == 'remote' end |
#safe_name ⇒ Object
70 71 72 |
# File 'lib/bolt/target.rb', line 70 def safe_name inventory_target.safe_name end |
#target_alias ⇒ Object
74 75 76 |
# File 'lib/bolt/target.rb', line 74 def target_alias inventory_target.target_alias end |
#to_h ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/bolt/target.rb', line 78 def to_h .merge( 'name' => name, 'uri' => uri, 'protocol' => protocol, 'user' => user, 'password' => password, 'host' => host, 'port' => port ) end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/bolt/target.rb', line 62 def to_s safe_name end |
#transport ⇒ Object
125 126 127 |
# File 'lib/bolt/target.rb', line 125 def transport inventory_target.transport end |
#uri ⇒ Object
113 114 115 |
# File 'lib/bolt/target.rb', line 113 def uri inventory_target.uri end |
#user ⇒ Object
133 134 135 |
# File 'lib/bolt/target.rb', line 133 def user inventory_target.user end |
#vars ⇒ Object
54 55 56 |
# File 'lib/bolt/target.rb', line 54 def vars @inventory.vars(self) end |