SSH-Infrastructure / schema / hosts.schema.json
1 contributor
159 lines | 4.516kb
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://next-gen.local/ssh-infrastructure/hosts.schema.json",
  "title": "SSH infrastructure inventory",
  "type": "object",
  "required": ["version", "defaults", "entrypoints", "jumps", "groups"],
  "additionalProperties": false,
  "properties": {
    "version": { "const": 1 },
    "facts": { "type": "object" },
    "ssh_options": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "required": ["options"],
        "additionalProperties": false,
        "properties": {
          "description": { "type": "string" },
          "options": {
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                { "type": "string" },
                { "type": "integer" },
                { "type": "boolean" }
              ]
            }
          }
        }
      }
    },
    "company_managed": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "jump_hosts": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "inherit_globals_on_targets": {
              "type": "array",
              "items": { "type": "string" }
            },
            "match_defaults": {
              "type": "array",
              "items": { "$ref": "#/$defs/companyManagedMatch" }
            }
          }
        }
      }
    },
    "defaults": {
      "type": "object",
      "required": ["jump", "final_host"],
      "additionalProperties": false,
      "properties": {
        "jump": { "$ref": "#/$defs/defaults" },
        "final_host": { "$ref": "#/$defs/defaults" }
      }
    },
    "entrypoints": {
      "type": "object",
      "additionalProperties": { "$ref": "#/$defs/host" }
    },
    "jumps": {
      "type": "object",
      "additionalProperties": {
        "allOf": [
          { "$ref": "#/$defs/host" },
          {
            "type": "object",
            "properties": {
              "role": { "type": "string" }
            }
          }
        ]
      }
    },
    "groups": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "required": ["hosts"],
        "additionalProperties": false,
        "properties": {
          "description": { "type": "string" },
          "default_jump": { "type": "string" },
          "defaults": { "$ref": "#/$defs/defaults" },
          "patterns": {
            "type": "object",
            "additionalProperties": { "$ref": "#/$defs/options" }
          },
          "hosts": {
            "type": "object",
            "additionalProperties": { "$ref": "#/$defs/host" }
          }
        }
      }
    }
  },
  "$defs": {
    "defaults": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "user": { "type": "string" },
        "port": { "type": "integer", "minimum": 1, "maximum": 65535 },
        "connect_timeout": { "type": "integer", "minimum": 1 },
        "connection_attempts": { "type": "integer", "minimum": 1 },
        "auth": { "$ref": "#/$defs/auth" }
      }
    },
    "options": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "connect_timeout": { "type": "integer", "minimum": 1 },
        "connection_attempts": { "type": "integer", "minimum": 1 }
      }
    },
    "companyManagedMatch": {
      "type": "object",
      "required": ["patterns"],
      "additionalProperties": false,
      "properties": {
        "patterns": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        },
        "user": { "type": "string" },
        "port": { "type": "integer", "minimum": 1, "maximum": 65535 }
      }
    },
    "host": {
      "type": "object",
      "required": ["aliases", "hostname"],
      "additionalProperties": false,
      "properties": {
        "aliases": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        },
        "hostname": { "type": "string" },
        "user": { "type": "string" },
        "port": { "type": "integer", "minimum": 1, "maximum": 65535 },
        "identity_file": { "type": "string" },
        "identities_only": { "type": "boolean" },
        "role": { "type": "string" },
        "auth": { "$ref": "#/$defs/auth" }
      }
    },
    "auth": {
      "type": "string",
      "enum": ["key", "password_interactive"]
    }
  }
}