terraform-coop / terraform-provider-foreman

Terraform provider for Foreman
https://registry.terraform.io/providers/terraform-coop/foreman
Mozilla Public License 2.0
33 stars 31 forks source link

Terraform provisioning always going to network boot #102

Closed thatsk closed 1 year ago

thatsk commented 1 year ago

Hello Team, I am trying to use image as provisioned but by default it is going to install via network boot. Is there any param we need to set to use for cloning VM template.

thatsk commented 1 year ago

@lhw any lights on this

lhw commented 1 year ago

Something like this should work:


data "foreman_image" "example" {
  name = "some image name"
}
resource "foreman_host" "example" {
  name = "compute01.dc1.company.com"
  image_id = data.foreman_image.example.id
}
thatsk commented 1 year ago

this is error @lhw

 "error": {"id":null,"errors":{"ptable_id":["can't be blank unless a custom partition has been defined"],"medium_id":["can't be blank"]},"full_messages":["Ptable can't be blank unless a custom partition has been defined","Medium can't be blank"]}
}
]
}
thatsk commented 1 year ago

This was working upto 0.4.5 and now latest seems like some new stuff has been added.


resource "foreman_host" "newtest" {
    name                    = "test02p1"
    compute_profile_id      = "${data.foreman_computeprofile.medium.id}"
    build                   = true
    compute_resource_id     = "${data.foreman_computeresource.int-msp.id}"
    domain_id               = 2
    hostgroup_id            = "${data.foreman_hostgroup.terraform.id}"
    image_id                = "${data.foreman_image.example.id}"
    model_id                = 0
    operatingsystem_id  = "${data.foreman_operatingsystem.Centos79.id}"
    owner_id            = 3
    retry_count         = 2
    parameters = {
      "puppet_environment" = "integration",
    }
}
resource "null_resource" "newtest" {
  triggers = {
       templateid = "${foreman_host.newtest.id}"
  }

  connection {
    type = "ssh"
    host = "${foreman_host.newtest.interfaces_attributes[0].ip}"
    user = "root"
    password = "${var.password}"
    port = "22"
    agent = false
  }

  provisioner "file" {
      source      = "scripts/"
      destination = "/tmp"
 }
}
thatsk commented 1 year ago

when I am checking the code it has been refactored for provision_method and build params.

thatsk commented 1 year ago

which param is defining i need to use this image for cloning and which param say it goes in network boot

thatsk commented 1 year ago

on 0.5.0 says methods are deprecated now and need to use method and build and if we get some lights on this. https://github.com/terraform-coop/terraform-provider-foreman/releases/tag/v0.5.0

thatsk commented 1 year ago

https://github.com/terraform-coop/terraform-provider-foreman/commit/f39044833265a92c8f47f04075da72db12a879e2#diff-cd3952521384329d0a0e1d6a3520280acb84b99f14aa1382053142c13b029896

@lhw i am trying to understand and findiing solution but this is not working even I use build true or false

thatsk commented 1 year ago

it says use build arg how to use that in terraform code