Class: LinodeCluster::NodeGroup
- Inherits:
-
Struct
- Object
- Struct
- LinodeCluster::NodeGroup
- Defined in:
- lib/linode_cluster/node_group.rb
Instance Attribute Summary collapse
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#count ⇒ Object
Returns the value of attribute count.
-
#group_name_prefix ⇒ Object
Returns the value of attribute group_name_prefix.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#region ⇒ Object
Returns the value of attribute region.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #as_ansible_inventory ⇒ Object
- #create! ⇒ Object
- #group_name ⇒ Object
- #name_prefix ⇒ Object
- #names ⇒ Object
- #nodes ⇒ Object
- #template_options(node) ⇒ Object
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster
4 5 6 |
# File 'lib/linode_cluster/node_group.rb', line 4 def cluster @cluster end |
#count ⇒ Object
Returns the value of attribute count
4 5 6 |
# File 'lib/linode_cluster/node_group.rb', line 4 def count @count end |
#group_name_prefix ⇒ Object
Returns the value of attribute group_name_prefix
4 5 6 |
# File 'lib/linode_cluster/node_group.rb', line 4 def group_name_prefix @group_name_prefix end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/linode_cluster/node_group.rb', line 4 def name @name end |
#options ⇒ Object
Returns the value of attribute options
4 5 6 |
# File 'lib/linode_cluster/node_group.rb', line 4 def end |
#region ⇒ Object
Returns the value of attribute region
4 5 6 |
# File 'lib/linode_cluster/node_group.rb', line 4 def region @region end |
#size ⇒ Object
Returns the value of attribute size
4 5 6 |
# File 'lib/linode_cluster/node_group.rb', line 4 def size @size end |
Instance Method Details
#as_ansible_inventory ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/linode_cluster/node_group.rb', line 39 def as_ansible_inventory result = +"[#{name}]\n" nodes.each do |node| = (node).map { |k, v| "#{k}=#{v}" }.join(' ') result << "#{node.name} #{string_options}".strip result << "\n" end result << "\n" end |
#create! ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/linode_cluster/node_group.rb', line 17 def create! names.each do |name| node = cluster.client.find_node_by_name(name) if node check_node_specs(node) else create_node(name) end end end |
#group_name ⇒ Object
13 14 15 |
# File 'lib/linode_cluster/node_group.rb', line 13 def group_name "#{group_name_prefix}#{name}" end |
#name_prefix ⇒ Object
9 10 11 |
# File 'lib/linode_cluster/node_group.rb', line 9 def name_prefix "#{group_name}-" end |
#names ⇒ Object
5 6 7 |
# File 'lib/linode_cluster/node_group.rb', line 5 def names Array.new(count) { |i| "#{name_prefix}#{i}" } end |
#nodes ⇒ Object
28 29 30 |
# File 'lib/linode_cluster/node_group.rb', line 28 def nodes names.map { |n| cluster.client.find_node_by_name(n) }.compact end |
#template_options(node) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/linode_cluster/node_group.rb', line 32 def (node) Hash[.map do |k, v| v = node.ip_address if v == '{{ ip_address }}' [k, v] end] end |