redhat-performance / jetlag

Automation to deploy Bare-metal OpenShift leveraging the Assisted-Installer
Apache License 2.0
26 stars 40 forks source link

Apply ansible-lint default rules #492

Open rabin-io opened 3 months ago

rabin-io commented 3 months ago

Current state,

                        Rule Violation Summary                        
 count tag                      profile    rule associated tags       
    13 command-instead-of-shell basic      command-shell, idiom       
     2 key-order[task]          basic      formatting                 
     1 literal-compare          basic      idiom                      
    70 jinja[spacing]           basic      formatting (warning)       
     2 schema[playbook]         basic      core                       
     9 name[missing]            basic      idiom                      
     9 yaml[colons]             basic      formatting, yaml           
     1 yaml[commas]             basic      formatting, yaml           
     2 yaml[comments]           basic      formatting, yaml           
     2 yaml[empty-lines]        basic      formatting, yaml           
     2 yaml[hyphens]            basic      formatting, yaml           
   308 yaml[indentation]        basic      formatting, yaml           
    92 yaml[line-length]        basic      formatting, yaml           
     8 yaml[octal-values]       basic      formatting, yaml           
     4 yaml[trailing-spaces]    basic      formatting, yaml           
    31 yaml[truthy]             basic      formatting, yaml           
    12 name[template]           moderate   idiom                      
     3 name[casing]             moderate   idiom                      
    93 risky-file-permissions   safety     unpredictability           
    21 risky-shell-pipe         safety     command-shell              
    11 ignore-errors            shared     unpredictability           
   153 no-changed-when          shared     command-shell, idempotency 
     1 no-handler               shared     idiom                      
   589 fqcn[action-core]        production formatting                 
    20 fqcn[action]             production formatting                 
     2 run-once[task]                      idiom                      

Failed: 1391 failure(s), 70 warning(s) on 259 files. Last profile that met the validation criteria was 'min'.

A quick win/fix with ansible-lint --fix can reduce this to

$ ansible-lint --fix=fqcn ansible/*

Modified 104 files.
                       Rule Violation Summary                       
 count tag                      profile  rule associated tags       
    13 command-instead-of-shell basic    command-shell, idiom       
     2 key-order[task]          basic    formatting                 
     1 literal-compare          basic    idiom                      
    70 jinja[spacing]           basic    formatting (warning)       
     2 schema[playbook]         basic    core                       
     9 name[missing]            basic    idiom                      
     2 yaml[comments]           basic    formatting, yaml           
    18 yaml[line-length]        basic    formatting, yaml           
    12 name[template]           moderate idiom                      
     3 name[casing]             moderate idiom                      
    93 risky-file-permissions   safety   unpredictability           
    21 risky-shell-pipe         safety   command-shell              
    11 ignore-errors            shared   unpredictability           
   153 no-changed-when          shared   command-shell, idempotency 
     1 no-handler               shared   idiom                      
     2 run-once[task]                    idiom                      

Failed: 343 failure(s), 70 warning(s) on 259 files. Last profile that met the validation criteria was 'min'.
rabin-io commented 3 months ago

What do you think @akrzos ?

akrzos commented 3 months ago

I most likely do not agree with all of the defaults, for example I don't think we should waste time or space adding extra indents to an array that already indents naturally. There are likely some changes in there that break stuff, so without testing we can not just apply all of ansible lint suggestions.

rabin-io commented 3 months ago

Yes, I understand your distaste for some of the rules, but most have been accepted by default. I actually think that adhering to a standard creates uniformity, and it actually helps in writing consistent code.