{"id":20509224,"url":"https://github.com/shinesolutions/ansible-role-vars-schema-validator","last_synced_at":"2025-04-13T22:22:48.340Z","repository":{"id":46814772,"uuid":"178751970","full_name":"shinesolutions/ansible-role-vars-schema-validator","owner":"shinesolutions","description":"Ansible role for validating vars against a schema","archived":false,"fork":false,"pushed_at":"2023-01-24T23:32:47.000Z","size":76,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-27T12:46:27.293Z","etag":null,"topics":["ansible","ansible-role","the-works","validation-schema"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinesolutions.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-31T23:05:15.000Z","updated_at":"2024-06-13T21:18:56.000Z","dependencies_parsed_at":"2023-02-14T02:30:31.335Z","dependency_job_id":null,"html_url":"https://github.com/shinesolutions/ansible-role-vars-schema-validator","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinesolutions%2Fansible-role-vars-schema-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinesolutions%2Fansible-role-vars-schema-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinesolutions%2Fansible-role-vars-schema-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinesolutions%2Fansible-role-vars-schema-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinesolutions","download_url":"https://codeload.github.com/shinesolutions/ansible-role-vars-schema-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248789774,"owners_count":21161891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-role","the-works","validation-schema"],"created_at":"2024-11-15T20:23:24.069Z","updated_at":"2025-04-13T22:22:47.247Z","avatar_url":"https://github.com/shinesolutions.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/shinesolutions/ansible-role-vars-schema-validator/workflows/CI/badge.svg)](https://github.com/shinesolutions/ansible-role-vars-schema-validator/actions?query=workflow%3ACI)\n[![Known Vulnerabilities](https://snyk.io/test/github/shinesolutions/ansible-role-vars-schema-validator/badge.svg)](https://snyk.io/test/github/shinesolutions/ansible-role-vars-schema-validator)\n\nAnsible Role Vars Schema Validator\n----------------------------------\n\nAnsible Role for validating Ansible variables against a YAML schema.\n\nThis role is useful for making sure that the Ansible variables required for your playbooks are valid according to the specified schema, where you can define whether a variable must be a string, or if the variable is mandatory, and various other use cases supported by [Cerberus](https://docs.python-cerberus.org/en/stable/validation-rules.html).\n\n| Ansible Version | Ansible Role Vars Schema Validator Version |\n|-----------------|--------------------------------------------|\n| 4.x             | 1.1.0                                      |\n| 3.x             | 1.0.0                                      |\n| 2.x             | 0.10.0                                     |\n\nInstallation\n------------\n\nInstall [Cerberus](https://pypi.org/project/Cerberus/) Python package:\n\n    pip install cerberus==1.3.2\n\nAdd vars_schema_validator role to `requirements.yml` file:\n\n    - src: shinesolutions_opensource.vars_schema_validator\n      path: roles/\n\nInstall Ansible roles using `ansible-galaxy`:\n\n    ansible-galaxy install --role-file requirements.yml --force\n\nUsage\n-----\n\nCreate a validation schema file using [the rules defined in cerberus](http://docs.python-cerberus.org/en/stable/validation-rules.html).\n\nAdd the role to playbook and specify the schema path:\n\n    roles:\n      - role: 'shinesolutions_opensource.vars_schema_validator'\n        vars:\n          schema: 'path/to/your/schema.yaml'\n\nIn the `path/to/your/schema.yaml` file, specify the validation rules.\n\nRequired and can't be empty:\n\n    some_var:\n      required: true\n      empty: false\n\nShould be a string and from a predefined list:\n\n    some_var:\n      type: string\n      allowed:\n        - some_value_1\n        - some_value_2\n\nShould be an integer:\n\n    some_var:\n      type: integer\n\nShould be a boolean:\n\n    some_var:\n      type: boolean\n\nShould be a list:\n\n    some_var:\n      type: list\n\nShould be a dictionary/map:\n\n    some_var:\n      type: dict\n\nOnly allow configuration properties which are defined in the schema:\nNote that this setting is applied to all descendant properties.\n\n    some_var:\n      allow_unknown: false\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinesolutions%2Fansible-role-vars-schema-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinesolutions%2Fansible-role-vars-schema-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinesolutions%2Fansible-role-vars-schema-validator/lists"}