问题描述
我正尝试使用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)