This Ansible collection provides modules for interacting with the Torque platform, enabling you to manage environments, execute actions, and export outputs.
Install the collection from Ansible Galaxy:
ansible-galaxy collection install torque.collections
Execute actions on resources within a Torque environment.
Parameters:
space
(required): The Torque space nameenvironment
(required): The environment ID within the spacegrain_fullname
(required): The grain full name pathresource
(required): The resource identifier within the grainaction
(required): The action ID to executeapi_token
(optional): Torque API token for authentication. If not provided, usesTORQUE_API_TOKEN
environment variableapi_url
(optional): Base URL for the Torque API (default: https://portal.qtorque.io)
Example Usage:
- name: Execute action on AWS instance
torque.collections.execute_action:
space: 03-Live
environment: tuF7LfdwbCs4
grain_fullname: elk-2
resource: aws_instance.elk_2
action: aws-power-on-ec2-tf
api_token: "{{ torque_api_token }}"
- name: Execute action using environment variable for token
torque.collections.execute_action:
space: production
environment: env_12345
grain_fullname: web-server
resource: aws_instance.web_1
action: restart-service
Execute workflows on resources within a Torque environment.
Parameters:
space
(required): The Torque space nameenvironment
(required): The environment ID within the spacegrain_fullname
(required): The grain full name pathresource
(required): The resource identifier within the grainworkflow_name
(required): The workflow/blueprint name to executerepository_name
(required): The repository name containing the workflowinputs
(optional): Key-value dictionary of inputs for the workflowowner_email
(required): Email address of the workflow ownerexecution_name
(optional): Custom execution name. If not provided, generates as "workflow_name__instantiation__{datetime}"api_token
(optional): Torque API token for authentication. If not provided, usesTORQUE_API_TOKEN
environment variableapi_url
(optional): Base URL for the Torque API (default: https://portal.qtorque.io)
Example Usage:
- name: Execute workflow on vCenter VM
torque.collections.execute_resource_workflow:
space: 03-Live
environment: Rr0LgPNF2j2C
grain_fullname: vcenter-win2012-template
resource: vsphere_virtual_machine.win-vm
workflow_name: vcenter-vm-power-on
repository_name: ProductionBPs
owner_email: admin@example.com
inputs:
vm_name: "test-vm"
cpu_count: 2
api_token: "{{ torque_api_token }}"
- name: Execute workflow with custom execution name
torque.collections.execute_resource_workflow:
space: production
environment: env_12345
grain_fullname: web-server
resource: aws_instance.web_1
workflow_name: server-maintenance
repository_name: MaintenanceBPs
owner_email: devops@example.com
execution_name: "custom-maintenance-task-001"
Exports playbook outputs to a JSON file that Torque uses as grain outputs.
Parameters:
outputs
(required): Dictionary of outputs to export
Example Usage:
- name: Export outputs
torque.collections.export_torque_outputs:
outputs:
output1: "{{ result }}"
database_url: "{{ db_connection_string }}"
server_ip: "{{ ansible_default_ipv4.address }}"
For the execute_action
module, you can provide authentication in two ways:
- Via parameter: Pass the
api_token
parameter directly - Via environment variable: Set the
TORQUE_API_TOKEN
environment variable
Example with environment variable:
export TORQUE_API_TOKEN=your_api_token_here
ansible-playbook your-playbook.yml
- Ansible >= 2.9
- Python >= 3.6
- 1.1.1: Added
execute_resource_workflow
module for executing Torque workflows on resources - 1.1.0: Added
execute_action
module for executing Torque actions on resources - 1.0.2: Initial release with
export_torque_outputs
module
GPL-2.0-or-later
- shirel menahem shirel.m@quali.com
- DBS