Create a gateway service

Prev Next

The following walkthrough demonstrates the typical workflow for creating and running a gateway service. Itential Automation Gateway (IAG) imports automation content from your Git repositories and packages them as services that other users in your organization can use.

âš  Important

This example is not designed for production environments.

The following example is designed to help new users familiarize themselves with the application and should not be used for production.


Prerequisites

Before you begin, ensure you have the following:

  • A gateway server that is successfully connected to the Itential Platform
  • An existing Git repository (Github, Gitlab), either:
    • For demonstration purposes, you can use https://github.com/torerodev/example-scripts, or
    • Your own Github or Gitlab repository that contains your automation scripts

Step 1: Connect a Git repository to IAG

Set IAG server to client mode
IAG must be in client mode to connect a new Git repository. For more information about IAG application modes, see Modes of operation.

  1. Set the GATEWAY_APPLICATION_MODE environment variable to client.
export GATEWAY_APPLICATION_MODE=client
  1. Login as the admin user
iagctl login admin



Link a repository resource
For this guide, we will use a repository that is publicly available and doesn't require authentication. For more information on connecting to private repositories, specific branches, or repositories with authentication, see iagctl create repository.

Connect a repository to IAG using the iagctl create repository command.

iagctl create repository example-scripts-repo --description "Simple repository for tutorial" --url https://github.com/torerodev/example-scripts.git --reference main



Verify that you see the following output confirming that the repository was successfully created.

Output:

Successfully created the repository

Name:             example-scripts-repo
Description:      Simple repository for tutorial
Url:              https://github.com/torerodev/example-scripts.git
Reference:        main
Tags:             
Private Key Name:

You can also run the iagctl get repositories or iagctl describe repository example-scripts-repo command to verify that the repository was created.

Step 2: Create a simple service

Next, we'll publish simple scripts as services in the Itential Platform. The scripts used in this example are available in the public repository that you connected to in the previous step.


Create a service based on a Python script:

iagctl create service python-script my-python-service \
--repository example-scripts-repo \
--filename hello-torero.py  \
--description "Python Script Example" 



Create a service based on a Ansible playbook:

iagctl create service ansible-playbook my-ansible-service \
--repository example-scripts-repo \
--playbook hello-ansible.yml \
--description "Ansible Playbook Example" 



Create a service based on an OpenTofu plan:

iagctl create service opentofu-plan my-opentofu-service \
--repository example-scripts-repo \
--working-dir hello-plan \
--description "OpenTofu Plan Example"


Run the gateway service

Run the service from your client:

iagctl run service python-script my-python-service

Return results:

Output:

Start Time:   2024-01-01T12:00:00Z
End Time:     2024-01-01T12:00:01Z
Elapsed Time: 1.372672s
Return Code:  0
Stdout:
Hello, torero!
...

Stderr:

Now that you have registered your gateway services, you can use the Itential Platform to orchestrate these services through intuitive workflows. For more information, see Adding services to workflows.

Learn more