Runtime Installation for Ansible
Install Python packages at the start of each pipeline run using a requirements.txt file for Ansible playbooks.
This approach installs Python dependencies at the start of each pipeline run using a requirements.txt file in your playbook repository.
Create requirements.txt
Create a requirements.txt file in your playbook repository with your required Python packages:
tabulate==0.9.0
netaddr==0.9.0
jmespath==1.0.1Pin versions using == to ensure reproducibility across pipeline runs.
Add pipeline variable
In your Harness pipeline, add a pipeline variable to point to your requirements file:
Open your pipeline in the Harness UI.
Select Variables in the pipeline editor.
Add a new variable with the following values:
Name:
ANSIBLE_REQUIREMENTSType: String
Value:
requirements.txt
If your requirements file is in a subdirectory, provide the relative path from the repository root:
Run your pipeline
When the pipeline runs, dependencies are installed automatically before your playbook executes. Check the pipeline logs to verify installation:
Complete example
This example demonstrates using the tabulate package installed via requirements.txt:
Directory structure
requirements.txt
playbook.yml
Pipeline variable
Name:
ANSIBLE_REQUIREMENTSValue:
requirements.txt
The ANSIBLE_REQUIREMENTS variable is automatically detected and dependencies are installed before the playbook runs.
Last updated
Was this helpful?