Run your playbook automation to test behavior
Run your playbook using two methods provided by the Ansible VS Code extension.
Procedure
ansible-playbookruns the playbook on your local machine using Ansible Core.ansible-navigatorruns the playbook in an execution environment in the same manner that Ansible Automation Platform runs an automation job. You specify the base image for the execution environment in the Ansible extension settings.
Run your playbook with ansible-playbook
You can run your Ansible playbook locally by using the ansible-playbook command directly within the VS Code extension.
Procedure
The output is displayed in the Terminal tab of the VS Code terminal. The ok=2 and failed=0 messages indicate that the playbook ran successfully.
Run your playbook with ansible-navigator
You can run an Ansible playbook through ansible-navigator by right-clicking the playbook name in the Explorer pane. This procedure explains how to view the playbook’s output and navigate the results for each play and task within the terminal.
Before you begin
- You enabled the use of an execution environment in the Ansible extension settings.
- You entered the path or URL for the execution environment image in the Ansible extension settings.
Procedure
Publish and run your playbook automation
The following procedures describe how to deploy your new playbooks in your instance of Ansible Automation Platform so that you can use them to run automation jobs.
Save your project in SCM
Save your playbook project as a repository in your source control management system, for example GitHub.
Procedure
- Initialize your project directory as a git repository.
- Push your project up to a source control system such as GitHub.
Run your playbook in Ansible Automation Platform
To run your playbook in Ansible Automation Platform, you must create a project in automation controller for the repository where you stored your playbook project. You can then create a job template for each playbook from the project.
Procedure
- In a browser, log in to automation controller.
- Configure a Source Control credential type for your source control system if necessary. See the Creating new credentials section of Using automation execution for more details.
- In automation controller, create a project for the GitHub repository where you stored your playbook project. Refer to the Projects chapter of Using automation execution.
- Create a job template that uses a playbook from the project that you created. Refer to the Job Templates chapter of Using automation execution.
- Run your playbook from automation controller by launching the job template. Refer to the Launching a job template section of Using automation execution.