GET /api/hostgroups
列出所有主机组

GET /api/puppetclasses/:puppetclass_id/hostgroups
列出 Puppet 类别的所有主机组

GET /api/locations/:location_id/hostgroups
列出每个位置的所有主机组

GET /api/organizations/:organization_id/hostgroups
列出每个机构的所有主机组

示例

GET /api/hostgroups
200
{
  "total": 5,
  "subtotal": 5,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "subnet_id": null,
      "subnet_name": null,
      "operatingsystem_id": 309172073,
      "operatingsystem_name": "centos 5.3",
      "domain_id": 22495316,
      "domain_name": "mydomain.net",
      "environment_id": 334344675,
      "environment_name": "production",
      "compute_profile_id": 980190962,
      "compute_profile_name": "1-Small",
      "ancestry": null,
      "parent_id": null,
      "parent_name": null,
      "ptable_id": null,
      "ptable_name": null,
      "medium_id": 980190962,
      "medium_name": "CentOS 5.4",
      "pxe_loader": null,
      "subnet6_id": null,
      "subnet6_name": null,
      "compute_resource_id": null,
      "compute_resource_name": null,
      "architecture_id": 501905019,
      "architecture_name": "x86_64",
      "realm_id": null,
      "realm_name": null,
      "created_at": "2019-09-11 14:32:19 UTC",
      "updated_at": "2019-09-11 14:32:19 UTC",
      "id": 636252244,
      "name": "Common",
      "title": "Common",
      "description": null,
      "puppet_proxy_id": 182953976,
      "puppet_proxy_name": "Puppetmaster Proxy",
      "puppet_ca_proxy_id": null,
      "puppet_ca_proxy_name": null,
      "puppet_proxy": {
        "name": "Puppetmaster Proxy",
        "id": 182953976,
        "url": "http://else.where:4567"
      },
      "puppet_ca_proxy": null,
      "parameters": [
        {
          "priority": null,
          "created_at": "2019-09-11 14:32:19 UTC",
          "updated_at": "2019-09-11 14:32:19 UTC",
          "id": 767575238,
          "name": "group1",
          "parameter_type": null,
          "value": "group1"
        }
      ]
    },
    {
      "subnet_id": null,
      "subnet_name": null,
      "operatingsystem_id": 309172073,
      "operatingsystem_name": "centos 5.3",
      "domain_id": null,
      "domain_name": null,
      "environment_id": 334344675,
      "environment_name": "production",
      "compute_profile_id": null,
      "compute_profile_name": null,
      "ancestry": null,
      "parent_id": null,
      "parent_name": null,
      "ptable_id": null,
      "ptable_name": null,
      "medium_id": 980190962,
      "medium_name": "CentOS 5.4",
      "pxe_loader": null,
      "subnet6_id": null,
      "subnet6_name": null,
      "compute_resource_id": null,
      "compute_resource_name": null,
      "architecture_id": 501905019,
      "architecture_name": "x86_64",
      "realm_id": null,
      "realm_name": null,
      "created_at": "2019-09-11 14:32:19 UTC",
      "updated_at": "2019-09-11 14:32:19 UTC",
      "id": 603241515,
      "name": "db",
      "title": "db",
      "description": null,
      "puppet_proxy_id": 182953976,
      "puppet_proxy_name": "Puppetmaster Proxy",
      "puppet_ca_proxy_id": null,
      "puppet_ca_proxy_name": null,
      "puppet_proxy": {
        "name": "Puppetmaster Proxy",
        "id": 182953976,
        "url": "http://else.where:4567"
      },
      "puppet_ca_proxy": null,
      "parameters": []
    },
    {
      "subnet_id": 1018350795,
      "subnet_name": "five",
      "operatingsystem_id": 309172073,
      "operatingsystem_name": "centos 5.3",
      "domain_id": 22495316,
      "domain_name": "mydomain.net",
      "environment_id": 153855663,
      "environment_name": "global_puppetmaster",
      "compute_profile_id": 980190962,
      "compute_profile_name": "1-Small",
      "ancestry": null,
      "parent_id": null,
      "parent_name": null,
      "ptable_id": 615088209,
      "ptable_name": "Example partition table",
      "medium_id": 980190962,
      "medium_name": "CentOS 5.4",
      "pxe_loader": "PXELinux BIOS",
      "subnet6_id": 51848956,
      "subnet6_name": "six",
      "compute_resource_id": null,
      "compute_resource_name": null,
      "architecture_id": 501905019,
      "architecture_name": "x86_64",
      "realm_id": null,
      "realm_name": null,
      "created_at": "2019-09-11 14:32:19 UTC",
      "updated_at": "2019-09-11 14:32:19 UTC",
      "id": 1,
      "name": "Parent",
      "title": "Parent",
      "description": null,
      "puppet_proxy_id": 182953976,
      "puppet_proxy_name": "Puppetmaster Proxy",
      "puppet_ca_proxy_id": 182953976,
      "puppet_ca_proxy_name": "Puppetmaster Proxy",
      "puppet_proxy": {
        "name": "Puppetmaster Proxy",
        "id": 182953976,
        "url": "http://else.where:4567"
      },
      "puppet_ca_proxy": {
        "name": "Puppetmaster Proxy",
        "id": 182953976,
        "url": "http://else.where:4567"
      },
      "parameters": []
    },
    {
      "subnet_id": null,
      "subnet_name": "five",
      "operatingsystem_id": null,
      "operatingsystem_name": "centos 5.3",
      "domain_id": null,
      "domain_name": "mydomain.net",
      "environment_id": 334344675,
      "environment_name": "production",
      "compute_profile_id": null,
      "compute_profile_name": "1-Small",
      "ancestry": "1",
      "parent_id": 1,
      "parent_name": "Parent",
      "ptable_id": null,
      "ptable_name": "Example partition table",
      "medium_id": null,
      "medium_name": "CentOS 5.4",
      "pxe_loader": "PXELinux BIOS",
      "subnet6_id": null,
      "subnet6_name": "six",
      "compute_resource_id": null,
      "compute_resource_name": null,
      "architecture_id": null,
      "architecture_name": "x86_64",
      "realm_id": null,
      "realm_name": null,
      "created_at": "2019-09-11 14:32:19 UTC",
      "updated_at": "2019-09-11 14:32:19 UTC",
      "id": 928644285,
      "name": "inherited",
      "title": "Parent/inherited",
      "description": null,
      "puppet_proxy_id": null,
      "puppet_proxy_name": "Puppetmaster Proxy",
      "puppet_ca_proxy_id": null,
      "puppet_ca_proxy_name": "Puppetmaster Proxy",
      "puppet_proxy": {
        "name": "Puppetmaster Proxy",
        "id": 182953976,
        "url": "http://else.where:4567"
      },
      "puppet_ca_proxy": {
        "name": "Puppetmaster Proxy",
        "id": 182953976,
        "url": "http://else.where:4567"
      },
      "parameters": []
    },
    {
      "subnet_id": null,
      "subnet_name": null,
      "operatingsystem_id": null,
      "operatingsystem_name": null,
      "domain_id": null,
      "domain_name": null,
      "environment_id": null,
      "environment_name": null,
      "compute_profile_id": null,
      "compute_profile_name": null,
      "ancestry": null,
      "parent_id": null,
      "parent_name": null,
      "ptable_id": null,
      "ptable_name": null,
      "medium_id": null,
      "medium_name": null,
      "pxe_loader": null,
      "subnet6_id": null,
      "subnet6_name": null,
      "compute_resource_id": null,
      "compute_resource_name": null,
      "architecture_id": null,
      "architecture_name": null,
      "realm_id": null,
      "realm_name": null,
      "created_at": "2019-09-11 14:32:19 UTC",
      "updated_at": "2019-09-11 14:32:19 UTC",
      "id": 866317115,
      "name": "Unusual",
      "title": "Unusual",
      "description": null,
      "puppet_proxy_id": 182953976,
      "puppet_proxy_name": "Puppetmaster Proxy",
      "puppet_ca_proxy_id": null,
      "puppet_ca_proxy_name": null,
      "puppet_proxy": {
        "name": "Puppetmaster Proxy",
        "id": 182953976,
        "url": "http://else.where:4567"
      },
      "puppet_ca_proxy": null,
      "parameters": []
    }
  ]
}

