db import

Import resources/services from a service file

Synopsis

Import

This command imports a service config from a file. This is useful in cases where services and resources need to move from one torero instance to another. The method allows a previously exported (or created) file to be imported.

Services and resources can be imported either from a local file or a repository if you have one setup. torero also provides tools to --validate and --check the import process.

Validate

Validation can be run against a file by providing the --validate command. The flag will ensure that required fields for the resource has all required fields and return information if not so the issues can be resolved.

Check

Check allows torero to display the actions that would take place or the results of dry-run import without making any changes to the store. There are three states that a check can surface.

  1. Conflict - This state means there is a conflict and nothing will take place. If you want to override the existing resource that is flagged as conflict you can you the --force flag.
  2. Add - This state means the resource is new and will be created on import.
  3. Replacement - This state means the resource will be replaced when the service is imported. You will see this when running the check flag with --force.

Example File

example.yml

decorators:
  - name: ansible-xr
    schema:
      $id: https://example.com/device.schema.json
      $schema: https://json-schema.org/draft/2020-12/schema
      properties:
        device_type:
          description: The type of device
          enum:
            - ios
            - eos
            - nxos
          type: string
        host:
          description: The hostname or IP address of the device
          type: string
      title: Network Device
      type: object
repositories:
  - name: xr-resources
    description: XR Resources for testing
    url: [email protected]:jh/xr/resources.git
    reference: main
    tags:
      - cisco
      - xr
    private-key-name: xr-gitlab-private
services:
  - name: Ansible-Example
    type: ansible-playbook
    description: An ansible playbook to say hello-world
    playbooks:
      - hello-world.yml
    working-directory: ./
    repository: xr-resources
    decorator: ansible-xr
    tags:
      - xr
      - cisco
    runtime:
      check: true
      diff: true
      skip-tags: example-tag
      inventory:
        - ./inventory.ini
      verbose-level: 6
  - name: Hello-World
    type: python-script
    description: A simple hello-world playbook
    filename: hello-world.yml
    working-directory: ansibleplaybooks
    repository: xr-resources
    decorator: my-special-decorator
torero db import <filename> [flags]

Examples

Import Services And Resources From A Local file

>_ torero db import ./file.yml

Import Services And Resources From A Repository Via HTTP

>_ torero db import --repository https://github.com/itential/quick.git import.yml

Import Services And Resources From A Repository Via SSH With Private Key

>_ torero db import --repository [email protected]:itential/quick.git --private-key-name my-private-key import.yml

Validate Service File

>_ torero db import ./file.yml --validate

Check Service File Against torero Store

>_ torero db import ./file.yml --check

Check Service File Against torero Store If Forced

>_ torero db import ./file.yml --check --force

Options

      --check                When set torero will perform a validation and dry-run of the service
                             import.
      --force                When set torero will override any existing service that already exists.
  -h, --help                 help for import
      --private-key string   Private key to access the repository when pulling in resources.
      --reference string     reference to be used to clone the repository
      --repository string    The repository url to import services from.
      --validate             When set torero will only validate the service file.

Options inherited from parent commands

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

SEE ALSO

  • torero db - Manage resources of the database/store