Friday, November 22, 2019

RedHat Ansible - Code Review Tool - Part 2



In this series, let us see how to use anisble-review and review a simple playbook

Pre-requisites:
  • Ansible installed in any instance
  • simple playbook to run ansible-review

Getting Started: 
  • Below is the code sample I use here for demonstration purpose


  • Now run the playbook using ansible-playbook and watch the output(let the playbook be simple and working copy)
 
 
  • run ansible-review <<playbook name>> in order to get the suggestions from ansible-review
 
  • open the playbook(sample.yml here) and fix the recommended changes 
    • Review comment #1
 
    • Review comment #2
 
    • Review comment #3
    • Review comment #4
 
    corrected as 


 
  • re-run the ansible-review and watch the warnings reduced for each of the changes made against the suggestion(s)
  [EXTRA0008] tasks should not be required in a play
 
The above WARNING can be ignored as it is raised for having 'tasks' keyword in playbook. Such kind of WARNINGs can be ignored on requirement basis
 
By this way, include ansible-review in your continous integration pipelines in Jenkins as a step or in any other integration engine that you have in place and see Ansible doing code complainces and standards enforcement, at ease

No comments:

Post a Comment