Export Smart class configuration (puppetclasses)

is there a way to export Smart class configuration. It can be critical for my business to lose everything
Foreman and Proxy versions:
Foreman 1.17.1

I do not think this feature exists, but perhaps you may be able to script something with hammer/API to back up your data. Do you have any specific export format in mind? I imagine a complimentary import feature would come in handy as well when you want to restore…

I never user hammer/API

For the first time, his just important to export data in any format. (txt, csv …)
Where data are stored ? in the database (table?)


You can view the API documentation by navigating to https://$(hostname)/apidoc.html on your foreman instance. Using hammer might be a bit more straightforward. You could be interested in the following commands:

hammer puppet-class
hammer smart-variable
hammer sc-param

You can also specify the output format: hammer --output csv. The data are stored in database, you might also find general backup information useful.

I will explore this way

@1visible Did you build something working for this? I’m looking for the same solution.

I find another solution but little complex :

  1. Access on the old foreman bdd

  2. Dump some table on the old foreman bdd
    pg_dump foreman --column-inserts -a -t config_groups -t puppetclasses -t config_group_classes -t lookup_keys -t lookup_values -t environments \ -t environment_classes -t media -t operatingsystems -t media_operatingsystems \ -t template_kinds -t templates -t operatingsystems_provisioning_templates -t operatingsystems_ptables \ -t os_default_templates \ -t auth_sources -t users -t roles -t user_roles -t usergroups -t usergroup_members> /tmp/backup_for_foreman_config2019.sql

  3. (2 Bis) I put you several tables that I restored for a new foreman, but in your case you only need :
    pg_dump foreman --column-inserts -a -t config_groups -t puppetclasses -t config_group_classes -t lookup_keys -t lookup_values -t environments > /tmp/backup_for_foreman_config2019.sql

  4. Restore the exported config on the new server
    pg_restore /tmp/backup_for_foreman_config2019.sql -d foreman

you can contact me if you need help accessing the database or other