使用 terraform 在 azure 虚拟机上部署 tanium 客户端
Deploying tanium client on an azure virtual machine using terraform
我正在使用 Terraform 创建 Azure VM 并使用 PowerShell 安装 IIS 作为扩展。
现在我想在 Azure VM 上安装 Tanium 客户端。我是否也可以使用 PowerShell 或 terraform 作为扩展来执行此操作,或者是否有任何其他方法?
我对此很陌生,因此非常感谢任何帮助。
我假设您有一些 bash 或 powershell 脚本来下载、安装和配置 tanium 客户端。在这种情况下,您可以使用扩展程序复制到远程机器并执行脚本。
resource "azurerm_virtual_machine_extension" "tanium-client-deployment" {
name = "tanium-client"
virtual_machine_id = <vm-id>
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.0"
protected_settings = <<SETTINGS
{
"commandToExecute": "powershell -command \"[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64encode(data.template_file.tf.rendered)}')) | Out-File -filepath install.ps1\" && powershell -ExecutionPolicy Unrestricted -File install-tanium.ps1"
}
SETTINGS
}
data "template_file" "tf" {
template = "${file("install-tanium.ps1")}"
}
我从 here 获得了 template_file 和一个示例 powershell 命令。
如果您的脚本不需要任何模板,您可以避免执行 template_file
,使用 base64 编码并将其传递给 commandToExecute
我正在使用 Terraform 创建 Azure VM 并使用 PowerShell 安装 IIS 作为扩展。
现在我想在 Azure VM 上安装 Tanium 客户端。我是否也可以使用 PowerShell 或 terraform 作为扩展来执行此操作,或者是否有任何其他方法?
我对此很陌生,因此非常感谢任何帮助。
我假设您有一些 bash 或 powershell 脚本来下载、安装和配置 tanium 客户端。在这种情况下,您可以使用扩展程序复制到远程机器并执行脚本。
resource "azurerm_virtual_machine_extension" "tanium-client-deployment" {
name = "tanium-client"
virtual_machine_id = <vm-id>
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.0"
protected_settings = <<SETTINGS
{
"commandToExecute": "powershell -command \"[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64encode(data.template_file.tf.rendered)}')) | Out-File -filepath install.ps1\" && powershell -ExecutionPolicy Unrestricted -File install-tanium.ps1"
}
SETTINGS
}
data "template_file" "tf" {
template = "${file("install-tanium.ps1")}"
}
我从 here 获得了 template_file 和一个示例 powershell 命令。
如果您的脚本不需要任何模板,您可以避免执行 template_file
,使用 base64 编码并将其传递给 commandToExecute