蔚蓝ubuntu vm的点火器

问题描述

我正尝试使用systemd service中的ignition provider来编写terraform文件,如下所述ubuntu OS

# Systemd unit data resource containing the unit deFinition
data "ignition_systemd_unit" "example" {
  name = "example.service"
  content = "[Service]\nType=oneshot\nExecStart=/usr/bin/echo Hello World\n\n[Install]\nWantedBy=multi-user.target"
}

# Ingnition config include the prevIoUs defined systemd unit data resource
data "ignition_config" "example" {
  systemd = [
    data.ignition_systemd_unit.example.rendered,]
}

# Create a CoreOS server using the Igntion config.
resource "aws_instance" "web" {
  # ...

  user_data = data.ignition_config.example.rendered
}

azurerm_linux_virtual_machine中,我像下面这样

custom_data = data.ignition_config.example.rendered

我遇到如下错误

Error: expected "custom_data" to be a base64 string,got {"ignition":{"config":{},"timeouts":{},"version":"2.1.0"},"networkd":{},"passwd":{},"storage":{},"systemd":{"units":[{"contents":"[Service]\nType=oneshot\nExecStart=/usr/bin/echo Hello World\n\n[Install]\nWantedBy=multi-user.target","enabled":true,"name":"example.service"}]}}

如何使用systemd service创建terraform文件,以及上述配置中缺少的内容,这个ignition仅适用于centos吗?任何帮助,将不胜感激

解决方法

对于错误消息,您可以使用base64encode函数将Base64编码应用于字符串。

 custom_data = base64encode(data.ignition_config.example.rendered)

我使用Azure VM映像UbuntuServer 16.04-LTS进行了尝试 enter image description here