Skip to content

libre-devops/terraform-external-which-os

Repository files navigation

###############################################################################
# Detect the OS
###############################################################################

# Full path to the helper that exists only on Windows
locals {
  windows_helper = "${abspath(path.module)}\\printf.cmd"
}

# If the helper file exists, we’re on Windows; otherwise assume Linux
data "external" "detect_os" {
  program = fileexists(local.windows_helper) ? [local.windows_helper, "{\"os\":\"Windows\"}"] : ["printf", "{\"os\":\"Linux\"}"]
}

locals {
  os         = data.external.detect_os.result.os
  is_windows = lower(local.os) == "windows"
  is_linux   = lower(local.os) == "linux"
}

Requirements

No requirements.

Providers

Name Version
external n/a

Modules

No modules.

Resources

Name Type
external_external.detect_os data source

Inputs

No inputs.

Outputs

Name Description
is_linux True if the OS is Linux
is_windows True if the OS is Windows
os The OS that is running the commands

About

A module used to determine which OS you are running terraform under

Resources

License

Stars

Watchers

Forks

Packages

No packages published