Export/import custom vars from old stack to new stack. Or create with ansible

Is there a way to export and import custom vars, eg Data Fields, Data lists from one icinga stack to a new one. Or export data to csv and import to new stack with eg fileshipper, alt use api or automation with eg ansible.

well you can use baskets to move your commands,host and service templates.
the fileshipper has the possibility to import from core API which would be the icinga2 objects at runtime. or rest api which can be used to talk to another icinga directors rest api and try to fetch objects.

Hmm, I tried icingacli director export datafields >> datafields.json same with datalists, got output with correct data. The trickey part is how do I import them into the new stack? Tested Import source and jobs got green check on both, but have no idea where the data got imported, not showing up in cust vars. Really confusing :slight_smile:

A Datafield is a datafield not a custom var.
If you add the datafield to a template or object and fill it out you get a custom var which can be exported using baskets as long as it is not hanging on a host or service because these two types can not be exported that way.
If you set up a basket you can see what kind of objects are supported to export.

Your imported datafields are most likely here:

The goal was to export datalists, and custom vars created in my old stack. Is there a way to import them in the new stack?

You can use icings director baskets for datalists and datafields

Ok, I really trying to understand the concept, but its really confusing. Exporting the data is not a problem, I can download json-file from basket or or use the icingacli director export. Then its getting confusing how to import it. Should you not be able to import to basket and the restore snap? The only success sofar is creating import source, preview looks fine, then I tried to create a job, works to, but its not possible to add the job to basket, got: " Please check your Basket configuration, datalist does not support single “DirectorJob” configuration objects"

ok, sorry for that, you can only import these elements listed here using baskets:

but all the datafields attached to a service/hosttemplate will of course be exported/imported if the service/hosttemplate is exported/imported

The cli export command can export datafields but the import command cant import them:

Thanks for clarifying, got it right now:

  1. Create commands basket, download.
  2. Create host and host_groups basket, download.
  3. Create service and service_groups basket, download.
  4. Had to open host/groups exports in vim and “find and replace” zone due to using diffrent zones in old and new stack. New stack just master zone, old diffrent sat zone) (:%s/old zone/new zone/g)
  5. Import baskets in new stack:
    5a. commands
    5b. hosts
    5c. services
  6. Done :slight_smile:

Thank you for your patience :slight_smile:

Hope to be able to import datafields with icingacli in the future, would be nice, saves time :slight_smile:

Thank you, Fredde

Host an services do not support baskets.
Templates do