You can import templates from a repository of your choice.
You can use different protocols to point to your repository, for example /tmp/dir
, git://example.com
, https://example.com
, and ssh://example.com
.
Note
|
The templates provided by {Project} are locked and you cannot import them by default.
To overwrite this behavior, change the |
-
Each template must contain the location and organization that the template belongs to. This applies to all template types. Before you import a template, ensure that you add the following section to the template:
<%# kind: provision name: My_Provisioning_Template oses: - My_first_OS - My_second_OS locations: - My_first_Location - My_second_Location organizations: - My_first_Organization - My_second_Organization %>
To use the CLI instead of the {ProjectWebUI}, see the CLI procedure. To use the API, see the API Procedure.
-
In the {ProjectWebUI}, navigate to Hosts > Templates > Sync Templates.
-
Click Import.
-
Each field is populated with values configured in Administer > Settings > TemplateSync. Change the values as required for the templates you want to import. For more information about each field, see [Configuring_the_TemplateSync_plugin_{context}].
-
Click Submit.
The {ProjectWebUI} displays the status of the import. The status is not persistent; if you leave the status page, you cannot return to it.
-
To import a template from a repository, enter the following command:
$ hammer import-templates \ --branch "My_Branch" \ --filter '.*Template Name$' \ --organization "My_Organization" \ --prefix "[Custom Index] " \ --repo "https://git.example.com/path/to/repository"
For better indexing and management of your templates, use
--prefix
to set a category for your templates. To select certain templates from a large repository, use--filter
to define the title of the templates that you want to import. For example--filter '.*Ansible Default$'
imports various Ansible Default templates.
-
Send a
POST
request toapi/v2/templates/import
:# curl -H "Accept:application/json" \ -H "Content-Type:application/json" \ -u login:password \ -k https://{foreman-example-com}/api/v2/templates/import \ -X POST
If the import is successful, you receive
{"message":"Success"}
.