iagctl create service ansible-playbook
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.
Before you create an Ansible playbook service, you need a repository that contains your playbooks.
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.
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.
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.
You can attach a decorator to the service for input validation at runtime with the --decorator flag. For more information, see iagctl create decorator.
The following example creates a service called my-ansible-service where the playbook main.yml is at the root of the my-repo repository:
The following example creates a service that uses multiple playbooks, an inventory file, extra variables, and several Ansible-specific options: