Automatically Apply Fixes

Not only does Spotter find all the errors that could seriously ruin at least your day, if not your whole infrastructure, but it can also automatically fix specific ones for you! Watch DEMO or read blog .

All you have to do is run the Spotter scan command with the --rewrite argument and watch the magic unfold as Spotter automatically changes your Ansible content: 

$ spotter scan --rewrite playbook.yml

While normally scanning, Spotter highlights which checks can be rewritten:

 > spotter scan playbook.yml
   Scanning...success. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00 
   Check results:
   playbook.yml:4:8: ERROR: [E601] Value of state in module file is set to present which does not match any of the possible choices listed in [absent, directory, file, hard, link, touch].
   playbook.yml:4:8: ERROR: [E005] path is a required parameter in module file.
   playbook.yml:4:8: ERROR: [E903] (rewritable) Use a fully-qualified name, such as ansible.builtin.file instead of file.
   playbook.yml:4:8: WARNING: [W104] (rewritable) Use the common task structure for module file instead of an inline action.
   playbook.yml:4:8: HINT: [H1001] (rewritable) Inline passing of parameters is not good practice.
   playbook.yml:4:8: HINT: [H1600] Tasks should always be named using the name parameter.
   playbook.yml:7:8: ERROR: [E903] (rewritable) Use a fully-qualified name, such as community.crypto.x509_certificate instead of openssl_certificate. View docs at https://docs.steampunk.si/plugins/community/crypto/latest/module/x509_certificate.html.
   playbook.yml:12:8: ERROR: [E903] (rewritable) Use a fully-qualified name, such as ansible.builtin.include_tasks instead of include_tasks. 
   playbook.yml:12:8: ERROR: [E1004] (rewritable) Inlined module parameters and variables used in module include_tasks. Not supported from Ansible 2.7.
   Scan summary:
   Spotter took 2.070 s to scan your input.
   It resulted in 6 error(s), 1 warning(s) and 2 hint(s).
   Can rewrite 1 file(s) with 6 change(s).
   Overall status: ERROR
   >  

Then you can easily apply the rewrite, and Spotter neatly summarizes exactly which checks were fixed automatically:

 > spotter scan --rewrite playbook.yml
   Scanning...success. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
   Rewritten check results:
   playbook.yml:4:8: WARNING: [W104] Use the common task structure for module file instead of an inline action.
   playbook.yml:4:8: ERROR: [E903] Use a fully-qualified name, such as ansible.builtin.file instead of file.
   playbook.yml:4:8: HINT: [H1001] Inline passing of parameters is not good practice.
   playbook.yml:7:8: ERROR: [E903] Use a fully-qualified name, such as community.crypto.x509_certificate instead of openssl_certificate. View docs at https://docs.steampunk.si/plugins/community/crypto/latest/module/x509_certificate.html.
   playbook.yml:12:8: ERROR: [E903] Use a fully-qualified name, such as ansible.builtin.include_tasks instead of include_tasks.
   playbook.yml:12:8: ERROR: [E1004] Inlined module parameters and variables used in module include_tasks. Not supported from Ansible 2.7.
   Remaining check results:
   playbook.yml:4:8: ERROR: [E601] Value of state in module file is set to present which does not match any of the possible choices listed in [absent, directory, file, hard, link, touch].
   playbook.yml:4:8: ERROR: [E005] path is a required parameter in module file.
   playbook.yml:4:8: HINT: [H1600] Tasks should always be named using the name parameter.
   Scan summary:
   Spotter took 2.249 s to scan your input.
   It resulted in 6 error(s), 1 warning(s) and 2 hint(s).
   Did rewrite 1 file(s) with 6 change(s).
   Overall status: ERROR
   >