参数

参数名字 描述
puppetclass_id
选填

Puppet 类别 ID

Validations:

  • Must be a String

location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

search
选填

过滤结果

Validations:

  • Must be a String

order
选填

排序项和顺序,例如 ‘id DESC’

Validations:

  • Must be a String

page
选填

页号,从 1 开始

Validations:

  • Must be a number.

per_page
选填

每页中显示的返回结果数

Validations:

  • Must be a number.

include
选填

要包含的额外信息类型阵列

Validations:

  • Must be an array of [parameters]

搜索字段

字段名 类型 可能的值
architecture string
class string
config_group string
environment string
host string
id integer
label string
location string
location_id integer
medium string
name string
organization string
organization_id integer
os string
os_description string
os_id integer
os_major string
os_minor string
os_title string
params text
template string
title string

GET /api/hostgroups/:id
显示主机组

示例

GET /api/hostgroups/928644287-hostgroup5
200
{
  "subnet_id": null,
  "subnet_name": null,
  "operatingsystem_id": null,
  "operatingsystem_name": null,
  "domain_id": null,
  "domain_name": null,
  "environment_id": null,
  "environment_name": null,
  "compute_profile_id": null,
  "compute_profile_name": null,
  "ancestry": null,
  "parent_id": null,
  "parent_name": null,
  "ptable_id": null,
  "ptable_name": null,
  "medium_id": null,
  "medium_name": null,
  "pxe_loader": null,
  "subnet6_id": null,
  "subnet6_name": null,
  "compute_resource_id": null,
  "compute_resource_name": null,
  "architecture_id": null,
  "architecture_name": null,
  "realm_id": null,
  "realm_name": null,
  "created_at": "2019-09-11 14:32:23 UTC",
  "updated_at": "2019-09-11 14:32:23 UTC",
  "id": 928644287,
  "name": "hostgroup5",
  "title": "hostgroup5",
  "description": null,
  "puppet_proxy_id": null,
  "puppet_proxy_name": null,
  "puppet_ca_proxy_id": null,
  "puppet_ca_proxy_name": null,
  "puppet_proxy": null,
  "puppet_ca_proxy": null,
  "parameters": [
    {
      "priority": 60,
      "created_at": "2019-09-11 14:32:23 UTC",
      "updated_at": "2019-09-11 14:32:23 UTC",
      "id": 767575240,
      "name": "parameter5",
      "parameter_type": null,
      "value": "parameter value 5"
    }
  ],
  "template_combinations": [],
  "puppetclasses": [],
  "config_groups": [],
  "all_puppetclasses": [],
  "locations": [
    {
      "id": 255093256,
      "name": "Location 1",
      "title": "Location 1",
      "description": null
    }
  ],
  "organizations": [
    {
      "id": 447626438,
      "name": "Organization 1",
      "title": "Organization 1",
      "description": null
    }
  ]
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

show_hidden_parameters
选填

显示隐藏的参数值

Validations:

  • Must be one of: true, false, 1, 0.


POST /api/hostgroups
创建主机组

示例

POST /api/hostgroups
{
  "hostgroup": {
    "name": "TestHostgroup"
  }
}
201
{
  "subnet_id": null,
  "subnet_name": null,
  "operatingsystem_id": null,
  "operatingsystem_name": null,
  "domain_id": null,
  "domain_name": null,
  "environment_id": null,
  "environment_name": null,
  "compute_profile_id": null,
  "compute_profile_name": null,
  "ancestry": null,
  "parent_id": null,
  "parent_name": null,
  "ptable_id": null,
  "ptable_name": null,
  "medium_id": null,
  "medium_name": null,
  "pxe_loader": null,
  "subnet6_id": null,
  "subnet6_name": null,
  "compute_resource_id": null,
  "compute_resource_name": null,
  "architecture_id": null,
  "architecture_name": null,
  "realm_id": null,
  "realm_name": null,
  "created_at": "2019-09-11 14:32:24 UTC",
  "updated_at": "2019-09-11 14:32:24 UTC",
  "id": 928644288,
  "name": "TestHostgroup",
  "title": "TestHostgroup",
  "description": null,
  "puppet_proxy_id": null,
  "puppet_proxy_name": null,
  "puppet_ca_proxy_id": null,
  "puppet_ca_proxy_name": null,
  "puppet_proxy": null,
  "puppet_ca_proxy": null,
  "parameters": [],
  "template_combinations": [],
  "puppetclasses": [],
  "config_groups": [],
  "all_puppetclasses": [],
  "locations": [],
  "organizations": []
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

hostgroup
必填

Validations:

  • Must be a Hash

hostgroup[name]
必填

主机组名称

Validations:

  • Must be a String

hostgroup[description]
选填 , 允许空值

主机组描述

Validations:

  • Must be a String

hostgroup[parent_id]
选填 , 允许空值

主机组父 ID

Validations:

  • Must be a number.

hostgroup[environment_id]
选填 , 允许空值

环境 ID

Validations:

  • Must be a number.

hostgroup[compute_profile_id]
选填 , 允许空值

计算配置文件 ID

Validations:

  • Must be a number.

hostgroup[compute_resource_id]
选填 , 允许空值

计算资源 ID

Validations:

  • Must be a number.

hostgroup[operatingsystem_id]
选填 , 允许空值

操作系统 ID

Validations:

  • Must be a number.

hostgroup[architecture_id]
选填 , 允许空值

架构 ID

Validations:

  • Must be a number.

hostgroup[pxe_loader]
选填 , 允许空值

DHCP 文件名选项(默认为 Grub2/PXELinux)

Validations:

  • Must be one of: None, PXELinux BIOS, PXELinux UEFI, Grub UEFI, Grub2 BIOS, Grub2 ELF, Grub2 UEFI, Grub2 UEFI SecureBoot, Grub2 UEFI HTTP, Grub2 UEFI HTTPS, Grub2 UEFI HTTPS SecureBoot, iPXE Embedded, iPXE UEFI HTTP, iPXE Chain BIOS, iPXE Chain UEFI.

hostgroup[medium_id]
选填 , 允许空值

介质 ID

Validations:

  • Must be a number.

hostgroup[ptable_id]
选填 , 允许空值

分区表 ID

Validations:

  • Must be a number.

hostgroup[subnet_id]
选填 , 允许空值

子网 ID

Validations:

  • Must be a number.

hostgroup[subnet6_id]
选填 , 允许空值

Subnet IPv6 ID

Validations:

  • Must be a number.

hostgroup[domain_id]
选填 , 允许空值

域 ID

Validations:

  • Must be a number.

hostgroup[realm_id]
选填 , 允许空值

范围 ID

Validations:

  • Must be a number.

hostgroup[config_group_ids]
选填 , 允许空值

关联配置组的 ID

Validations:

  • Must be an array of any type

hostgroup[group_parameters_attributes]
选填 , 允许空值

参数阵列

Validations:

  • Must be an Array of nested elements

hostgroup[group_parameters_attributes][name]
必填

参数名称

Validations:

  • Must be a String

hostgroup[group_parameters_attributes][value]
必填

参数值

Validations:

  • Must be a String

hostgroup[puppet_proxy_id]
选填 , 允许空值

Puppet 代理服务器 ID

Validations:

  • Must be a number.

hostgroup[puppet_ca_proxy_id]
选填 , 允许空值

Puppet CA 代理服务器 ID

Validations:

  • Must be a number.

hostgroup[root_pass]
选填 , 允许空值

预配主机中的 root 密码

Validations:

  • Must be a String

hostgroup[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

hostgroup[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type


PUT /api/hostgroups/:id
更新主机组

示例

PUT /api/hostgroups/636252244
{
  "hostgroup": {
    "name": ""
  }
}
422
{
  "error": {
    "id": 636252244,
    "errors": {
      "name": [
        "can't be blank"
      ]
    },
    "full_messages": [
      "Name can't be blank"
    ]
  }
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

hostgroup
必填

Validations:

  • Must be a Hash

hostgroup[name]
选填

主机组名称

Validations:

  • Must be a String

hostgroup[description]
选填 , 允许空值

主机组描述

Validations:

  • Must be a String

hostgroup[parent_id]
选填 , 允许空值

主机组父 ID

Validations:

  • Must be a number.

hostgroup[environment_id]
选填 , 允许空值

环境 ID

Validations:

  • Must be a number.

hostgroup[compute_profile_id]
选填 , 允许空值

计算配置文件 ID

Validations:

  • Must be a number.

hostgroup[compute_resource_id]
选填 , 允许空值

计算资源 ID

Validations:

  • Must be a number.

hostgroup[operatingsystem_id]
选填 , 允许空值

操作系统 ID

Validations:

  • Must be a number.

hostgroup[architecture_id]
选填 , 允许空值

架构 ID

Validations:

  • Must be a number.

hostgroup[pxe_loader]
选填 , 允许空值

DHCP 文件名选项(默认为 Grub2/PXELinux)

Validations:

  • Must be one of: None, PXELinux BIOS, PXELinux UEFI, Grub UEFI, Grub2 BIOS, Grub2 ELF, Grub2 UEFI, Grub2 UEFI SecureBoot, Grub2 UEFI HTTP, Grub2 UEFI HTTPS, Grub2 UEFI HTTPS SecureBoot, iPXE Embedded, iPXE UEFI HTTP, iPXE Chain BIOS, iPXE Chain UEFI.

hostgroup[medium_id]
选填 , 允许空值

介质 ID

Validations:

  • Must be a number.

hostgroup[ptable_id]
选填 , 允许空值

分区表 ID

Validations:

  • Must be a number.

hostgroup[subnet_id]
选填 , 允许空值

子网 ID

Validations:

  • Must be a number.

hostgroup[subnet6_id]
选填 , 允许空值

Subnet IPv6 ID

Validations:

  • Must be a number.

hostgroup[domain_id]
选填 , 允许空值

域 ID

Validations:

  • Must be a number.

hostgroup[realm_id]
选填 , 允许空值

范围 ID

Validations:

  • Must be a number.

hostgroup[config_group_ids]
选填 , 允许空值

关联配置组的 ID

Validations:

  • Must be an array of any type

hostgroup[group_parameters_attributes]
选填 , 允许空值

参数阵列

Validations:

  • Must be an Array of nested elements

hostgroup[group_parameters_attributes][name]
选填

参数名称

Validations:

  • Must be a String

hostgroup[group_parameters_attributes][value]
选填

参数值

Validations:

  • Must be a String

hostgroup[puppet_proxy_id]
选填 , 允许空值

Puppet 代理服务器 ID

Validations:

  • Must be a number.

hostgroup[puppet_ca_proxy_id]
选填 , 允许空值

Puppet CA 代理服务器 ID

Validations:

  • Must be a number.

hostgroup[root_pass]
选填 , 允许空值

预配主机中的 root 密码

Validations:

  • Must be a String

hostgroup[location_ids]
选填 , 允许空值

使用给定 id 替换位置

Validations:

  • Must be an array of any type

hostgroup[organization_ids]
选填 , 允许空值

使用给定 id 替换机构

Validations:

  • Must be an array of any type


DELETE /api/hostgroups/:id
删除主机组

示例

DELETE /api/hostgroups/1-Parent
{
  "hostgroup": {}
}
409
{
  "message": "Cannot delete group Parent because it has nested host groups."
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.


POST /api/hostgroups/:id/clone
克隆主机组

示例

POST /api/hostgroups/636252244/clone
{
  "name": "sdpYHEctpz",
  "hostgroup": {
    "name": "sdpYHEctpz"
  }
}
201
{
  "id": 928644299,
  "name": "sdpYHEctpz",
  "created_at": "2019-09-11T14:32:26.077Z",
  "updated_at": "2019-09-11T14:32:26.077Z",
  "environment_id": 334344675,
  "operatingsystem_id": 309172073,
  "architecture_id": 501905019,
  "medium_id": 980190962,
  "ptable_id": null,
  "root_pass": "$1$foreman$NW1XVtbk4/XkJqmKNrFWV0",
  "puppet_ca_proxy_id": 182953976,
  "use_image": null,
  "image_file": "",
  "ancestry": null,
  "vm_defaults": null,
  "subnet_id": null,
  "domain_id": 22495316,
  "puppet_proxy_id": 182953976,
  "title": "sdpYHEctpz",
  "realm_id": null,
  "compute_profile_id": 980190962,
  "grub_pass": "$1$foreman$NW1XVtbk4/XkJqmKNrFWV0",
  "lookup_value_matcher": "hostgroup=sdpYHEctpz",
  "subnet6_id": null,
  "pxe_loader": null,
  "description": null,
  "compute_resource_id": null
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

name
必填

Validations:

  • Must be a String


PUT /api/hostgroups/:id/rebuild_config
重建业务流程配置

示例

POST /api/hostgroups/928644292-hostgroup7/rebuild_config
{
  "only": [
    "TFTP"
  ],
  "hostgroup": {}
}
200
{
  "message": "Configuration successfully rebuilt."
}

参数

参数名字 描述
location_id
选填

根据位置界定的范围

Validations:

  • Must be a Integer

organization_id
选填

根据机构界定的范围

Validations:

  • Must be a Integer

id
必填

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

only
选填

限制重建步骤,有效步骤是 DHCP, DNS, TFTP

Validations:

  • Must be an array of any type

children_hosts
选填

在子主机组中操作

Validations:

  • Must be one of: true, false, 1, 0.