iagctl db import

Import resources and services from a file.

The iagctl db import command imports services and resources from a service configuration file. Use this command to move services and resources from one gateway instance to another, or to import a file you’ve created manually.

You can import from a local file or from a repository. IAG also provides the --validate and --check flags to verify the import before applying changes.

Syntax

$iagctl db import <filename> [flags]

Usage notes

Validate an import

Use the --validate flag to verify that all resources in the file contain the required fields. If any fields are missing, the gateway returns details so you can resolve the issue.

Preview an import

Use the --check flag to preview the actions the gateway would take without making any changes. The gateway reports one of three states for each resource:

StateDescription
ConflictA resource with the same name already exists. The gateway takes no action unless you also use the --force flag.
AddThe resource is new and the gateway creates it on import.
ReplacementThe resource replaces an existing one. This state appears when you combine --check with --force.

Force an import

Use the --force flag to override any existing resources that conflict with the imported file.

Examples

Import from a local file

$iagctl db import ./file.yml

Import from a repository over HTTP

$iagctl db import --repository https://github.com/itential/quick.git import.yml

Import from a repository over SSH with a private key

$iagctl db import --repository git@github.com:itential/quick.git \
>--private-key-name my-private-key import.yml

Validate a service file

$iagctl db import ./file.yml --validate

Preview an import

$iagctl db import ./file.yml --check

Preview a forced import

$iagctl db import ./file.yml --check --force

Service file format

The following example shows the structure of a service configuration file:

1decorators:
2 - name: ansible-xr
3 schema:
4 $id: https://example.com/device.schema.json
5 $schema: https://json-schema.org/draft/2020-12/schema
6 properties:
7 device_type:
8 description: The type of device
9 enum:
10 - ios
11 - eos
12 - nxos
13 type: string
14 host:
15 description: The hostname or IP address of the device
16 type: string
17 title: Network Device
18 type: object
19repositories:
20 - name: xr-resources
21 description: XR Resources for testing
22 url: git@gitlab.com:jh/xr/resources.git
23 reference: main
24 tags:
25 - cisco
26 - xr
27 private-key-name: xr-gitlab-private
28services:
29 - name: Ansible-Example
30 type: ansible-playbook
31 description: An ansible playbook to say hello-world
32 playbooks:
33 - hello-world.yml
34 working-directory: ./
35 repository: xr-resources
36 decorator: ansible-xr
37 tags:
38 - xr
39 - cisco
40 runtime:
41 check: true
42 diff: true
43 skip-tags: example-tag
44 inventory:
45 - ./inventory.ini
46 verbose-level: 6
47 - name: Hello-World
48 type: python-script
49 description: A simple hello-world playbook
50 filename: hello-world.py
51 working-directory: python-scripts
52 repository: xr-resources
53 decorator: my-special-decorator

Options

$ --check Validate and preview the import without making changes.
$ --force Override any existing resources that conflict with the import.
$ -h, --help Help for import
$ --repository string The repository to import from. Must be a preconfigured repository referenced by name.
$ --validate Validate the service file without importing.

Options inherited from parent commands

$ --config string Path to the configuration file
$ --raw Display the result of the command in raw format
$ --verbose Enable verbose output