ec2launcher 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -0
- data/lib/ec2launcher.rb +18 -4
- data/lib/ec2launcher/version.rb +1 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
data/lib/ec2launcher.rb
CHANGED
@@ -698,6 +698,16 @@ module EC2Launcher
|
|
698
698
|
new_env
|
699
699
|
end
|
700
700
|
|
701
|
+
# Given a string containing a command to run, replaces any inline variables.
|
702
|
+
# Supported variables include:
|
703
|
+
# * @APPLICATION@ - name of the application
|
704
|
+
# * @ENVIRONMENT@ - name of the environment
|
705
|
+
#
|
706
|
+
# @return [String] command with variables replaced
|
707
|
+
def substitute_command_variables(cmd)
|
708
|
+
cmd.gsub(/@APPLICATION@/, @application.name).gsub(/@ENVIRONMENT@/, @environment.name)
|
709
|
+
end
|
710
|
+
|
701
711
|
# Validates all settings in an application file
|
702
712
|
#
|
703
713
|
# @param [String] filename name of the application file
|
@@ -767,8 +777,8 @@ module EC2Launcher
|
|
767
777
|
|
768
778
|
# pre-commands, if necessary
|
769
779
|
unless @environment.precommands.nil? || @environment.precommands.empty?
|
770
|
-
|
771
|
-
user_data += "\n" +
|
780
|
+
commands = @environment.precommands.collect {|cmd| substitute_command_variables(cmd) }
|
781
|
+
user_data += "\n" + commands.join("\n")
|
772
782
|
end
|
773
783
|
|
774
784
|
user_data += "\n"
|
@@ -806,12 +816,16 @@ module EC2Launcher
|
|
806
816
|
user_data += " 2>&1 > /var/log/cloud-startup.log"
|
807
817
|
|
808
818
|
# Add extra requested commands to the launch sequence
|
819
|
+
unless @options.commands.nil?
|
820
|
+
commands = @environment.commands.collect {|cmd| substitute_command_variables(cmd) }
|
821
|
+
user_data += "\n" + commands.join("\n")
|
822
|
+
end
|
809
823
|
@options.commands.each {|extra_cmd| user_data += "\n#{extra_cmd}" }
|
810
824
|
|
811
825
|
# Post commands
|
812
826
|
unless @environment.postcommands.nil? || @environment.postcommands.empty?
|
813
|
-
|
814
|
-
user_data += "\n" +
|
827
|
+
commands = @environment.postcommands.collect {|cmd| substitute_command_variables(cmd) }
|
828
|
+
user_data += "\n" + commands.join("\n")
|
815
829
|
end
|
816
830
|
user_data
|
817
831
|
end
|
data/lib/ec2launcher/version.rb
CHANGED