Skip to content

Commit

Permalink
FEATURE: support to set log level of each components (#18)
Browse files Browse the repository at this point in the history
- support to set log level of each components
- upgrade terraform version to 1.5+
  • Loading branch information
Downager authored Nov 6, 2023
1 parent 910af4c commit 940bdd1
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Terraform test"
on: [push, pull_request]
on: [pull_request]

jobs:
tflint:
Expand All @@ -8,7 +8,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: TFLint
uses: docker://wata727/tflint
uses: docker://ghcr.io/terraform-linters/tflint:v0.48.0

fmt-and-validate:
name: fmt and validate
Expand All @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@master
- name: Install terraform
env:
TF_VERSION: 1.2.8
TF_VERSION: 1.5.7
run: |
# Install terraform
wget https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip -O /tmp/terraform.zip
Expand Down
2 changes: 2 additions & 0 deletions modules/containerd/files/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version = 2
[debug]
level = "${log_level}"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
5 changes: 3 additions & 2 deletions modules/containerd/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ data "ignition_file" "containerd_config" {
overwrite = true

content {
content = file("${path.module}/files/config.toml")
content = templatefile("${path.module}/files/config.toml", {
log_level = var.log_level
})
}

}

data "ignition_file" "crictl_config" {
Expand Down
5 changes: 5 additions & 0 deletions modules/containerd/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "log_level" {
description = "(Optional) containerd log level (trace, debug, info, warn, error, fatal, panic), default is info"
type = string
default = "info"
}
2 changes: 1 addition & 1 deletion modules/containerd/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
3 changes: 2 additions & 1 deletion modules/docker/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
locals {
docker_opts = concat(var.docker_opts, ["--log-level", var.log_level])
docker_cgroup = concat(var.docker_cgroups, var.docker_cgroup_driver == "systemd" ? ["--exec-opt native.cgroupdriver=systemd"] : [""])
}

Expand All @@ -9,7 +10,7 @@ data "ignition_systemd_unit" "docker_dropin" {
dropin {
name = "10-dockeropts.conf"
content = templatefile("${path.module}/templates/10-dockeropts.conf.tpl", {
docker_opts = join(" ", var.docker_opts)
docker_opts = join(" ", local.docker_opts)
docker_cgroups = join(" ", local.docker_cgroup)
})
}
Expand Down
6 changes: 6 additions & 0 deletions modules/docker/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ variable "docker_cgroups" {
variable "docker_cgroup_driver" {
type = string
default = "cgroupfs"
}

variable "log_level" {
description = "(Optional) Docker daemon log level (debug, info, warn, error, fatal), default is info"
type = string
default = "info"
}
2 changes: 1 addition & 1 deletion modules/docker/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
2 changes: 1 addition & 1 deletion modules/ecr-helper/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
2 changes: 1 addition & 1 deletion modules/legacy-cgroups/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
2 changes: 1 addition & 1 deletion modules/locksmithd/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
2 changes: 1 addition & 1 deletion modules/node-exporter/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
2 changes: 1 addition & 1 deletion modules/ntp/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
2 changes: 1 addition & 1 deletion modules/sshd/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
6 changes: 1 addition & 5 deletions modules/systemd-networkd/main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# the systemd-networkd configuration file 10-eni.network and 10-eth.network need to be adjusted after systemd updated
# Reference: https://github.com/aws/amazon-vpc-cni-k8s/issues/1600

locals {
systemd_log_level = var.debug ? "debug" : "warning"
}

data "ignition_file" "systemd_networkd_log_level" {

mode = 420
Expand All @@ -13,7 +9,7 @@ data "ignition_file" "systemd_networkd_log_level" {

content {
content = templatefile("${path.module}/templates/10-log-level.conf.tpl", {
log_level = local.systemd_log_level
log_level = var.log_level
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions modules/systemd-networkd/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variable "debug" {
description = "(Optional) Enable CoreOS Systemd Networkd debug log or not"
type = bool
default = false
variable "log_level" {
description = "(Optional) The systemd-networkd log level, default is warning"
type = string
default = "warning"
}

variable "manage_foreign_policy" {
Expand Down
2 changes: 1 addition & 1 deletion modules/systemd-networkd/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
2 changes: 1 addition & 1 deletion modules/update-ca-certificates/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down
2 changes: 1 addition & 1 deletion tests/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.2.0"
required_version = ">= 1.5.0"

required_providers {
ignition = {
Expand Down

0 comments on commit 940bdd1

Please sign in to comment.