little-timmy


Namelittle-timmy JSON
Version 2.2.0 PyPI version JSON
download
home_pageNone
SummaryLittle Timmy will try their best to find those unused Ansible variables.
upload_time2025-01-25 11:06:42
maintainerNone
docs_urlNone
authorHuw
requires_python>=3.9
licenseMIT License Copyright (c) 2024 Huw Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # little-timmy

Little Timmy will try their best to find those unused Ansible variables.

```sh
cd repo/ansible/plays
ansible-galaxy collection install -f -r requirements.yml -p .
ansible-galaxy role install -f -r requirements.yml -p galaxy_roles

pip3 install little-timmy

little-timmy
# or 
python3 -m little_timmy
```

It will find most unused variables in:

- `group_vars`
- `host_vars`
- `vars`
- `defaults`
- `set_facts` - when not defined as key value pairs on a single line
- `register`
- Inventory files

It is unlikely to find unused variables or may generate false positives for:

- Complex, dynamically referenced or created variables
- Variables referenced by YAML anchors
- Variables consumed in any custom python filters or similar
- Non standard(ish) directory layouts

False positives can be ignored with a config file detailed in the [Config](#config) section.

Please raise issues with ideas or contributions with improvements!

## Github Action

Workflow

```yaml
name: little-timmy
on:
  push:
jobs:
  little-timmy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run action
        uses: hoo29/little-timmy@v2-action
```

Variables

```yaml
inputs:
  directory:
    description: The root directory for your ansible
    required: false
    default: "."
  additional_cli_args:
    description: Additional CLI arguments to pass to little-timmy
    required: false
    default: ""
  galaxy_role_requirements_file:
    description: Location, relative to `directory`, of the ansible galaxy roles requirements file.
    required: false
  galaxy_collection_requirements_file:
    description: Location, relative to `directory`, of the ansible galaxy collections requirements file.
    required: false
  ansible_vault_password:
    description: |
      Optional ansible-vault password. The content will be a written to a 
      file and ANSIBLE_VAULT_PASSWORD_FILE set to its location. Only used
      by ansible if a vaulted value is found.
    required: false
    default: replace-me-if-vault-is-used
```

## Version and Tags

The latest version can be found in [CHANGELOG.md](./CHANGELOG.md).

The tags on this repo are used for the Github action and do not relate the published
python module.

## Config

Additional, optional configuration can be specified in a YAML configuration file named `.little-timmy`.
The file can be located at any level between the current working directory and `/`.

The schema for the file is:

```python
{
    "type": "object",
    "properties": {
        "galaxy_dirs": {
            "description": "Directories where ansible-galaxy collections and roles have been installed. Must be within the directory being scanned.",
            "default": ["ansible_collections", "galaxy_roles"],
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "skip_vars": {
            "description": "Variables to skip checking.",
            "default": [],
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "skip_dirs": {
            "description": "Directories to skip loading files from.",
            "default": ["molecule", "venv", "tests"],
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "extra_jinja_context_keys": {
            "description": """
            Locations where there is already a jinja context for evaluation e.g. `when` and `assert.that`.
            Does not require module FQCN. Values are added to .config_loader.DEFAULT_JINJA_CONTEXT_KEYS.
            """,
            "default": [],
            "type": "array",
            "items": {
                "type": "string"
            }
        }
    },
    "additionalProperties": False
}
```

## Help

```text
little-timmy -h

usage: little-timmy [OPTIONS] [directory]

Process a directory path

positional arguments:
  directory             The directory to process

options:
  -h, --help            show this help message and exit
  -c CONFIG_FILE, --config-file CONFIG_FILE
                        Config file to use. By default it will search all dirs to `/` for .little-timmy
  -d, --dave-mode, --no-dave-mode
                        Make logging work on dave's macbook.
  -e, --exit-success, --no-exit-success
                        Exit 0 when unused vars are found.
  -g, --github-action, --no-github-action
                        Output results for github actions.
  -j, --json-output, --no-json-output
                        Output results as json to stdout. Disables the stderr logger.
  -l LOG_LEVEL, --log-level LOG_LEVEL
                        set the logging level (default: INFO).
  -v, --version, --no-version
                        Output the version.
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "little-timmy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Huw",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d9/c1/31fde03f5feba0b36d3178868082378dc0ec16bddaf62d62b361759407c2/little_timmy-2.2.0.tar.gz",
    "platform": null,
    "description": "# little-timmy\n\nLittle Timmy will try their best to find those unused Ansible variables.\n\n```sh\ncd repo/ansible/plays\nansible-galaxy collection install -f -r requirements.yml -p .\nansible-galaxy role install -f -r requirements.yml -p galaxy_roles\n\npip3 install little-timmy\n\nlittle-timmy\n# or \npython3 -m little_timmy\n```\n\nIt will find most unused variables in:\n\n- `group_vars`\n- `host_vars`\n- `vars`\n- `defaults`\n- `set_facts` - when not defined as key value pairs on a single line\n- `register`\n- Inventory files\n\nIt is unlikely to find unused variables or may generate false positives for:\n\n- Complex, dynamically referenced or created variables\n- Variables referenced by YAML anchors\n- Variables consumed in any custom python filters or similar\n- Non standard(ish) directory layouts\n\nFalse positives can be ignored with a config file detailed in the [Config](#config) section.\n\nPlease raise issues with ideas or contributions with improvements!\n\n## Github Action\n\nWorkflow\n\n```yaml\nname: little-timmy\non:\n  push:\njobs:\n  little-timmy:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: Run action\n        uses: hoo29/little-timmy@v2-action\n```\n\nVariables\n\n```yaml\ninputs:\n  directory:\n    description: The root directory for your ansible\n    required: false\n    default: \".\"\n  additional_cli_args:\n    description: Additional CLI arguments to pass to little-timmy\n    required: false\n    default: \"\"\n  galaxy_role_requirements_file:\n    description: Location, relative to `directory`, of the ansible galaxy roles requirements file.\n    required: false\n  galaxy_collection_requirements_file:\n    description: Location, relative to `directory`, of the ansible galaxy collections requirements file.\n    required: false\n  ansible_vault_password:\n    description: |\n      Optional ansible-vault password. The content will be a written to a \n      file and ANSIBLE_VAULT_PASSWORD_FILE set to its location. Only used\n      by ansible if a vaulted value is found.\n    required: false\n    default: replace-me-if-vault-is-used\n```\n\n## Version and Tags\n\nThe latest version can be found in [CHANGELOG.md](./CHANGELOG.md).\n\nThe tags on this repo are used for the Github action and do not relate the published\npython module.\n\n## Config\n\nAdditional, optional configuration can be specified in a YAML configuration file named `.little-timmy`.\nThe file can be located at any level between the current working directory and `/`.\n\nThe schema for the file is:\n\n```python\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"galaxy_dirs\": {\n            \"description\": \"Directories where ansible-galaxy collections and roles have been installed. Must be within the directory being scanned.\",\n            \"default\": [\"ansible_collections\", \"galaxy_roles\"],\n            \"type\": \"array\",\n            \"items\": {\n                \"type\": \"string\"\n            }\n        },\n        \"skip_vars\": {\n            \"description\": \"Variables to skip checking.\",\n            \"default\": [],\n            \"type\": \"array\",\n            \"items\": {\n                \"type\": \"string\"\n            }\n        },\n        \"skip_dirs\": {\n            \"description\": \"Directories to skip loading files from.\",\n            \"default\": [\"molecule\", \"venv\", \"tests\"],\n            \"type\": \"array\",\n            \"items\": {\n                \"type\": \"string\"\n            }\n        },\n        \"extra_jinja_context_keys\": {\n            \"description\": \"\"\"\n            Locations where there is already a jinja context for evaluation e.g. `when` and `assert.that`.\n            Does not require module FQCN. Values are added to .config_loader.DEFAULT_JINJA_CONTEXT_KEYS.\n            \"\"\",\n            \"default\": [],\n            \"type\": \"array\",\n            \"items\": {\n                \"type\": \"string\"\n            }\n        }\n    },\n    \"additionalProperties\": False\n}\n```\n\n## Help\n\n```text\nlittle-timmy -h\n\nusage: little-timmy [OPTIONS] [directory]\n\nProcess a directory path\n\npositional arguments:\n  directory             The directory to process\n\noptions:\n  -h, --help            show this help message and exit\n  -c CONFIG_FILE, --config-file CONFIG_FILE\n                        Config file to use. By default it will search all dirs to `/` for .little-timmy\n  -d, --dave-mode, --no-dave-mode\n                        Make logging work on dave's macbook.\n  -e, --exit-success, --no-exit-success\n                        Exit 0 when unused vars are found.\n  -g, --github-action, --no-github-action\n                        Output results for github actions.\n  -j, --json-output, --no-json-output\n                        Output results as json to stdout. Disables the stderr logger.\n  -l LOG_LEVEL, --log-level LOG_LEVEL\n                        set the logging level (default: INFO).\n  -v, --version, --no-version\n                        Output the version.\n```\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2024 Huw\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "Little Timmy will try their best to find those unused Ansible variables.",
    "version": "2.2.0",
    "project_urls": {
        "Homepage": "https://github.com/hoo29/little-timmy"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2cdd01e688d61b218dd1bad0c053fcc87e7fc498d5964ba7150a37280ad64636",
                "md5": "037cf75386e0f370e0de8aae59fe789a",
                "sha256": "9a70a54b6ce63f81a07b28777f4d11a6fe522e22975b508df33bfc38922044c3"
            },
            "downloads": -1,
            "filename": "little_timmy-2.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "037cf75386e0f370e0de8aae59fe789a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 11667,
            "upload_time": "2025-01-25T11:06:41",
            "upload_time_iso_8601": "2025-01-25T11:06:41.053953Z",
            "url": "https://files.pythonhosted.org/packages/2c/dd/01e688d61b218dd1bad0c053fcc87e7fc498d5964ba7150a37280ad64636/little_timmy-2.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d9c131fde03f5feba0b36d3178868082378dc0ec16bddaf62d62b361759407c2",
                "md5": "f6ff7b4bfb2ec3f26dc6e76d0e2018ca",
                "sha256": "2ea9e64f03f65ab92c8c2a85d36b099f425970b421a1d24e4bed973230f45a6c"
            },
            "downloads": -1,
            "filename": "little_timmy-2.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f6ff7b4bfb2ec3f26dc6e76d0e2018ca",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 11633,
            "upload_time": "2025-01-25T11:06:42",
            "upload_time_iso_8601": "2025-01-25T11:06:42.918473Z",
            "url": "https://files.pythonhosted.org/packages/d9/c1/31fde03f5feba0b36d3178868082378dc0ec16bddaf62d62b361759407c2/little_timmy-2.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-25 11:06:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hoo29",
    "github_project": "little-timmy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "little-timmy"
}
        
Huw
Elapsed time: 0.70828s