### Install jq and gnupg on Linux Source: https://tofuutils.github.io/tofuenv Installs jq (required) and gnupg (optional) using apt-get. ```console sudo apt-get update -y sudo apt-get install -y jq gnupg ``` -------------------------------- ### Install tofuenv via Homebrew Source: https://tofuutils.github.io/tofuenv Use Homebrew to install tofuenv by tapping the tofuutils repository and then installing the package. ```console brew tap tofuutils/tap brew install tofuenv ``` -------------------------------- ### Install specific OpenTofu versions Source: https://tofuutils.github.io/tofuenv Demonstrates installing specific OpenTofu versions using various syntaxes. ```console tofuenv install 1.6.0-rc1 ``` ```console tofuenv install latest:^1.6 ``` ```console tofuenv install latest-allowed ``` ```console tofuenv install min-required ``` -------------------------------- ### Install Git-Bash on Windows Source: https://tofuutils.github.io/tofuenv Install Git-Bash using winget, a command-line package manager for Windows. ```console winget install --id Git.Git -e --source winget ``` -------------------------------- ### List Remote Installable OpenTofu Versions Source: https://tofuutils.github.io/tofuenv Lists all OpenTofu versions that are available for installation from the remote repository. ```bash tofuenv list-remote ``` -------------------------------- ### Install jq on Windows (Git Bash) Source: https://tofuutils.github.io/tofuenv Downloads and installs the jq executable for Windows within the Git Bash environment. ```console curl -L -o /usr/bin/jq.exe https://github.com/jqlang/jq/releases/latest/download/jq-win64.exe ``` -------------------------------- ### Install jq and gnupg on macOS Source: https://tofuutils.github.io/tofuenv Installs jq (required) and gnupg (optional) using Homebrew. ```console brew install jq gnupg grep ``` -------------------------------- ### Enable Auto Installation Source: https://tofuutils.github.io/tofuenv Enable automatic installation of OpenTofu versions if they are not found locally when using 'tofu use'. ```console TOFUENV_AUTO_INSTALL=true tofu use ``` -------------------------------- ### Example .opentofu-version File Usage Source: https://tofuutils.github.io/tofuenv Demonstrates how the .opentofu-version file is used to specify OpenTofu versions. It shows setting specific versions, 'latest', and using regex patterns, as well as overriding with TOFUENV_TOFU_VERSION. ```bash cat .opentofu-version 1.6.0-beta5 tofu version OpenTofu v1.6.0-beta5 on darwin_amd64 echo 1.6.0-alpha5 > .opentofu-version tofu version OpenTofu v1.6.0-alpha5 on darwin_amd64 echo latest:^1.6 > .opentofu-version tofu version OpenTofu v1.6.0-rc1 on darwin_amd64 TOFUENV_TOFU_VERSION=1.6.0-alpha1 tofu --version tofu v1.6.0-alpha1 on darwin_amd64 ``` -------------------------------- ### Install tofuenv via AUR (git clone) Source: https://tofuutils.github.io/tofuenv Install tofuenv from the Arch User Repository by cloning the repository and using makepkg. ```console git clone https://aur.archlinux.org/tofuenv.git cd tofuenv makepkg -si ``` -------------------------------- ### Install tofuenv via AUR (yay) Source: https://tofuutils.github.io/tofuenv Install tofuenv from the Arch User Repository using the yay helper. ```console yay --sync tofuenv ``` -------------------------------- ### List Installed OpenTofu Versions Source: https://tofuutils.github.io/tofuenv Lists all installed OpenTofu versions. The currently active version is indicated with an asterisk. ```bash tofuenv list ``` -------------------------------- ### Install Specific Architecture Source: https://tofuutils.github.io/tofuenv Specify a non-default architecture for OpenTofu installation using the TOFUENV_ARCH variable. ```console TOFUENV_ARCH=arm64 tofuenv install 0.7.9 ``` -------------------------------- ### Manually install tofuenv on Windows (Git-Bash) Source: https://tofuutils.github.io/tofuenv Clone the tofuenv repository within the Git-Bash environment and add its bin directory to your PATH. ```console git clone --depth=1 https://github.com/tofuutils/tofuenv.git ~/.tofuenv echo 'export PATH=$PATH:$HOME/.tofuenv/bin' >> ~/.bashrc ``` -------------------------------- ### Manually install tofuenv on Linux/macOS Source: https://tofuutils.github.io/tofuenv Clone the tofuenv repository to a local directory and add its bin directory to your PATH. ```console git clone --depth=1 https://github.com/tofuutils/tofuenv.git ~/.tofuenv ``` -------------------------------- ### Disable Auto Installation Source: https://tofuutils.github.io/tofuenv Disable automatic installation of OpenTofu versions. This will cause tofuenv to exit if the requested version is not installed. ```console $ TOFUENV_AUTO_INSTALL=false tofuenv use 1.6.0-beta3 No installed versions of opentofu matched '^1.6.0-beta3$'. TOFUENV_AUTO_INSTALL is set to false, so exiting. ``` -------------------------------- ### Enable GPG verification for OpenTofu installation Source: https://tofuutils.github.io/tofuenv Configures tofuenv to use GPG for signature verification by creating a 'use-gpgv' file. ```console echo 'trust-tofuenv: yes' > ${TOFUENV_INSTALL_DIR}/use-gpgv tofuenv install ``` -------------------------------- ### Specify Custom Remote Source: https://tofuutils.github.io/tofuenv Install OpenTofu from a remote URL other than the default GitHub releases using TOFUENV_REMOTE. ```console TOFUENV_REMOTE=https://example.jfrog.io/artifactory/opentofu ``` -------------------------------- ### Skip Listing Remote Versions Source: https://tofuutils.github.io/tofuenv Skip the step of listing remote versions during installation, useful for custom remotes like Artifactory. ```console TOFUENV_SKIP_LIST_REMOTE=1 tofuenv install 1.6.0-rc1 ``` -------------------------------- ### Verify tofuenv installation on Linux/macOS Source: https://tofuutils.github.io/tofuenv Check if the tofuenv executable is found in your PATH. ```console which tofuenv ``` -------------------------------- ### Get Current OpenTofu Version Name Source: https://tofuutils.github.io/tofuenv Prints the version of OpenTofu currently being used in the directory. This is resolved automatically from environment variables or .opentofu-version files. ```bash tofuenv version-name ``` -------------------------------- ### Uninstall Tofuenv Source: https://tofuutils.github.io/tofuenv Command to completely remove the tofuenv installation. ```bash rm -rf /some/path/to/tofuenv ``` -------------------------------- ### Set Custom Eval Prefix for Console Output Source: https://tofuutils.github.io/tofuenv Use BASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX to define a command that generates a prefix for console output and file log entries. The example shows prefixing with the calling process's PID. ```bash BASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX='echo "${$$} " ' ``` -------------------------------- ### Enable JSON Logging to File Source: https://tofuutils.github.io/tofuenv Set BASHLOG_JSON to 1 to enable JSON formatted logging. Logs are written to individual files named like /tmp/.log.json. The example demonstrates enabling JSON logging for the 'tofuenv use latest' command. ```bash BASHLOG_JSON=1 tofuenv use latest ``` -------------------------------- ### Create symlinks for tofuenv binaries in ~/.local/bin Source: https://tofuutils.github.io/tofuenv Create symbolic links for tofuenv binaries into ~/.local/bin and ensure it's in your PATH. This is useful for Ubuntu/Debian systems. ```console mkdir -p ~/.local/bin/ . ~/.profile ln -s ~/.tofuenv/bin/* ~/.local/bin/ ``` -------------------------------- ### Create symlinks for tofuenv binaries Source: https://tofuutils.github.io/tofuenv Create symbolic links for tofuenv binaries into a directory already in your PATH, such as /usr/local/bin. This is for OSX/Linux only. ```console ln -s ~/.tofuenv/bin/* /usr/local/bin ``` -------------------------------- ### Launch Git-Bash environment on Windows Source: https://tofuutils.github.io/tofuenv Launch the Git-Bash shell environment by executing its sh.exe. ```console "C:\Program Files\Git\bin\sh.exe" ``` -------------------------------- ### Detect minimum required OpenTofu version from .opentofu-version file Source: https://tofuutils.github.io/tofuenv Illustrates how a .opentofu-version file with a required_version constraint is parsed to detect the minimum required OpenTofu version. ```hcl terraform { required_version = "<0.12.3, >= 0.10.0" } ``` -------------------------------- ### Switch OpenTofu Version Source: https://tofuutils.github.io/tofuenv Use this command to switch to a specific OpenTofu version. If no version is provided, it defaults to resolving via .opentofu-version files or TOFUENV_TOFU_VERSION environment variable. ```bash tofuenv use tofuenv use min-required tofuenv use 0.7.0 tofuenv use latest tofuenv use latest:^0.8 tofuenv use latest-allowed ``` -------------------------------- ### Detect latest allowed OpenTofu version from .opentofu-version file Source: https://tofuutils.github.io/tofuenv Shows how a .opentofu-version file with a version constraint is parsed to detect the latest allowed OpenTofu version. ```hcl terraform { required_version = "~> 0.10.0, <0.12.3" } ``` -------------------------------- ### Override default GPG binary for verification Source: https://tofuutils.github.io/tofuenv Allows overriding the default GPG binary used for verification by specifying a custom path and key file in the 'use-gpgv' file. ```console echo 'binary: gpgv --keyring ./path/to/gpg/opentofu.gpg' > ${TOFUENV_INSTALL_DIR}/use-gpgv tofuenv install ``` -------------------------------- ### Handle Reversed Remote Version Order Source: https://tofuutils.github.io/tofuenv Enable reversed remote version listing for custom remotes that provide versions in oldest-to-newest order, ensuring 'latest' functionality works. ```console TOFUENV_REVERSE_REMOTE=1 tofuenv list-remote ``` -------------------------------- ### Enable File Logging Source: https://tofuutils.github.io/tofuenv Enable plain text logging to a file for the Bashlog library by setting BASHLOG_FILE to 1. Logs are typically stored in /tmp. ```console BASHLOG_FILE=1 tofuenv use latest ``` -------------------------------- ### Pin Current OpenTofu Version Source: https://tofuutils.github.io/tofuenv Writes the currently active OpenTofu version to a ./.opentofu-version file. This command creates the file if it does not exist. ```bash tofuenv pin ``` -------------------------------- ### Add tofuenv to PATH for WSL Bash Source: https://tofuutils.github.io/tofuenv Append the tofuenv bin directory to your PATH in the .bashrc for WSL environments. ```bash echo 'export PATH=$PATH:$HOME/.tofuenv/bin' >> ~/.bashrc ``` -------------------------------- ### Set Custom Config Directory Source: https://tofuutils.github.io/tofuenv Specify a custom directory for tofuenv configuration and local OpenTofu versions using TOFUENV_CONFIG_DIR. ```console TOFUENV_CONFIG_DIR="$XDG_CONFIG_HOME/tofuenv" ``` -------------------------------- ### Add tofuenv to PATH for Bash Source: https://tofuutils.github.io/tofuenv Append the tofuenv bin directory to your PATH in the .bash_profile for persistent access. ```bash echo 'export PATH="$HOME/.tofuenv/bin:$PATH"' >> ~/.bash_profile ``` -------------------------------- ### Add tofuenv to PATH for Zsh Source: https://tofuutils.github.io/tofuenv Append the tofuenv bin directory to your PATH in the .zprofile for persistent access. ```zsh echo 'export PATH="$HOME/.tofuenv/bin:$PATH"' >> ~/.zprofile ``` -------------------------------- ### Specify Netrc Credentials File Source: https://tofuutils.github.io/tofuenv Provide a path to a .netrc file for authentication with remote locations when using TOFUENV_REMOTE. ```console TOFUENV_NETRC_PATH="$PWD/.netrc.tofuenv" ``` -------------------------------- ### Upgrade Tofuenv Source: https://tofuutils.github.io/tofuenv Command to upgrade the tofuenv tool itself using git. ```bash git --git-dir=~/.tofuenv/.git pull ``` -------------------------------- ### Uninstall OpenTofu Version Source: https://tofuutils.github.io/tofuenv Uninstall a specific OpenTofu version. You can use 'latest' or a regex pattern with 'latest:' to uninstall the latest matching version. ```bash tofuenv uninstall 0.7.0 tofuenv uninstall latest tofuenv uninstall latest:^0.8 ``` -------------------------------- ### Syslog Logging Functionality Source: https://tofuutils.github.io/tofuenv Configure syslog logging by setting BASHLOG_SYSLOG to 1. This snippet shows the basic structure for sending logs to syslog using the 'logger' binary, including tag, facility, and severity. ```bash local tag="${BASHLOG_SYSLOG_TAG:-$(basename "${0}")}" local facility="${BASHLOG_SYSLOG_FACILITY:-local0}" local pid="${$}" logger --id="${pid}" -t "${tag}" -p "${facility}.${severity}" "${syslog_line}" ``` -------------------------------- ### Specify Log File Path Source: https://tofuutils.github.io/tofuenv Define a specific file path for all FILE type logging in the Bashlog library using BASHLOG_FILE_PATH. ```console BASHLOG_FILE_PATH=/tmp/$(basename ${0}).log ``` -------------------------------- ### Override OpenTofu Version Source: https://tofuutils.github.io/tofuenv Override the OpenTofu version specified in .opentofu-version files or by defaults using TOFUENV_TOFU_VERSION. Supports 'latest' and version prefixes. ```console TOFUENV_TOFU_VERSION=latest:^0.11. tofu --version ``` -------------------------------- ### Disable Bashlog Colors Source: https://tofuutils.github.io/tofuenv Disable colored output in the Bashlog logging library by setting BASHLOG_COLOURS to 0. ```console BASHLOG_COLOURS=0 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.