Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Add install_cmd for other package managers in init-snippet-install-awscli #327

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion modules/init-snippet-install-awscli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
9 changes: 8 additions & 1 deletion modules/init-snippet-install-awscli/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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`
*
Expand All @@ -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"
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion modules/init-snippet-install-awscli/snippet.tpl
Original file line number Diff line number Diff line change
@@ -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}