From b24f09e002e9f9ba17bc46b210d9e873ff42d31e Mon Sep 17 00:00:00 2001 From: Triet Le Date: Thu, 22 Aug 2019 13:49:46 -0400 Subject: [PATCH 1/3] Updates to allow enabling repos --- modules/lx-autoscale/main.tf | 7 ++++--- modules/lx-autoscale/variables.tf | 6 ++++++ .../watchmaker-lx-autoscale.params.cfn.yaml | 2 ++ .../watchmaker-lx-autoscale.template.cfn.yaml | 17 +++++++++++++++++ modules/lx-instance/main.tf | 7 ++++--- modules/lx-instance/variables.tf | 6 ++++++ .../watchmaker-lx-instance.params.cfn.yaml | 2 ++ .../watchmaker-lx-instance.template.cfn.yaml | 17 +++++++++++++++++ variables.tf | 6 ++++++ 9 files changed, 64 insertions(+), 6 deletions(-) diff --git a/modules/lx-autoscale/main.tf b/modules/lx-autoscale/main.tf index 489385c8..759e5d6b 100644 --- a/modules/lx-autoscale/main.tf +++ b/modules/lx-autoscale/main.tf @@ -36,6 +36,7 @@ resource "aws_cloudformation_stack" "watchmaker-lx-autoscale" { CloudWatchAppLogs = "${join(",", var.CloudWatchAppLogs)}" DesiredCapacity = "${var.DesiredCapacity}" EbsOptimized = "${var.EbsOptimized}" + EnableRepos = "${var.EnableRepos}" InstanceRole = "${var.InstanceRole}" InstanceTerminationPolicies = "${join(",", var.InstanceTerminationPolicies)}" InstanceType = "${var.InstanceType}" @@ -67,8 +68,8 @@ resource "aws_cloudformation_stack" "watchmaker-lx-autoscale" { } timeouts { - create = "${var.TimeoutInMinutes}m" - delete = "${var.TimeoutInMinutes}m" - update = "${var.TimeoutInMinutes}m" + create = "${var.TimeoutInMinutes}m" + delete = "${var.TimeoutInMinutes}m" + update = "${var.TimeoutInMinutes}m" } } diff --git a/modules/lx-autoscale/variables.tf b/modules/lx-autoscale/variables.tf index d206df4c..b80dad66 100644 --- a/modules/lx-autoscale/variables.tf +++ b/modules/lx-autoscale/variables.tf @@ -337,3 +337,9 @@ variable "EbsOptimized" { description = "Specifies whether the launch configuration is optimized for EBS I/O. This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal EBS I/O performance. Warning: Stack creation will fail if set to true and the instance type does not support EBS Optimization. See complete list of supported instances here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html#ebs-optimization-support" default = "false" } + +variable "EnableRepos" { + type = "string" + description = "(Optional) Specify repos to be enabled by yum-config-manager" + default = "" +} diff --git a/modules/lx-autoscale/watchmaker-lx-autoscale.params.cfn.yaml b/modules/lx-autoscale/watchmaker-lx-autoscale.params.cfn.yaml index 31fd0703..181e5fb9 100644 --- a/modules/lx-autoscale/watchmaker-lx-autoscale.params.cfn.yaml +++ b/modules/lx-autoscale/watchmaker-lx-autoscale.params.cfn.yaml @@ -34,6 +34,8 @@ ParameterValue: __DESIREDCAPACITY__ - ParameterKey: EbsOptimized ParameterValue: __EBSOPTIMIZED__ +- ParameterKey: EnableRepos + ParameterValue: __ENABLEREPOS__ - ParameterKey: InstanceRole ParameterValue: __INSTANCEROLE__ - ParameterKey: InstanceTerminationPolicies diff --git a/modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml b/modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml index be655cc4..661f1c85 100644 --- a/modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml +++ b/modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml @@ -23,6 +23,10 @@ Conditions: - !Equals - !Ref PatchGroup - '' + EnablingRepos: !Not + - !Equals + - !Ref EnableRepos + - '' ExecuteAppScript: !Not - !Equals - !Ref AppScriptUrl @@ -368,6 +372,10 @@ Parameters: See complete list of supported instances here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html#ebs-optimization-support Type: String + EnableRepos: + Default: '' + Description: '(Optional) Specify repos to be enabled by yum-config-manager. Example: epel' + Type: String InstanceRole: Default: '' Description: (Optional) IAM instance role to apply to the instance(s) @@ -631,6 +639,10 @@ Resources: - InstallCloudWatchAgent - cw-agent-install - !Ref 'AWS::NoValue' + - !If + - EnablingRepos + - enable-repos + - !Ref 'AWS::NoValue' - watchmaker-install - watchmaker-launch - !If @@ -784,6 +796,11 @@ Resources: commands: 10-install-updates: command: yum -y update + enable-repos: + commands: + 10-enable-repos: + command: + !Sub 'yum-config-manager --enable ${EnableRepos}' make-app: commands: 05-get-appscript: diff --git a/modules/lx-instance/main.tf b/modules/lx-instance/main.tf index 0c69e7d1..0d3325e5 100644 --- a/modules/lx-instance/main.tf +++ b/modules/lx-instance/main.tf @@ -33,6 +33,7 @@ resource "aws_cloudformation_stack" "watchmaker-lx-instance" { CloudWatchAppLogs = "${join(",", var.CloudWatchAppLogs)}" DisableApiTermination = "${var.DisableApiTermination}" EbsOptimized = "${var.EbsOptimized}" + EnableRepos = "${var.EnableRepos}" InstanceRole = "${var.InstanceRole}" InstanceType = "${var.InstanceType}" KeyPairName = "${var.KeyPairName}" @@ -58,8 +59,8 @@ resource "aws_cloudformation_stack" "watchmaker-lx-instance" { } timeouts { - create = "${var.TimeoutInMinutes}m" - delete = "${var.TimeoutInMinutes}m" - update = "${var.TimeoutInMinutes}m" + create = "${var.TimeoutInMinutes}m" + delete = "${var.TimeoutInMinutes}m" + update = "${var.TimeoutInMinutes}m" } } diff --git a/modules/lx-instance/variables.tf b/modules/lx-instance/variables.tf index b6b3d2d3..46d7f971 100644 --- a/modules/lx-instance/variables.tf +++ b/modules/lx-instance/variables.tf @@ -283,3 +283,9 @@ variable "EbsOptimized" { description = "Specifies whether the instance is optimized for Amazon Elastic Block Store I/O. See complete list of supported instances here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html#ebs-optimization-support" default = "false" } + +variable "EnableRepos" { + type = "string" + description = "(Optional) Specify repos to be enabled by yum-config-manager" + default = "" +} diff --git a/modules/lx-instance/watchmaker-lx-instance.params.cfn.yaml b/modules/lx-instance/watchmaker-lx-instance.params.cfn.yaml index 18cde780..1306d4fa 100644 --- a/modules/lx-instance/watchmaker-lx-instance.params.cfn.yaml +++ b/modules/lx-instance/watchmaker-lx-instance.params.cfn.yaml @@ -28,6 +28,8 @@ ParameterValue: __DISABLEAPITERMINATION__ - ParameterKey: EbsOptimized ParameterValue: __EBSOPTIMIZED__ +- ParameterKey: EnableRepos + ParameterValue: __ENABLEREPOS__ - ParameterKey: InstanceRole ParameterValue: __INSTANCEROLE__ - ParameterKey: InstanceType diff --git a/modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml b/modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml index fda3c6e4..37bb24b9 100644 --- a/modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml +++ b/modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml @@ -19,6 +19,10 @@ Conditions: - !Equals - !Ref PatchGroup - '' + EnablingRepos: !Not + - !Equals + - !Ref EnableRepos + - '' ExecuteAppScript: !Not - !Equals - !Ref AppScriptUrl @@ -288,6 +292,10 @@ Parameters: See complete list of supported instances here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html#ebs-optimization-support Type: String + EnableRepos: + Default: '' + Description: '(Optional) Specify repos to be enabled by yum-config-manager. Example: epel' + Type: String InstanceRole: Default: '' Description: (Optional) IAM instance role to apply to the instance @@ -444,6 +452,10 @@ Resources: - InstallCloudWatchAgent - cw-agent-install - !Ref 'AWS::NoValue' + - !If + - EnablingRepos + - enable-repos + - !Ref 'AWS::NoValue' - watchmaker-install - watchmaker-launch - !If @@ -597,6 +609,11 @@ Resources: commands: 10-install-updates: command: yum -y update + enable-repos: + commands: + 10-enable-repos: + command: + !Sub 'yum-config-manager --enable ${EnableRepos}' make-app: commands: 05-get-appscript: diff --git a/variables.tf b/variables.tf index 466223c3..8cafcca2 100644 --- a/variables.tf +++ b/variables.tf @@ -182,3 +182,9 @@ variable "ToggleCfnInitUpdate" { description = "A/B toggle that forces a change to instance metadata, triggering the cfn-init update sequence" default = "A" } + +variable "EnableRepos" { + type = "string" + description = "(Optional) Specify repos to be enabled by yum-config-manager" + default = "" +} From 009e4110eac1002e46d47a0f16cd645a3702218e Mon Sep 17 00:00:00 2001 From: Triet Le Date: Thu, 22 Aug 2019 19:15:40 -0400 Subject: [PATCH 2/3] Updates tests to enable epel for linux instances. --- tests/main.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/main.tf b/tests/main.tf index 8857fc84..bbd43e5e 100644 --- a/tests/main.tf +++ b/tests/main.tf @@ -19,6 +19,7 @@ module "lx-instance-centos6" { SubnetId = "${var.subnet_id}" WatchmakerConfig = "${var.watchmaker_config}" WatchmakerEnvironment = "${var.watchmaker_env}" + EnableRepos = "epel" } module "lx-instance-centos7" { @@ -39,6 +40,7 @@ module "lx-instance-centos7" { SubnetId = "${var.subnet_id}" WatchmakerConfig = "${var.watchmaker_config}" WatchmakerEnvironment = "${var.watchmaker_env}" + EnableRepos = "epel" } module "lx-autoscale-centos6" { @@ -61,6 +63,7 @@ module "lx-autoscale-centos6" { SubnetIds = "${var.subnet_id}" WatchmakerConfig = "${var.watchmaker_config}" WatchmakerEnvironment = "${var.watchmaker_env}" + EnableRepos = "epel" } module "lx-autoscale-centos7" { @@ -84,6 +87,7 @@ module "lx-autoscale-centos7" { SubnetIds = "${var.subnet_id}" WatchmakerConfig = "${var.watchmaker_config}" WatchmakerEnvironment = "${var.watchmaker_env}" + EnableRepos = "epel" } module "win-instance-2008R2" { From 823605cdf6a747ab13012085383a9ab89e0abdd6 Mon Sep 17 00:00:00 2001 From: Triet Le Date: Fri, 23 Aug 2019 13:07:09 -0400 Subject: [PATCH 3/3] Bumps version to 1.15.7 --- .bumpversion.cfg | 2 +- modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml | 2 +- modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml | 2 +- .../win-autoscale/watchmaker-win-autoscale.template.cfn.yaml | 2 +- modules/win-instance/watchmaker-win-instance.template.cfn.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 43030def..682e0c07 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.15.6 +current_version = 1.15.7 commit = True message = Bumps version to {new_version} tag = False diff --git a/modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml b/modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml index 661f1c85..5f6dfacb 100644 --- a/modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml +++ b/modules/lx-autoscale/watchmaker-lx-autoscale.template.cfn.yaml @@ -206,7 +206,7 @@ Metadata: default: Force Cfn Init Update ToggleNewInstances: default: Force New Instances - Version: 1.15.6 + Version: 1.15.7 Outputs: ScaleDownScheduledAction: Condition: UseScheduledAction diff --git a/modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml b/modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml index 37bb24b9..e6aea388 100644 --- a/modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml +++ b/modules/lx-instance/watchmaker-lx-instance.template.cfn.yaml @@ -157,7 +157,7 @@ Metadata: ParameterLabels: ToggleCfnInitUpdate: default: Force Cfn Init Update - Version: 1.15.6 + Version: 1.15.7 Outputs: WatchmakerInstanceId: Description: Instance ID diff --git a/modules/win-autoscale/watchmaker-win-autoscale.template.cfn.yaml b/modules/win-autoscale/watchmaker-win-autoscale.template.cfn.yaml index 9aa81678..4b38ec9d 100644 --- a/modules/win-autoscale/watchmaker-win-autoscale.template.cfn.yaml +++ b/modules/win-autoscale/watchmaker-win-autoscale.template.cfn.yaml @@ -192,7 +192,7 @@ Metadata: default: Force Cfn Init Update ToggleNewInstances: default: Force New Instances - Version: 1.15.6 + Version: 1.15.7 Outputs: ScaleDownScheduledAction: Condition: UseScheduledAction diff --git a/modules/win-instance/watchmaker-win-instance.template.cfn.yaml b/modules/win-instance/watchmaker-win-instance.template.cfn.yaml index ad17176c..f81674b1 100644 --- a/modules/win-instance/watchmaker-win-instance.template.cfn.yaml +++ b/modules/win-instance/watchmaker-win-instance.template.cfn.yaml @@ -141,7 +141,7 @@ Metadata: ParameterLabels: ToggleCfnInitUpdate: default: Force Cfn Init Update - Version: 1.15.6 + Version: 1.15.7 Outputs: WatchmakerInstanceId: Description: Instance ID