You can add your own script repository to the platform. A dedicated or virtual server can be used as a repository.

Adding a repository


To create your own script repository:

  1. On the repository server:
    1. Install and configure the web server.
    2. Create a directory for the repository. The directory must be accessible to external connections via HTTP. For example, /var/www/html/recipes/.
    3. Copy the script files into the repository directory.
    4. Create a metadata.json file with script descriptions in the repository directory:

      Example of metadata.json file

      {
        "type": "recipe",
        "recipe": [
          {
            "name": "ForLinux",
            "tags": [
              "linux"
            ],
            "description": "script1",
            "file_name": "script1.sh",
            "updated_at": "2020-05-15 12:01:12"
          },
          {
            "name": "ForWindows",
            "tags": [
              "windows"
            ],
            "description": "script2",
            "file_name": "script2.ps",
            "updated_at": "2022-04-14 07:57:13"
          }
        ]
      }
      YML

      type — repository type. Specify the value of recipe

      recipe — an array with script descriptions:

      • name — script name
      • tags — script tags. For example, linux or windows
      • description — description of the script
      • file_name — file name of the script
      • updated_at — date and time of the last update
  2. Get the authorization token:
    curl -k -X POST -H "accept: application/json" -H "Content-Type: application/json" 'https://domain.com/auth/v4/public/token' -d '{"email": "admin_email", "password": "admin_pass"}'
    CODE

    domain.com — domain name or IP address of the server with the platform

    admin_email — platform administrator's email

    admin_pass — platform administrator's password

    In response, you will get the message in the form:

    Example of response in JSON

    {
      "confirmed": true,
      "expires_at": null,
      "id": "6",
      "token": "4-e9726dd9-61d9-2940-add3-914851d2cb8a"
    }
    CODE

    Save the received token value.

  3. Execute an API request to create a repository in the platform:

    curl -H 'x-xsrf-token: <token>' -X POST https://localhost/vm/v3/repository -d '{"name":"<repo_name>","url":"<repo_url"}'
    BASH

    <token> — authorization token

    <repo_name> — internal name of the repository

    <repo_url> — repository directory URL. For example, http://example.com/recipes

Checking the repository added


  1. Connect to the server with the platform via SSH.
  2. Request a list of repositories:

    docker exec -it mysql bash -c "mysql isp -p\$MYSQL_ROOT_PASSWORD -e \"SELECT name,url FROM vm_repository WHERE type='recipe';\""
    BASH

    Example of response

    +-------------------+-------------------------------------------------------+
    | name              | url                                                   |
    +-------------------+-------------------------------------------------------+
    | recipe_repository | http://download.ispsystem.com/OSTemplate/vm6/recipes/ |
    | My repo           | http://example.com/recipes/                           | 
    +----+-------------------+--------+-----------------------------------------+
    CODE
  3. In the platform interface:
    1. Check the display of scripts from the added repository.
    2. Run the script from the repository on the VM.

Updating the script list


The list of scripts in the platform is synchronized with the repository every 15 minutes. To update the list of scripts manually:

  1. Get the authorization token:
    curl -k -X POST -H "accept: application/json" -H "Content-Type: application/json" 'https://domain.com/auth/v4/public/token' -d '{"email": "admin_email", "password": "admin_pass"}'
    CODE

    domain.com — domain name or IP address of the server with the platform

    admin_email — platform administrator's email

    admin_pass — platform administrator's password

    In response, you will get the message in the form:

    Example of response in JSON

    {
      "confirmed": true,
      "expires_at": null,
      "id": "6",
      "token": "4-e9726dd9-61d9-2940-add3-914851d2cb8a"
    }
    CODE

    Save the received token value.

  2. Execute the API request:

    curl -H 'x-xsrf-token: <token>' -X POST "https://domain.com/vm/v3/repository/<repo_id>/update" -d ''
    
    BASH

    <token> — authorization token

    domain.comdomain name or IP address of the server with the platform

    <repo_id> — id of the repository