Octopus.Script exported 2023-02-16 by domrichardson belongs to ‘Ansible’ category.
Step template to run an ansible playbook using bash. Requires Ansible and Ansible-Playbook to run successfully.
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
Ansible Playbook Path
RunAnsible.Playbook.Path =
Enter the full path where the Ansible Playbook yaml is located.
Script body
Steps based on this template will execute the following Bash script.
ansibleInstalled=$(which -a ansible-playbook >/dev/null; echo $?)
if [ $ansibleInstalled -ne 0 ];then
echo "Ansible Not Installed"
exit 1;
fi
ansible-playbook $(get_octopusvariable "RunAnsible.Playbook.Path")
playbookRC=$?
if [ $playbookRC -ne 0 ]; then
exit $playbookRC;
fi
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "02d3b753-e0eb-4bda-9bf3-09c77e54fce1",
"Name": "Run Ansible Playbook (bash)",
"Description": "Step template to run an ansible playbook using bash. Requires Ansible and Ansible-Playbook to run successfully.",
"Version": 1,
"ExportedAt": "2023-02-16T11:39:51.509Z",
"ActionType": "Octopus.Script",
"Author": "domrichardson",
"Packages": [],
"Parameters": [
{
"Id": "c9c94c61-07a7-4e7e-a52c-fec79ecd50d6",
"Name": "RunAnsible.Playbook.Path",
"Label": "Ansible Playbook Path",
"HelpText": "Enter the full path where the Ansible Playbook yaml is located.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"Properties": {
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "Bash",
"Octopus.Action.Script.ScriptBody": "ansibleInstalled=$(which -a ansible-playbook >/dev/null; echo $?)\n\nif [ $ansibleInstalled -ne 0 ];then\n\techo \"Ansible Not Installed\"\n exit 1;\nfi\n\n\nansible-playbook $(get_octopusvariable \"RunAnsible.Playbook.Path\")\nplaybookRC=$?\n\nif [ $playbookRC -ne 0 ]; then\n exit $playbookRC;\nfi"
},
"Category": "Ansible",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/ansible-run-playbook.json",
"Website": "/step-templates/02d3b753-e0eb-4bda-9bf3-09c77e54fce1",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gUIEhU7AxDPmAAAGmlJREFUeNrtnXd8VFXax7/TUiEFwlAmYYAElq4URZT+goiAqCiKFBsvKooiLSC66qtrQRAEFhAFFJcVEKQoIIgU3V0LunwUCxBQL+FSroaQTHomM+8fM2GzCOSmzMy9c8/388mHkjPnzj33/O7zPKc8BwQCgUAgEAgEAoFAIBAIBAKBQCAQCAQCgUAgEAgEAoFAIBAIBAKBQCAQCAQCgUAgEAgEAoFAIBAIBAItYnc4dVWv4D+YRBMETBRWIAGIA2KBhkAHoCXgABoDjQA7EHmZqvKAUxV+MoGf/D85/t/nKLKUc6F4FFkSD0IIJLSWoWIntDucHYAhQG+gKRDv/4kN0FdwlwsEyAa+B/YAmxVZyhJiEQIJpRgS/FahFzAcGKixr5wNbAHeA34ATiuyVCSepBBIoIUxChgHtACaAFYd3IbL7559ASxSZGm/eLJCILUiCrvDGQ+0Bv4XuD9MblEGFgKbgZ8VWSoRrpgQSFVF0gh4EegPJIfpbRYDR4EViiy9KkQiBHJRawGgyBJ2hzMKaA88C9xowOZ41i+W40IsQiAXulLjgUnAnwCzgZslH/gamKrI0tcVXyBCIAYTht3hjAauA1aGsRtVE9YBTyqylGFUi2JYC2J3OAcDc/wBuODSlAD/AkYpsnTSaCIxGVAYrYAFaG/eQg9MA5YrspRtFKGYDCCIinHGKuBWAjezbQRkIF2RpdXCgoSPMLoBm/CtfRLUDluBhxRZygznmwzb0ZoK4tjo96GFOGqXwcBBu8M5rfyFFI5YwtiCdI6NS/gW6IKY7wkUUcCA2LiEFsCn+a6cQrvDSb4rR1gQrbpV/j/n+a1GA9GHg8JY4H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