iagctl create service ansible-playbook
iagctl create service ansible-playbook
Create a new Ansible playbook service.
The iagctl create service ansible-playbook command creates an Ansible playbook service in the gateway data store. You can then run the service with the iagctl run command. For more information, see Create gateway services.
Consider an Ansible repository called example-repo with the following directory layout:
To create a service from the playbooks in the upgrade-plays directory, specify the repository with --repository, the subdirectory with --working-dir, and the playbook files with --playbook.
Prerequisites
Before you create an Ansible playbook service, you need a repository that contains your playbooks.
Syntax
Usage notes
Extra variables
Pass Ansible extra variables with the --extra-vars flag using key=value syntax or JSON (for example, {"key": "value"}). To reference a variables file in the repository, use --extra-vars-file. The file path must be relative to your --working-dir.
Requirements files
The gateway installs all dependencies listed in requirements.yml and requirements.txt when you run the service. You can specify the Ansible version in requirements.txt. If you don’t specify a version, the gateway installs the latest version. Both requirements files must be in the --working-dir.
Inventory
Specify inventory files with the --inventory flag. You can provide multiple inventory files, and the gateway loads them in the order you specify. File paths must be relative to your --working-dir.
Decorators
You can attach a decorator to the service for input validation at runtime with the --decorator flag. For more information, see iagctl create decorator.
Examples
Create a basic Ansible playbook service
The following example creates a service called my-ansible-service where the playbook main.yml is at the root of the my-repo repository:
Create an Ansible playbook service with all options
The following example creates a service that uses multiple playbooks, an inventory file, extra variables, and several Ansible-specific options: