- 04 Jan 2024
-
DarkLight
-
PDF
Git Integration
- Updated on 04 Jan 2024
-
DarkLight
-
PDF
For scripts saved in Git repositories, IAG has a process to import those scripts from those various repositories.
"Git" refers to the use of GitHub, GitLab, Bitbucket, and other Git-based code integration/management tools.
Git in Automation Gateway
The primary Git tab is located in the left navigation menu of Automation Gateway. Alternatively, it is also listed under the Configuration tab.
Figure 1: Git Configuration
Configuring Git Integration
From the Configuration tab, you can click Git to display the Git Integration Configuration modal, with configuration fields for Git Exec, Git Key Path, and Git Repo Path (Figure 2).
Strict Host Key Checking is an available option that will automatically check for a known host with an SSH key. If this option is checked, further manual action is required. You will need to check the server terminal to select "Yes" if the SSH Key is a trusted key.
Figure 2: Git Integration Configuration
How to Create an SSH Key
When you click the Git tab in the left navigation menu of Automation Gateway, a dropdown list for SSH Keys, Integrations, and Repositories displays.
Figure 3: Git Menu List
To add a SSH key, click the "+" in the top toolbar to open the Create dialog box. Scroll down and select Git SSH Keys.
Figure 4: Create an SSH Key_
Enter a name for the key under Generate SSH Key. Then click the Generate button.
Figure 5: Name the SSH Key
An SSH Key will be generated and a message banner displays in the upper right corner to indicate the SSH key pair was successfully generated. Next, click on SSH Keys in the left navigation bar. The newly generated key will display in the Public Key box with the name it was given. Users will be able to view the SSH Key as well as use it to copy/paste into Git.
Figure 6: View the SSH Key
How to Add an SSH Key
After creating the key, go to your Git CI/CD platform (e.g., GitLab) and access the appropriate section to setup your SSH Keys.
In GitLab, click Add an SSH Key and paste the generated key into the Key box provided.
Figure 7: Paste the SSH Key
Enter a key Title (name). Click Add Key. Both IAG and Git now have the same SSH Key.
Making the key title the same name as the SSH Key created in Automation Gateway will help identify what the key was created for.
Figure 8: Adding the SSH Key
How to Create a Git Integration
From Automation Gateway, click Integrations in the left navigation. A list of any created Integrations will also be shown here. To create a new integration, click the "+" in the top toolbar to open a Create dialog box and then select Git Integration from the dropdown list.
Figure 9: Creating an Integration
Type in a name for the integration. Then select the name of the SSH Key that was created from above. Click Create.
Figure 10: Naming the Integration
Click the name of the Git Integration in the sidenav menu to display information pertaining to the integration and the SSH Key being used. Click the search bar under SSH Key Name to display a dropdown list of names of any SSH Keys that are stored. This will allow users to change the integration to another key that has been created. Click Save at the bottom of the page to keep any changes that were made.
Figure 11: Git Integration Information
How to Create a Git Repository
Click the "+" in the top toolbar to open the Create dialog. Scroll down the list and select Git Repository and then click Create.
Figure 12: Creating a Git Repository
Select the integration (name) that was created above and enter a name for this Repository. Copy the SSH Key from Git (i.e., use the Clone button in GitLab) and paste it into the Repository field. Next, choose the necessary code branch (in this case it is called "master"). This will be the location on the server where the Repository is stored. In the example below, /opt/automation-gateway/repos/iag-repo/
is the location where the integration can be found. To clone and download the repository, click Create.
Figure 13: Naming the Repository
Next, click on the Repository tab in the left navigation menu and the repository name will be displayed. Click on the repository name to view information related to the repository and the Remote Fingerprint will display a unique identifier for the Host Key Check In. In the example below multiple Host Keys have been added and are shown for the Host Key Check In.
Figure 14: Viewing the Host Key
Repository Controls
In the footer (under the Remote Fingerprint), there are repository controls (buttons) where users can Pull repo data, Reset repo data (if making any changes locally on the server. Resetting will go back to the last commit.), Delete data, or Reset the Fingerprint (this will remove the data shown under the Remote Fingerprint).
Figure 15: Repository Controls
How to Import Script Configurations
If users are importing scripts (as shown in Figure 16), copy the File Path from the repository that was created. For example: /opt/automation-gateway/repos/iag-repo/
. Open the tab for Scripts in the left side navigation. Paste the file path under Scripts Paths. Click the Save icon at the top. IAG will now be able to find all of the scripts in that directory.
Figure 16: Scripts Path
How to Import Decorations
Importing Decoration scripts into the repo is an efficient way to save time without having to make edits to the Decorations.
Go to Configurations in the left hand navigation and click Scripts. Under the Parameters tab, various Decorations will be shown. Select a Decoration and click the pencil icon to edit it. The Decoration is a script built from a JSON object with type
, item
, and arguments
that will get passed on when the Decoration is used.
Figure 17: Decorations
When a Git Pull is done, the Decoration pattern will be found using the file name (example: C_demo.scripts.iag.json
). The parameters will be imported into IAG and saved to the database. Anytime there is a Git Pull from the repo, the decorations are saved into the Database and can be located by their unique name attached to scripts.iag.json
.
if the script, playbook, or module is not named with this exact suffix (e.g., name.type.iag.json
), it will not be imported on a Git Pull.
Figure 18: File Name
Collection modules are not supported and cannot be decorated automatically for a Git Pull.