From 1b71f00cf2744bc8368947653ab2818b743609b0 Mon Sep 17 00:00:00 2001 From: Kirill Zaborsky Date: Thu, 30 Apr 2020 12:35:40 +0300 Subject: [PATCH] Add `install_cmd` for other package managers in init-snippet-install-awscli --- CHANGELOG.md | 3 +++ modules/init-snippet-install-awscli/README.md | 3 ++- modules/init-snippet-install-awscli/main.tf | 9 ++++++++- modules/init-snippet-install-awscli/snippet.tpl | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c9a7cd4..7d30294c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ * nat-gateways: Fix association issue caused between `nat_eip` and public subnets. This only affects resources using the `nat_eip` variable. +* `init-snippet-install-awscli`: new argument to allow not only `apt` as a + command to install OS packages + ### Examples # v0.9.16 diff --git a/modules/init-snippet-install-awscli/README.md b/modules/init-snippet-install-awscli/README.md index 59570c1c..ce809a10 100644 --- a/modules/init-snippet-install-awscli/README.md +++ b/modules/init-snippet-install-awscli/README.md @@ -2,7 +2,8 @@ Generate an init snippet to install the AWS cli tool on boot. This will: -* use apt to install `python-pip` +* use apt (by default) to install `python-pip` * use `pip` to upgrade `pip` * us `pip` to install `awscli` +To override package manager set a proper value to the argument `install_cmd`. diff --git a/modules/init-snippet-install-awscli/main.tf b/modules/init-snippet-install-awscli/main.tf index 5c458d77..2cd122f5 100644 --- a/modules/init-snippet-install-awscli/main.tf +++ b/modules/init-snippet-install-awscli/main.tf @@ -3,7 +3,7 @@ * * Generate an init snippet to install the AWS cli tool on boot. This will: * - * * use apt to install `python-pip` + * * use apt/yum to install `python-pip` * * use `pip` to upgrade `pip` * * us `pip` to install `awscli` * @@ -16,6 +16,12 @@ variable "init_prefix" { type = string } +variable "install_cmd" { + default = "apt install -y" + description = "package manager install command (`apt install -y` by default)" + type = string +} + variable "init_suffix" { default = "" description = "init (shellcode) to append to the end of this snippet" @@ -34,6 +40,7 @@ data "template_file" "init_snippet" { vars = { init_prefix = var.init_prefix + install_cmd = var.install_cmd init_suffix = var.init_suffix log_prefix = var.log_prefix } diff --git a/modules/init-snippet-install-awscli/snippet.tpl b/modules/init-snippet-install-awscli/snippet.tpl index df47462c..90959a72 100644 --- a/modules/init-snippet-install-awscli/snippet.tpl +++ b/modules/init-snippet-install-awscli/snippet.tpl @@ -1,5 +1,5 @@ # start snippet - install awscli python cli tools ${init_prefix} -apt install -y python3-pip +${install_cmd} python3-pip pip3 install awscli ${init_suffix}