/ansible-lint-rules

ansible-lint rules

Primary LanguagePythonMIT LicenseMIT

Note

This repository has no longer maintained.

Please use some forks, e.g. lean-delivery/ansible-lint-rules

Rules for ansible-lint

This is a rule set for ansible-lint .

These rules are used in the Tsukinowa Inc. , but anyone can use with the license (MIT).

How to use

  1. Install ansible-lint (ex: pip install ansible-lint)
  2. Copy or git clone on your ansible playbook repository with rules name
  3. Run ansible lint with -r rules flag (ex: ansible-lint -r rules <your playbook file>)

Rules

+------------+----------------------------------------------------------------------+ sample message | +============+======================================================================+ playbook | +------------+----------------------------------------------------------------------+ Playbook should has ".yml" extension | +------------+----------------------------------------------------------------------+ +------------+----------------------------------------------------------------------+ Role | +------------+----------------------------------------------------------------------+ Doesn't need a relative path in role | +------------+----------------------------------------------------------------------+ +------------+----------------------------------------------------------------------+ Task | +------------+----------------------------------------------------------------------+ All tasks should be named | +------------+----------------------------------------------------------------------+ Include should has tags | +------------+----------------------------------------------------------------------+ Use ":" YAML syntax when arguments are over 4 | +------------+----------------------------------------------------------------------+ Do not use local_action. use delegate_to: localhost instead | +------------+----------------------------------------------------------------------+ Variable should has space "{{ foo }}" | +------------+----------------------------------------------------------------------+ +------------+----------------------------------------------------------------------+ Module | +------------+----------------------------------------------------------------------+ Octal file permissions must contain leading zero | +------------+----------------------------------------------------------------------+ Template file should has '.j2' extension | +------------+----------------------------------------------------------------------+ +------------+----------------------------------------------------------------------+ Shell/Command alternative module | +------------+----------------------------------------------------------------------+ Use chmod module | +------------+----------------------------------------------------------------------+ Use chown module | +------------+----------------------------------------------------------------------+ Use hostname module | +------------+----------------------------------------------------------------------+ Use mount module | +------------+----------------------------------------------------------------------+ Use nmcli module | +------------+----------------------------------------------------------------------+ Use yum module with file path | +------------+----------------------------------------------------------------------+ Use service module | +------------+----------------------------------------------------------------------+ Use sysctl module | +------------+----------------------------------------------------------------------+ Use ufw module | +------------+----------------------------------------------------------------------+ Use unarchive module | +------------+----------------------------------------------------------------------+ Shell/command module must contain creates or removes | +------------+----------------------------------------------------------------------+ Use file module instead of mkdir, ln -s and so on | +------------+----------------------------------------------------------------------+ +------------+----------------------------------------------------------------------+ Formatting | +------------+----------------------------------------------------------------------+ Trailing whitespace | +------------+----------------------------------------------------------------------+ Line too long | +------------+----------------------------------------------------------------------+ +------------+----------------------------------------------------------------------+

Why so many shell module lint?

Because user may want to use a command to correct use. Since we separete these rule, user can disable specific rule easily.

If you can manage playbook your self, consider set skip_ansible_lint tag.

License

MIT License (same as ansible-lint)