Skip to main content

Add your description here

Project description

ansible-lint-custom-strict-naming

PyPI PyPI Python Versions black Downloads

Ansible is a powerful tool for configuration management. But it is difficult to maintain the YAML playbook quality. Variable maintenance is one of the difficult tasks because they can be overwritten unexpectedly, if you don't care about such like precedence and position where variables are defined.

This is a strict rule for variable naming, using ansible-lint. Strict naming rule is useful to avoid name collision and to search defined position.

Rules

var_name_prefix

  • <role_name>_role__ , <task_name>_tasks__

    • prefix Variables defined in
      <role_name>_role__ roles/<role_name>/tasks/
      <role_name>_tasks__ <not_roles>/**/tasks/
    • In ansible-lint, var-naming[no-role-prefix] require to use <role_name>_ as prefix. But it is not enough to avoid name collision or search defined position. So, I add _role__ or _tasks__ to the prefix.

  • var__, const__

    • prefix description
      var__ Variables dynamically defined by ansible.builtin.set_fact or register
      const__ Variables statistically defined in such like inventory's vars, group_vars and host_vars
  • prefix precedence

    • descending order

      • role or task prefix
      • var or const prefix
    • examples

      var description
      var__fizz defined in playbook by ansible.builtin.set_fact or register
      some_role__var__fizz defined in roles/<role_name>/tasks by ansible.builtin.set_fact or register
      some_role__arg__fizz defined by ansible.builtin.include_role's vars key and shouldn't changed in roles/<role_name>/tasks
      some_role__const__fizz defined only in roles/<role_name>/vars/.
      some_tasks__var__fizz defined in tasks by ansible.builtin.set_fact or register
      some_tasks__const__fizz defined by ansible.builtin.include_role's vars key and not changed in tasks
      tasks:
        - name: Some task
          ansible.builtin.include_role:
            name: <role_name>
          vars:
            some_role__const__one: value1
            some_role__const__two: value2
      

Others

Double underscores?

  • Single underscore (_) is used to separate words. Double underscores (__) are used to separate chunks for readability.
  • examples
    • var__send_message__user_id
    • var__send_message__content
    • some_role__const__app_config__name
    • some_role__const__app_config__token
    • some_role__const__app_config__version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file ansible-lint-custom-strict-naming-0.1.3.tar.gz.

File metadata

File hashes

Hashes for ansible-lint-custom-strict-naming-0.1.3.tar.gz
Algorithm Hash digest
SHA256 979a45308b2b04890824bd0d9233cb3f1e19a8c3418c74b124e34918613ab64f
MD5 4fbf09e3dac0bcb66e795d7ad29dc52f
BLAKE2b-256 ccde0fe947eb1db55d6bf3bd17d393378b555b79611e732ae41200a88f9d2dca

See more details on using hashes here.

File details

Details for the file ansible_lint_custom_strict_naming-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for ansible_lint_custom_strict_naming-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3cc612b6a95a84ffca562faedbc6bf16db308deb271a8265913966f1e5fea4f4
MD5 7d07ca06957a96d49af0f1277efe7619
BLAKE2b-256 a10c98fb753073acf033e282acecf27f604dad10379065a62ab3374e9bd84927

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page