Remove organization and location on template export

Problem:
Hi.

Is there any way to remove only organization and location metadatada, on template export to filesystem or git with foreman_templates plugin? If not, is there out any other way to acomplish it?

As per plugin documentation (Foreman :: Plugin Manuals), there’s an option “metadata_export_mode” with possible values…

“refresh” -> do not removes organization / location
“keep” -> maintains all metadata
“remove” -> removes all metadatas

The most simmilar option value (“refresh”), keeps organization and location with current values.

Thanks.
Expected outcome:
.erb files without organization and location.

Foreman and Proxy versions:
1.24.2

Foreman and Proxy plugin versions:
foreman_templates 7.0.6

Distribution and version:
Red Hat Enterprise Linux Server 7.7

Other relevant data:
Example:

[root@srv tmp]# hammer -v export-templates --repo=/tmp/ --filter=“Reboot Host” --metadata-export-mode=refresh
Name: VN - Reboot Host
Type: job_template
Exported: true

Export finished.

[root@srv job_templates]# head -n 25 vn_-_reboot_host.erb
<%#
name: VN - Reboot Host
snippet: false
template_inputs:

  • name: Reboot
    required: true
    input_type: user
    description: example
    options: “one_option\r\nother option”
    advanced: false
    value_type: plain
    resource_type: Katello::ActivationKey
    model: JobTemplate
    job_category: Ansible Power
    provider_type: Ansible
    kind: job_template
    organizations:
    - SAMPLEORG
    locations:
    - Default Location
    %>

Hi,
there is currently no way to specify individual items in metadata that should be skipped for export, there are only the 3 modes. But I see how that might not be granular enough for some users, so having an option to choose what gets exported would be a nice feature, so I opened Feature #29613: Specify which keys are included/exculded for export - Templates - Foreman

1 Like