Class: Buildserver::Role
- Inherits:
-
Object
- Object
- Buildserver::Role
- Defined in:
- lib/buildserver/role.rb
Instance Attribute Summary collapse
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
- #add_build_block(block) ⇒ Object
- #build(roles) ⇒ Object
- #external_ports ⇒ Object
- #has_role?(role) ⇒ Boolean
-
#initialize(role) ⇒ Role
constructor
A new instance of Role.
- #internal_ports ⇒ Object
Constructor Details
#initialize(role) ⇒ Role
8 9 10 11 |
# File 'lib/buildserver/role.rb', line 8 def initialize(role) @role = role.to_s @build_blocks = [] end |
Instance Attribute Details
#role ⇒ Object (readonly)
Returns the value of attribute role.
6 7 8 |
# File 'lib/buildserver/role.rb', line 6 def role @role end |
Instance Method Details
#add_build_block(block) ⇒ Object
13 14 15 |
# File 'lib/buildserver/role.rb', line 13 def add_build_block(block) @build_blocks << block end |
#build(roles) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/buildserver/role.rb', line 29 def build(roles) @commands = [] @after_commands = [] # Safe bash: @commands << "set -eux" @commands << "set -o pipefail" @build_blocks.each do |build_block| @commands << "# ! #{build_block.to_s} -------------------------------------" commands, after_commands = build_block.build!(self, roles) @commands << commands @commands << "# / #{build_block.to_s} -------------------------------------" @after_commands << after_commands end @commands << @after_commands @commands << "if [ ! -f /root/system_setup_complete ]; then" @commands << "echo $(date \"+%Y.%m.%d-%H:%M:%S\") > /root/system_setup_complete" @commands << "fi" @commands.flatten end |
#external_ports ⇒ Object
17 18 19 |
# File 'lib/buildserver/role.rb', line 17 def external_ports @build_blocks.map{|bb| bb.external_ports}.flatten end |
#has_role?(role) ⇒ Boolean
25 26 27 |
# File 'lib/buildserver/role.rb', line 25 def has_role?(role) @role == role.to_s end |
#internal_ports ⇒ Object
21 22 23 |
# File 'lib/buildserver/role.rb', line 21 def internal_ports @build_blocks.map{|bb| bb.internal_ports}.flatten end |