When you use external packages with your services, you might need to use a private registry. Itential Automation Gateway (IAG) supports PyPI and Ansible Galaxy registries for use with your Python and Ansible services.
Default registries
IAG provides default registries for both PyPI and Ansible Galaxy. The following table shows the basic details for these default registries, including the default registry name and the public repository that the registry points to.
Registry | Default registry name | Public repository |
---|---|---|
PyPI | default-pypi |
https://pypi.org/simple |
Ansible Galaxy | default-galaxy |
https://galaxy.ansible.com |
If these registries don't meet your needs, you can delete them and create a new default registry using the iagctl create registry
command and specifying the --default
flag.
Create a registry resource
You can also create a registry resource to specify information about private registries.
The following example creates a Python PyPI registry resource named my-pypi-registry
:
iagctl create registry pypi my-pypi-registry --url 'http://private-repo-hostname:8080/simple' --username admin --password-name pip-password
This command uses the following parameters:
--url
specifies the private repository (http://private-repo-hostname:8080/simple
) that the registry points to--username
specifiesadmin
--password-name
references an IAG secret resource namedpip-password
For more information about creating secrets, see iagctl create secret.
Now consider an example gateway-resources
repository that contains a Python script with dependencies. IAG needs to fetch these dependencies from your private repository as specified in a requirements.txt
file.
gateway-resources repository structure
├── README.md
├── ansibleplaybooks
├── pythonscripts
│ ├── main.py
│ └── requirements.txt
└── opentofuplans
You can create a Python script service as you normally would, but now specify the private registry my-pypi-registry
that you created earlier:
iagctl create service python-script my-py-service --filename main.py --repository t-scripts --working-dir pythonscripts --registry my-pypi-registry
When you execute the service, IAG uses the registry to fetch the dependencies listed in the requirements.txt
file. You can verify this behavior by setting the configuration variable GATEWAY_LOG_LEVEL
to DEBUG
or lower:
2024-11-26T01:04:08Z DBG running command '/Users/gatewayuser/.gateway.d/venv/c4dcfa07a05afcf50a8f10a5f92106661a1b8815/bin/pip3 install -r /Users/gatewayuser/.gateway.d/venv/c4dcfa07a05afcf50a8f10a5f92106661a1b8815/requirements.txt --index-url http://admin:****@private-repo-hostname:8080/simple'
2024-11-26T01:04:09Z DBG command exit status: 0, execution time: 815.119678ms
2024-11-26T01:04:09Z DBG pip dependency install succeeded.
Stdout:
Looking in indexes: http://admin:****@private-repo-hostname:8080/simple
Collecting isOdd (from -r /Users/gatewayuser/.gateway.d/venv/c4dcfa07a05afcf50a8f10a5f92106661a1b8815/requirements.txt (line 1))
Downloading http://private-repo-hostname:8080/packages/isOdd-0.1.2-py3-none-any.whl (1.8 kB)
If you don't want secondary registries to override the default registry, set the GATEWAY_REGISTRY_DEFAULT_OVERRIDABLE
configuration variable to false
.