July 4, 2023 - Words by Sara Platiše - 4 min read
This blog post will explore the Visual Studio Code (VSC) extension of Steampunk Spotter, a powerful tool that enhances your playbook writing experience. With its unique capabilities, Spotter helps you identify and fix errors in your Ansible content, making automation more reliable, secure, and effective.
You can install the extension from the Visual Studio Marketplace or Open VSX Registry.. The extension requires a Spotter user account and the Spotter CLI installed in the console that you use with VS Code by default.
Let’s dive into the setup and scanning process.
Retrieving the CLI path: To begin, you can use the terminal command,
which spotter, to retrieve the path to the Spotter CLI. This step ensures a seamless integration.
Customizing the URL: If using an on-prem Spotter instance, you can customize the URL through the provided field.
API token: You can fetch the token from the Spotter app under “My Settings” in the “Profile settings” section. Once obtained, copy the API token into the corresponding field in the extension’s settings.
Scan level configuration: You can set the path to the configuration file (JSON/YAML).
Project ID: You can organize your scans according to project IDs. You can find the ID in the Spotter app. Copy the project ID into the designated field in the extension’s settings.
Ansible version: You can select the Ansible version against which you want to scan. This option allows you to align the scanning process with your specific Ansible environment.
Values and metadata: By enabling the inclusion of values, Spotter scans not only for names, modules, and parameters but also their corresponding values. Any secrets will be automatically detected and replaced with null values for enhanced security. You can also choose to upload metadata, such as file names, line numbers, and column numbers, for a more detailed analysis.
Display level: The display level determines the level of scans. For example, setting it to “warning” will suppress hints.
Scanning Profile: Spotter offers default, full, and security scanning profiles. The default profile covers basic scanning needs, while the full profile provides a more exhaustive scan. The security profile offers additional recommendations and advice on crafting secure playbooks.
Skipping Checks: If you want to skip specific checks, you need the ID of the check you wish to omit. You can find the check ID in the check catalogue within the Spotter app. Add the check ID to skip it during the scanning process.
Enforcing Checks: If you want to enforce specific checks, you need the ID of the check you wish to enforce. You can find the check ID in the check catalogue within the Spotter app. Add the check ID to enforce it during the scanning process.
Scanning a playbook
Now that the Spotter extension is set up let’s proceed with how to scan a playbook. You right-click and choose “Initiate a new scan.”
Upon completion, Spotter will provide you with a list of identified errors and links to the module documentation.
Spotter offers a rewrite function that can automatically fix many errors. Use this feature to address the identified issues. Once applied, the errors will be resolved, and the playbook will be updated accordingly.
Scanning a directory structure
Extend the scanning process to the entire directory structure. Spotter will scan multiple files within the specified directory and identify any errors.
Automatic scanning on file save
Spotter allows you to automatically scan your files after they are saved to streamline the scanning process, ensuring prompt error detection. If you make a mistake in the code, and save the file, Spotter will immediately notify you of any errors found.
Spotter VSC extension: Your playbook scanning sidekick with a Steampunk twist
We explored the setup and scanning process of the Spotter VSC extension. It offers a range of capabilities to enhance your playbook scanning experience, including automatic error fixing and scanning. Utilizing the extension allows you to optimize your automation workflow and make the most of Spotter.
Elevate your Ansible content writing with the VSC Spotter extension’s Assisted Playbook Writing feature
Try Spotter out and join the Spotter community!