【问题标题】:Ignition Provider for azure ubuntu vmazure ubuntu vm 的点火提供程序
【发布时间】:2020-09-02 06:36:52
【问题描述】:

我正在尝试使用terraformignition provider 编写systemd service 文件,如下所示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"}]}}

我如何使用terraform 创建一个systemd service 文件,以及我在上面的配置中缺少什么,这个ignition 是否仅适用于centos?对此的任何帮助将不胜感激

【问题讨论】:

    标签: azure azure-devops terraform systemd terraform-provider-azure


    【解决方案1】:

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

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

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

    【讨论】:

    • 您好,感谢您的回复,看起来它工作正常,但它不会存储在/etc/systemd/system 中?我们在哪里可以找到这个文件
    • "在 Linux 操作系统上,自定义数据通过 ovf-env.xml 文件传递​​到 VM,该文件在配置期间复制到 /var/lib/waagent 目录。较新版本的 Microsoft Azure Linux 代理也将复制为方便起见,也将 base64 编码的数据发送到 /var/lib/waagent/CustomData。”来自this
    猜你喜欢
    • 2016-11-04
    • 2021-12-23
    • 1970-01-01
    • 2020-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-20
    相关资源
    最近更新 更多