Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating cobbler_system #5

Open
kasuke5 opened this issue Apr 16, 2021 · 5 comments
Open

Error creating cobbler_system #5

kasuke5 opened this issue Apr 16, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@kasuke5
Copy link

kasuke5 commented Apr 16, 2021

I'm trying to create with terraform v0.14.8 a cobbler system but it failed everytime.
Using provider registry.terraform.io/cobbler/cobbler v2.0.2

I tried in first place with Cobbler 3.1.2 and I got the same result with Cobbler 3.2.1
Doing it directly with Cobbler command works, but providing the same infos with terraform don't.

From /var/log/cobbler/cobbler.log :

2021-04-16T14:25:17 - INFO | REMOTE save_item(system); user(cobbler); object_id(___NEW___system::KZSgRXWJJZE5QKm9JAQqpBWo/SyTNkgNcA==)
2021-04-16T14:25:17 - DEBUG | authorize; ['cobbler', 'save_system', <cobbler.items.system.System object at 0x7fd4da791e80>, None, True]
2021-04-16T14:25:17 - DEBUG | REMOTE cobbler authorization result: True; user(?)
2021-04-16T14:25:17 - INFO | add_item(system); ['test']
2021-04-16T14:25:17 - DEBUG | get_items; ['system']
2021-04-16T14:25:17 - DEBUG | done with get_items; ['system']
2021-04-16T14:25:17 - INFO | Exception occurred: <class 'AttributeError'>
2021-04-16T14:25:17 - INFO | Exception value: 'str' object has no attribute 'copy'
2021-04-16T14:25:17 - INFO | Exception Info:
  File "/usr/lib/python3.6/site-packages/cobbler/remote.py", line 3415, in _dispatch
    return method_handle(*params)

  File "/usr/lib/python3.6/site-packages/cobbler/remote.py", line 1908, in save_system
    return self.save_item("system", object_id, token, editmode=editmode)

  File "/usr/lib/python3.6/site-packages/cobbler/remote.py", line 1871, in save_item
    self.api.add_item(what, obj, logger=self.logger)

  File "/usr/lib/python3.6/site-packages/cobbler/api.py", line 728, in add_item
    self.get_items(what).add(ref, check_for_duplicate_names=check_for_duplicate_names, save=save, logger=logger)

  File "/usr/lib/python3.6/site-packages/cobbler/cobbler_collections/collection.py", line 388, in add
    self.lite_sync.add_single_system(ref.name)

  File "/usr/lib/python3.6/site-packages/cobbler/actions/litesync.py", line 202, in add_single_system
    self.tftpd.add_single_system(system)

  File "/usr/lib/python3.6/site-packages/cobbler/modules/managers/in_tftpd.py", line 144, in add_single_system
    menu_items = self.tftpgen.get_menu_items()['pxe']

  File "/usr/lib/python3.6/site-packages/cobbler/tftpgen.py", line 368, in get_menu_items
    system=None, profile=profile, distro=distro, arch=distro.arch)

  File "/usr/lib/python3.6/site-packages/cobbler/tftpgen.py", line 465, in write_pxe_file
    blended = utils.blender(self.api, True, profile)

  File "/usr/lib/python3.6/site-packages/cobbler/utils.py", line 605, in blender
    __consolidate(node, results)

  File "/usr/lib/python3.6/site-packages/cobbler/utils.py", line 754, in __consolidate
    results[field].update(data_item.copy())

From my file.tf :

provider "cobbler" {
  username = "cobbler"
  password = "cobbler"
  url      = "http://x.x.x.x/cobbler_api"
  insecure = true
}

variable "pfprefix" {}

resource "cobbler_profile" "test-cobbler" {
  name        = "test-cobbler"
  distro      = "SLES15-SP2-x86_64"
  enable_menu = true
}

resource "cobbler_system" "test" {
  name             = "test"
  profile          = cobbler_profile.test-cobbler.name
  autoinstall      = "test-cobbler.xml" 
  autoinstall_meta = "pfprefix=${var.pfprefix}"
  netboot_enabled  = true

  interface {
    name        = "eth0"
    mac_address = "50:6b:8d:b1:cf:c9"
    static      = true
  }
}

Is there somtehing missing ? cause reading from the provider documentation, I don't see any problem.

Profile is imported, and system is created but with interface informations missing

@hbokh
Copy link
Contributor

hbokh commented May 10, 2021

It won't work in Cobbler 3.1.2 without hacking into the code. You need Cobbler 3.2.x.
Before we start trying to reproduce this issue, have you disabled caching in Cobbler?


  • Cobbler, release 3.2.0 (or higher), with caching disabled.
    Set cache_enabled: 0 in file /etc/cobbler/settings.

Since v3.2.1 file /etc/cobbler/settings.yaml
Also see https://github.com/cobbler/terraform-provider-cobbler/blob/main/docs/index.md

Cc @SchoolGuy @holmesb
Looks like the documentation between GH and the TF Registry is "out-of-sync".

@SchoolGuy
Copy link
Member

Thanks for the ping! I will put it on my long list. Let's see what I can do...

@hbokh
Copy link
Contributor

hbokh commented May 10, 2021

Thanks for the ping! I will put it on my long list. Let's see what I can do...

The only way to publish updated documentation is to release a new version of the provider.
Reference: https://www.terraform.io/docs/registry/providers/docs.html#publishing

So when a release tagged v2.0.3 is pushed, we're "in sync" again.

@hbokh
Copy link
Contributor

hbokh commented May 10, 2021

This is somewhat off topic from the issue, but I'm looking into using tfplugindocs generate - hashicorp /
terraform-plugin-docs
to setup some improved documents generation.
It needs all resource_cobbler_*.go files used to have lines with a Description: added
Example: https://github.com/paultyng/terraform-provider-unifi/blob/main/internal/provider/resource_device.go#L31

Will have a look into this when I got some more time, so TBC.

See PR #6.

@hbokh
Copy link
Contributor

hbokh commented Oct 7, 2021

No response in almost 6 months. Can probably be closed.

@SchoolGuy SchoolGuy added the bug Something isn't working label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants