0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【ルール説明・basic】schema

Last updated at Posted at 2022-12-11

こちらの記事はAnsible lint Advent Calendar 2022 12日目の記事になります。

今回はルールschemaについて説明します。

schema

schemaはAnsibleコンテンツのmetaデータがJSONスキーマに対して妥当かどうかを検証します。schemaはAnsible lintの全てのルールの中で一番最初に検査が実行されます。Ansible lintでは必ず守るべきルールの1つになります。

JSONスキーマ

若干分かりにくい概念ですが簡単に言えばmetaデータに記述すべき要素が記述されているか、余分な要素が記述されていないかを検証します。

例えばAnsible roleのmetaデータである meta/main.yml は以下のような要素が指定できます。

galaxy_info:
  role_name: foo
  author: your name
  description: your description
  company: your company (optional)
  license: license (GPLv2, CC-BY, etc)
  min_ansible_version: 1.2
  platforms:
   - name: Fedora
     versions:
     - all
     - 25
   - name: SomePlatform
     versions:
     - all
     - 1.0
  galaxy_tags: []
dependencies: []

この中でgalaxy_info.role_nameは必ず記述する必要があります。galaxy_info.companyはオプションなので記述しなくても検査はパスします。

また例えばgalaxy_info.platforms.releaseのように独自の要素を記述するとエラーになります。

この定義ファイルはschemas/f at main · ansible/schemasansible-meta.jsonで確認できます。

長いです
{
  "$defs": {
    "AIXPlatformModel": {
      "properties": {
        "name": {
          "const": "AIX",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["6.1", "7.1", "7.2", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "AIXPlatformModel",
      "type": "object"
    },
    "AlpinePlatformModel": {
      "properties": {
        "name": {
          "const": "Alpine",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "AlpinePlatformModel",
      "type": "object"
    },
    "AmazonPlatformModel": {
      "properties": {
        "name": {
          "const": "Amazon",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "2013.03",
              "2013.09",
              "2014.03",
              "2014.09",
              "2015.03",
              "2015.09",
              "2016.03",
              "2016.09",
              "2017.03",
              "2017.09",
              "2017.12",
              "2018.03",
              "Candidate",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "AmazonPlatformModel",
      "type": "object"
    },
    "Amazon_Linux_2PlatformModel": {
      "properties": {
        "name": {
          "const": "Amazon Linux 2",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "Amazon Linux 2PlatformModel",
      "type": "object"
    },
    "ArchLinuxPlatformModel": {
      "properties": {
        "name": {
          "const": "ArchLinux",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "ArchLinuxPlatformModel",
      "type": "object"
    },
    "ClearLinuxPlatformModel": {
      "properties": {
        "name": {
          "const": "ClearLinux",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "ClearLinuxPlatformModel",
      "type": "object"
    },
    "CumulusPlatformModel": {
      "properties": {
        "name": {
          "const": "Cumulus",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["2.5", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "CumulusPlatformModel",
      "type": "object"
    },
    "DebianPlatformModel": {
      "properties": {
        "name": {
          "const": "Debian",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "bookworm",
              "bullseye",
              "buster",
              "etch",
              "jessie",
              "lenny",
              "sid",
              "squeeze",
              "stretch",
              "wheezy",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "DebianPlatformModel",
      "type": "object"
    },
    "DellOSPlatformModel": {
      "properties": {
        "name": {
          "const": "DellOS",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["10", "6", "9", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "DellOSPlatformModel",
      "type": "object"
    },
    "DependencyModel": {
      "additionalProperties": true,
      "anyOf": [
        {
          "required": ["role"]
        },
        {
          "required": ["src"]
        },
        {
          "required": ["name"]
        }
      ],
      "markdownDescription": "See https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#role-dependencies and https://github.com/ansible/ansible/blob/devel/lib/ansible/playbook/role/metadata.py#L79\n\nOther keys are treated as role [parameters](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#passing-different-parameters).",
      "properties": {
        "become": {
          "title": "Become",
          "type": "boolean"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "role": {
          "title": "Role",
          "type": "string"
        },
        "scm": {
          "enum": ["hg", "git"],
          "title": "Scm",
          "type": "string"
        },
        "src": {
          "title": "Src",
          "type": "string"
        },
        "tags": {
          "items": {
            "type": "string"
          },
          "title": "Tags",
          "type": ["array", "string"]
        },
        "vars": {
          "title": "Vars",
          "type": "object"
        },
        "version": {
          "title": "Version",
          "type": "string"
        },
        "when": {
          "$ref": "#/$defs/complex_conditional",
          "title": "When"
        }
      },
      "title": "Dependency entry",
      "type": "object"
    },
    "DevuanPlatformModel": {
      "properties": {
        "name": {
          "const": "Devuan",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["ascii", "beowulf", "ceres", "jessie", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "DevuanPlatformModel",
      "type": "object"
    },
    "DragonFlyBSDPlatformModel": {
      "properties": {
        "name": {
          "const": "DragonFlyBSD",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["5.2", "5.4", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "DragonFlyBSDPlatformModel",
      "type": "object"
    },
    "ELPlatformModel": {
      "properties": {
        "name": {
          "const": "EL",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["5", "6", "7", "8", "9", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "ELPlatformModel",
      "type": "object"
    },
    "FedoraPlatformModel": {
      "properties": {
        "name": {
          "const": "Fedora",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "16",
              "17",
              "18",
              "19",
              "20",
              "21",
              "22",
              "23",
              "24",
              "25",
              "26",
              "27",
              "28",
              "29",
              "30",
              "31",
              "32",
              "33",
              "34",
              "35",
              "36",
              "37",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "FedoraPlatformModel",
      "type": "object"
    },
    "FreeBSDPlatformModel": {
      "properties": {
        "name": {
          "const": "FreeBSD",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "10.0",
              "10.1",
              "10.2",
              "10.3",
              "10.4",
              "11.0",
              "11.1",
              "11.2",
              "11.3",
              "11.4",
              "12.0",
              "12.1",
              "12.2",
              "13.0",
              "8.0",
              "8.1",
              "8.2",
              "8.3",
              "8.4",
              "9.0",
              "9.1",
              "9.2",
              "9.3",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "FreeBSDPlatformModel",
      "type": "object"
    },
    "GalaxyInfoModel": {
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "standalone": {
                "const": true
              }
            }
          },
          "then": {
            "$comment": "Standalone role, so we require several fields.",
            "required": [
              "author",
              "description",
              "license",
              "min_ansible_version"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "standalone": {
                "const": false
              }
            }
          },
          "then": {
            "$comment": "Collection roles do not use most galaxy fields.",
            "not": {
              "required": [
                "cloud_platforms",
                "galaxy_tags",
                "min_ansible_version",
                "namespace",
                "platforms",
                "role_name"
              ]
            },
            "required": ["description"]
          }
        }
      ],
      "else": {
        "$comment": "If standalone is false, then we have a collection role and only description is required",
        "required": ["description"]
      },
      "properties": {
        "author": {
          "title": "Author",
          "type": "string"
        },
        "company": {
          "title": "Company",
          "type": "string"
        },
        "description": {
          "title": "Description",
          "type": "string"
        },
        "galaxy_tags": {
          "items": {
            "type": "string"
          },
          "markdownDescription": "See https://galaxy.ansible.com/docs/contributing/creating_role.html",
          "title": "Galaxy Tags",
          "type": "array"
        },
        "issue_tracker_url": {
          "title": "Issue Tracker Url",
          "type": "string"
        },
        "license": {
          "title": "License",
          "type": "string"
        },
        "min_ansible_container_version": {
          "title": "Min Ansible Container Version",
          "type": "string"
        },
        "min_ansible_version": {
          "title": "Min Ansible Version",
          "type": "string"
        },
        "namespace": {
          "markdownDescription": "Used by molecule and ansible-lint to compute FQRN for roles outside collections",
          "minLength": 2,
          "pattern": "^[a-z][a-z0-9_]+$",
          "title": "Namespace Name",
          "type": "string"
        },
        "platforms": {
          "$ref": "#/$defs/platforms"
        },
        "role_name": {
          "minLength": 2,
          "pattern": "^[a-z][a-z0-9_]+$",
          "title": "Role Name",
          "type": "string"
        },
        "standalone": {
          "description:": "Set to true for old standalone roles, or false for new collection roles.",
          "title": "Standalone",
          "type": "boolean"
        }
      },
      "title": "GalaxyInfoModel",
      "type": "object"
    },
    "GenericBSDPlatformModel": {
      "properties": {
        "name": {
          "const": "GenericBSD",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "GenericBSDPlatformModel",
      "type": "object"
    },
    "GenericLinuxPlatformModel": {
      "properties": {
        "name": {
          "const": "GenericLinux",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "GenericLinuxPlatformModel",
      "type": "object"
    },
    "GenericUNIXPlatformModel": {
      "properties": {
        "name": {
          "const": "GenericUNIX",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "GenericUNIXPlatformModel",
      "type": "object"
    },
    "GentooPlatformModel": {
      "properties": {
        "name": {
          "const": "Gentoo",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "GentooPlatformModel",
      "type": "object"
    },
    "HardenedBSDPlatformModel": {
      "properties": {
        "name": {
          "const": "HardenedBSD",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["10", "11", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "HardenedBSDPlatformModel",
      "type": "object"
    },
    "IOSPlatformModel": {
      "properties": {
        "name": {
          "const": "IOS",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "IOSPlatformModel",
      "type": "object"
    },
    "JunosPlatformModel": {
      "properties": {
        "name": {
          "const": "Junos",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "JunosPlatformModel",
      "type": "object"
    },
    "MacOSXPlatformModel": {
      "properties": {
        "name": {
          "const": "MacOSX",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "10.10",
              "10.11",
              "10.12",
              "10.13",
              "10.14",
              "10.15",
              "10.7",
              "10.8",
              "10.9",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "MacOSXPlatformModel",
      "type": "object"
    },
    "MageiaPlatformModel": {
      "properties": {
        "name": {
          "const": "Mageia",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["7", "8", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "MageiaPlatformModel",
      "type": "object"
    },
    "NXOSPlatformModel": {
      "properties": {
        "name": {
          "const": "NXOS",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "NXOSPlatformModel",
      "type": "object"
    },
    "OpenBSDPlatformModel": {
      "properties": {
        "name": {
          "const": "OpenBSD",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "5.6",
              "5.7",
              "5.8",
              "5.9",
              "6.0",
              "6.1",
              "6.2",
              "6.3",
              "6.4",
              "6.5",
              "6.6",
              "6.7",
              "6.8",
              "6.9",
              "7.0",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "OpenBSDPlatformModel",
      "type": "object"
    },
    "OpenWRTPlatformModel": {
      "properties": {
        "name": {
          "const": "OpenWRT",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["17.01", "18.06", "19.07", "21.02", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "OpenWRTPlatformModel",
      "type": "object"
    },
    "OracleLinuxPlatformModel": {
      "properties": {
        "name": {
          "const": "OracleLinux",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "8.0",
              "8.1",
              "8.2",
              "8.3",
              "8.4",
              "8.5",
              "8.6",
              "9.0",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "OracleLinuxPlatformModel",
      "type": "object"
    },
    "PAN-OSPlatformModel": {
      "properties": {
        "name": {
          "const": "PAN-OS",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["7.1", "8.0", "8.1", "9.0", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "PAN-OSPlatformModel",
      "type": "object"
    },
    "SLESPlatformModel": {
      "properties": {
        "name": {
          "const": "SLES",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "10SP3",
              "10SP4",
              "11",
              "11SP1",
              "11SP2",
              "11SP3",
              "11SP4",
              "12",
              "12SP1",
              "12SP2",
              "12SP3",
              "12SP4",
              "12SP5",
              "15",
              "15SP1",
              "15SP2",
              "15SP3",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "SLESPlatformModel",
      "type": "object"
    },
    "SmartOSPlatformModel": {
      "properties": {
        "name": {
          "const": "SmartOS",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "SmartOSPlatformModel",
      "type": "object"
    },
    "SolarisPlatformModel": {
      "properties": {
        "name": {
          "const": "Solaris",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["10", "11.0", "11.1", "11.2", "11.3", "11.4", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "SolarisPlatformModel",
      "type": "object"
    },
    "SynologyPlatformModel": {
      "properties": {
        "name": {
          "const": "Synology",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["6.0", "6.1", "6.2", "7.0", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "SynologyPlatformModel",
      "type": "object"
    },
    "TMOSPlatformModel": {
      "properties": {
        "name": {
          "const": "TMOS",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["12.1", "13.0", "13.1", "14.0", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "TMOSPlatformModel",
      "type": "object"
    },
    "UbuntuPlatformModel": {
      "properties": {
        "name": {
          "const": "Ubuntu",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "artful",
              "bionic",
              "cosmic",
              "cuttlefish",
              "disco",
              "eoan",
              "focal",
              "groovy",
              "hirsute",
              "impish",
              "jammy",
              "lucid",
              "maverick",
              "natty",
              "oneiric",
              "precise",
              "quantal",
              "raring",
              "saucy",
              "trusty",
              "utopic",
              "vivid",
              "wily",
              "xenial",
              "yakkety",
              "zesty",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "UbuntuPlatformModel",
      "type": "object"
    },
    "Void_LinuxPlatformModel": {
      "properties": {
        "name": {
          "const": "Void Linux",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "Void LinuxPlatformModel",
      "type": "object"
    },
    "WindowsPlatformModel": {
      "properties": {
        "name": {
          "const": "Windows",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "2008R2",
              "2008x64",
              "2008x86",
              "2012",
              "2012R2",
              "2016",
              "2019",
              "2022",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "WindowsPlatformModel",
      "type": "object"
    },
    "aosPlatformModel": {
      "properties": {
        "name": {
          "const": "aos",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "aosPlatformModel",
      "type": "object"
    },
    "collections": {
      "items": {
        "markdownDescription": "See [Using collections in roles](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#using-collections-in-roles) and [collection naming conventions](https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_in_groups.html#naming-conventions)",
        "pattern": "^[a-z_]+\\.[a-z_]+$",
        "type": "string"
      },
      "title": "Collections",
      "type": "array"
    },
    "complex_conditional": {
      "oneOf": [
        {
          "type": "boolean"
        },
        {
          "type": "string"
        },
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      ]
    },
    "eosPlatformModel": {
      "properties": {
        "name": {
          "const": "eos",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "eosPlatformModel",
      "type": "object"
    },
    "macOSPlatformModel": {
      "properties": {
        "name": {
          "const": "macOS",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "Big-Sur",
              "Catalina",
              "High-Sierra",
              "Mojave",
              "Monterey",
              "Sierra",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "macOSPlatformModel",
      "type": "object"
    },
    "opensusePlatformModel": {
      "properties": {
        "name": {
          "const": "opensuse",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": [
              "12.1",
              "12.2",
              "12.3",
              "13.1",
              "13.2",
              "15.0",
              "15.1",
              "15.2",
              "15.3",
              "15.4",
              "42.1",
              "42.2",
              "42.3",
              "all"
            ],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "opensusePlatformModel",
      "type": "object"
    },
    "os10PlatformModel": {
      "properties": {
        "name": {
          "const": "os10",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "os10PlatformModel",
      "type": "object"
    },
    "platforms": {
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/AIXPlatformModel"
          },
          {
            "$ref": "#/$defs/AlpinePlatformModel"
          },
          {
            "$ref": "#/$defs/AmazonPlatformModel"
          },
          {
            "$ref": "#/$defs/Amazon_Linux_2PlatformModel"
          },
          {
            "$ref": "#/$defs/aosPlatformModel"
          },
          {
            "$ref": "#/$defs/ArchLinuxPlatformModel"
          },
          {
            "$ref": "#/$defs/ClearLinuxPlatformModel"
          },
          {
            "$ref": "#/$defs/CumulusPlatformModel"
          },
          {
            "$ref": "#/$defs/DebianPlatformModel"
          },
          {
            "$ref": "#/$defs/DellOSPlatformModel"
          },
          {
            "$ref": "#/$defs/DevuanPlatformModel"
          },
          {
            "$ref": "#/$defs/DragonFlyBSDPlatformModel"
          },
          {
            "$ref": "#/$defs/ELPlatformModel"
          },
          {
            "$ref": "#/$defs/eosPlatformModel"
          },
          {
            "$ref": "#/$defs/FedoraPlatformModel"
          },
          {
            "$ref": "#/$defs/FreeBSDPlatformModel"
          },
          {
            "$ref": "#/$defs/GenericBSDPlatformModel"
          },
          {
            "$ref": "#/$defs/GenericLinuxPlatformModel"
          },
          {
            "$ref": "#/$defs/GenericUNIXPlatformModel"
          },
          {
            "$ref": "#/$defs/GentooPlatformModel"
          },
          {
            "$ref": "#/$defs/HardenedBSDPlatformModel"
          },
          {
            "$ref": "#/$defs/IOSPlatformModel"
          },
          {
            "$ref": "#/$defs/JunosPlatformModel"
          },
          {
            "$ref": "#/$defs/macOSPlatformModel"
          },
          {
            "$ref": "#/$defs/MacOSXPlatformModel"
          },
          {
            "$ref": "#/$defs/MageiaPlatformModel"
          },
          {
            "$ref": "#/$defs/NXOSPlatformModel"
          },
          {
            "$ref": "#/$defs/OpenBSDPlatformModel"
          },
          {
            "$ref": "#/$defs/opensusePlatformModel"
          },
          {
            "$ref": "#/$defs/OpenWRTPlatformModel"
          },
          {
            "$ref": "#/$defs/os10PlatformModel"
          },
          {
            "$ref": "#/$defs/PAN-OSPlatformModel"
          },
          {
            "$ref": "#/$defs/SLESPlatformModel"
          },
          {
            "$ref": "#/$defs/SmartOSPlatformModel"
          },
          {
            "$ref": "#/$defs/SolarisPlatformModel"
          },
          {
            "$ref": "#/$defs/SynologyPlatformModel"
          },
          {
            "$ref": "#/$defs/TMOSPlatformModel"
          },
          {
            "$ref": "#/$defs/UbuntuPlatformModel"
          },
          {
            "$ref": "#/$defs/vCenterPlatformModel"
          },
          {
            "$ref": "#/$defs/Void_LinuxPlatformModel"
          },
          {
            "$ref": "#/$defs/vSpherePlatformModel"
          },
          {
            "$ref": "#/$defs/WindowsPlatformModel"
          }
        ]
      },
      "title": "Platforms",
      "type": "array"
    },
    "vCenterPlatformModel": {
      "properties": {
        "name": {
          "const": "vCenter",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["5.5", "6.0", "6.5", "6.7", "7.0", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "vCenterPlatformModel",
      "type": "object"
    },
    "vSpherePlatformModel": {
      "properties": {
        "name": {
          "const": "vSphere",
          "title": "Name",
          "type": "string"
        },
        "versions": {
          "default": "all",
          "items": {
            "enum": ["5.5", "6.0", "6.5", "6.7", "7.0", "all"],
            "type": "string"
          },
          "type": "array"
        }
      },
      "title": "vSpherePlatformModel",
      "type": "object"
    }
  },
  "$id": "https://raw.githubusercontent.com/ansible/schemas/main/f/ansible-meta.json",
  "$schema": "http://json-schema.org/draft-07/schema",
  "examples": ["meta/main.yml"],
  "properties": {
    "additionalProperties": false,
    "allow_duplicates": {
      "title": "Allow Duplicates",
      "type": "boolean"
    },
    "collections": {
      "$ref": "#/$defs/collections"
    },
    "dependencies": {
      "items": {
        "$ref": "#/$defs/DependencyModel"
      },
      "title": "Dependencies",
      "type": "array"
    },
    "galaxy_info": {
      "$ref": "#/$defs/GalaxyInfoModel"
    }
  },
  "title": "Ansible Meta Schema v1/v2",
  "type": ["object", "null"]
}

で417行目あたりからどのキーが必要か確認できます。

.
.
.
            "required": [
              "author",
              "description",
              "license",
              "min_ansible_version"
.
.
.

またAnsibleのmetaデータではあらかじめ決められた要素以外は利用できません

galaxy_info:
  role_name: foo
  author: your name
  description: your description
  company: your company (optional)
  license: license (GPLv2, CC-BY, etc)
  min_ansible_version: 1.2
  platforms:
   - name: Fedora
     release: # <- releaseは定義できない
     - all
     - 25
   - name: SomePlatform
     versions:
     - all
     - 1.0
  galaxy_tags: []
dependencies: []

schemaで検証できるmetaデータ

以下のmetaデータの妥当性を検証できます。

metaデータ 概要
schema[ansible-lint-config] ansible-lint configuration
schema[ansible-navigator] ansible-navigator configuration
schema[arg_specs] module argument specs
schema[execution-environment] execution environments
schema[galaxy] collection metadata
schema[inventory] inventory files that match inventory/*.yml
schema[meta-runtime] runtime information that matches meta/runtime.yml
schema[meta] metadata for roles that match meta/main.yml
schema[playbook] Ansible playbooks
schema[requirements] Ansible requirements files that match requirements.yml
schema[tasks] Ansible task files that match tasks/**/*.yml
schema[vars] Ansible variables that match vars/.yml and defaults/.yml

schemaで何かエラーが出たら定義できない要素を定義している定義されるべき要素が定義されていないかのどちらかなのでAnsibleのマニュアルを良く調べるか定義ファイルを良くめば解決できるかと思います。

参考サイト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?