https://rancher.com/ logo
Title
d

damp-tent-77102

10/04/2022, 3:08 AM
Team, How we can assign static IP for the VM in Harvester. I tried with cloudinit but didn't work
s

square-farmer-68052

10/04/2022, 4:51 AM
what OS is the VM, sometimes I find its best to call the OS’s tooling directly..
d

damp-tent-77102

10/04/2022, 5:06 AM
Oracle Linux 7.9
@square-farmer-68052
cloudinit {
    user_data    = <<-EOF
      #cloud-config
      package_update: true
      packages:
        - qemu-guest-agent
      runcmd:
        - - systemctl
          - enable
          - '--now'
          - qemu-guest-agent.service
      EOF
    network_data = <<-EOF
      network:
        version: 1
        config:
          - type: physical
            name: eth0
            subnets:
              - type: static
                addresses: "${each.value.host_ip}/${var.network_subnet}"
                gateway: "${var.network_gateway}"
    EOF
  }
I am trying with these way but not working..
s

square-farmer-68052

10/10/2022, 6:29 PM
oh sorry for the late response.. if I hadda guess i’d say yer yaml is not coming through formatted properly and being ignored as malformed
d

damp-tent-77102

10/11/2022, 1:38 AM
then, how to fix it ? how we can use it in other way ? @square-farmer-68052
s

square-farmer-68052

10/11/2022, 1:47 AM
pipe yaml into b64 encoder
that preserves formatting better
for starters I dont think you want the yaml to be indented as such
d

damp-tent-77102

10/11/2022, 1:50 AM
Do you have any sample code how it would be ?
s

square-farmer-68052

10/11/2022, 1:50 AM
no sorry
docs say it can be b64 encoded and last time I encountered such an issue I just linted the yaml externally, b64 encoded it and used that: https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/machine_config_v2#user_data
d

damp-tent-77102

10/11/2022, 1:58 AM
ok.
w

witty-jelly-95845

10/19/2022, 4:38 PM
Have you tried using the Network Data section? I've a working example about half way down https://community.suse.com/posts/how-to-manage-harvester-030-with-rancher-261-running-in-a-vm-within-harvester (yes the article needs updating but the network bit should still be true)
d

damp-tent-77102

10/19/2022, 5:21 PM
I didn't try yet. I don't have account in this community. requested now.
the same format only i am using but trying via terraform