2.55. Hammer 策略

操作策略

Usage:
    hammer policy [OPTIONS] SUBCOMMAND [ARG] ...

Parameters:
 SUBCOMMAND                    Subcommand
 [ARG] ...                     Subcommand arguments

Subcommands:
 create                        Create a Policy
 delete, destroy               Delete a Policy
 hosts                         List all hosts
 info, show                    Show a Policy
 list, index                   List Policies
 update                        Update a Policy

Options:
 -h, --help                    Print help

2.55.1. Hammer 策略创建

创建策略

Usage:
    hammer policy create [OPTIONS]

Options:
 --cron-line VALUE                  Policy schedule cron line (only if period == “custom”)
 --day-of-month NUMBER              Policy schedule day of month (only if period == “monthly”)
 --deploy-by ENUM                   How the policy should be deployed
                                    Possible value(s): 'puppet', 'ansible', 'manual'
 --description VALUE                Policy description
 --host-ids LIST                    Apply policy to hosts
 --hostgroup-ids LIST               Apply policy to host groups
 --hostgroups LIST
 --hosts LIST
 --location VALUE                   Name to search by
 --location-id NUMBER               Set the current location context for the request
 --location-ids LIST                REPLACE locations with given ids
 --locations LIST
 --name VALUE                       Policy name
 --organization VALUE               Name to search by
 --organization-id NUMBER           Set the current organization context for the request
 --organization-ids LIST            REPLACE organizations with given ids.
 --organizations LIST
 --period VALUE                     Policy schedule period (weekly, monthly, custom)
 --scap-content VALUE               SCAP content title
 --scap-content-id NUMBER           Policy SCAP content ID
 --scap-content-profile VALUE       Name to search by
 --scap-content-profile-id NUMBER   Policy SCAP content profile ID
 --tailoring-file VALUE             Tailoring file name
 --tailoring-file-id NUMBER         Tailoring file ID
 --tailoring-file-profile-id NUMBER Tailoring file profile ID
 --weekday VALUE                    Policy schedule weekday (only if period == “weekly”)
 -h, --help                         Print help

Option details:
  Here you can find option types and the value an option can accept:

  BOOLEAN             One of true/false, yes/no, 1/0
  DATETIME            Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format
  ENUM                Possible values are described in the option's description
  FILE                Path to a file
  KEY_VALUE_LIST      Comma-separated list of key=value.
                      JSON is acceptable and preferred way for such parameters
  LIST                Comma separated list of values. Values containing comma should be quoted or escaped with backslash.
                      JSON is acceptable and preferred way for such parameters
  MULTIENUM           Any combination of possible values described in the option's description
  NUMBER              Numeric value. Integer
  SCHEMA              Comma separated list of values defined by a schema.
                      JSON is acceptable and preferred way for such parameters
  VALUE               Value described in the option's description. Mostly simple string

2.55.2. Hammer 策略删除

删除策略

Usage:
    hammer policy <delete|destroy> [OPTIONS]

Options:
 --id VALUE
 --location VALUE              Set the current location context for the request
 --location-id NUMBER          Set the current location context for the request
 --location-title VALUE        Set the current location context for the request
 --name VALUE                  Name to search by
 --organization VALUE          Set the current organization context for the request
 --organization-id NUMBER      Set the current organization context for the request
 --organization-title VALUE    Set the current organization context for the request
 -h, --help                    Print help

Option details:
  Here you can find option types and the value an option can accept:

  BOOLEAN             One of true/false, yes/no, 1/0
  DATETIME            Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format
  ENUM                Possible values are described in the option's description
  FILE                Path to a file
  KEY_VALUE_LIST      Comma-separated list of key=value.
                      JSON is acceptable and preferred way for such parameters
  LIST                Comma separated list of values. Values containing comma should be quoted or escaped with backslash.
                      JSON is acceptable and preferred way for such parameters
  MULTIENUM           Any combination of possible values described in the option's description
  NUMBER              Numeric value. Integer
  SCHEMA              Comma separated list of values defined by a schema.
                      JSON is acceptable and preferred way for such parameters
  VALUE               Value described in the option's description. Mostly simple string

2.55.3. Hammer 策略主机

列出所有主机

Usage:
    hammer policy hosts [OPTIONS]

Options:
 --fields LIST                 Show specified fields or predefined field sets only. (See below)
 --hostgroup VALUE             Hostgroup name
 --hostgroup-id VALUE          ID of host group
 --hostgroup-title VALUE       Hostgroup title
 --id VALUE                    Policy Id
 --include ENUM                Array of extra information types to include
                               Possible value(s): 'parameters', 'all_parameters'
 --location VALUE              Set the current location context for the request
 --location-id VALUE           ID of location
 --location-title VALUE        Set the current location context for the request
 --name VALUE                  Policy name
 --order VALUE                 Sort and order by a searchable field, e.g. '<field> DESC'
 --organization VALUE          Set the current organization context for the request
 --organization-id VALUE       ID of organization
 --organization-title VALUE    Set the current organization context for the request
 --page NUMBER                 Page number, starting at 1
 --per-page VALUE              Number of results per page to return, 'all' to return all results
 --search VALUE                Filter results
 --thin BOOLEAN                Only list ID and name of hosts
 -h, --help                    Print help

Predefined field sets:
  -----------------------|-----|---------|-----
  FIELDS                 | ALL | DEFAULT | THIN
  -----------------------|-----|---------|-----
  Id                     | x   | x       | x
  Name                   | x   | x       | x
  Operating system       | x   | x       |
  Host group             | x   | x       |
  Ip                     | x   | x       |
  Mac                    | x   | x       |
  Global status          | x   | x       |
  Organization           | x   |         |
  Location               | x   |         |
  Additional information | x   |         |
  Content view           | x   | x       |
  Lifecycle environment  | x   | x       |
  Security               | x   |         |
  Bugfix                 | x   |         |
  Enhancement            | x   |         |
  Trace status           | x   | x       |
  -----------------------|-----|---------|-----

Option details:
  Here you can find option types and the value an option can accept:

  BOOLEAN             One of true/false, yes/no, 1/0
  DATETIME            Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format
  ENUM                Possible values are described in the option's description
  FILE                Path to a file
  KEY_VALUE_LIST      Comma-separated list of key=value.
                      JSON is acceptable and preferred way for such parameters
  LIST                Comma separated list of values. Values containing comma should be quoted or escaped with backslash.
                      JSON is acceptable and preferred way for such parameters
  MULTIENUM           Any combination of possible values described in the option's description
  NUMBER              Numeric value. Integer
  SCHEMA              Comma separated list of values defined by a schema.
                      JSON is acceptable and preferred way for such parameters
  VALUE               Value described in the option's description. Mostly simple string

Search / Order fields:
  activation_key                       string
  activation_key_id                    string
  addon                                string
  addons_status                        Values: mismatched, matched, not_specified
  ansible_role                         string
  applicable_debs                      string
  applicable_errata                    string
  applicable_errata_issued             date
  applicable_rpms                      string
  architecture                         string
  autoheal                             boolean
  boot_time
  build                                Values: true, false
  build_status                         Values: built, pending, token_expired, build_failed
  comment                              text
  compute_resource                     string
  compute_resource_id                  integer
  content_source                       string
  content_view                         string
  content_view_id                      integer
  created_at                           datetime
  cve_id                               integer
  domain                               string
  domain_id                            integer
  errata_status                        Values: security_needed, errata_needed, updated, unknown
  execution_status                     Values: ok, error
  facts                                string
  global_status                        Values: ok, warning, error
  has_ip                               string
  has_mac                              string
  hostgroup                            string
  hostgroup_fullname                   string
  hostgroup_id                         integer
  hostgroup_name                       string
  hostgroup_title                      string
  hypervisor                           boolean
  hypervisor_host                      string
  id                                   integer
  image                                string
  infrastructure_facet.foreman
  infrastructure_facet.smart_proxy_id
  insights_recommendations_count       integer
  installable_errata                   string
  installed_at                         datetime
  ip                                   string
  job_invocation.id                    string
  job_invocation.result                Values: cancelled, failed, pending, success
  last_checkin                         datetime
  last_report                          datetime
  lifecycle_environment                string
  lifecycle_environment_id             integer
  location                             string
  location_id                          integer
  mac                                  string
  managed                              Values: true, false
  model                                string
  name                                 string
  organization                         string
  organization_id                      integer
  origin                               string
  os                                   string
  os_description                       string
  os_id                                integer
  os_major                             string
  os_minor                             string
  os_title                             string
  owner                                string
  owner_id                             integer
  owner_type                           string
  params                               string
  params_name                          string
  parent_hostgroup                     string
  puppet_ca                            string
  puppet_proxy_id                      integer
  puppetmaster                         string
  purpose_status                       Values: mismatched, matched, not_specified
  realm                                string
  realm_id                             integer
  registered_at                        datetime
  registered_through                   string
  release_version                      string
  reported.boot_time
  reported.cores
  reported.disks_total
  reported.ram
  reported.sockets
  reported.virtual                     Values: true, false
  repository                           string
  repository_content_label             string
  role                                 text
  role_status                          Values: mismatched, matched, not_specified
  service_level                        string
  sla_status                           Values: mismatched, matched, not_specified
  smart_proxy                          string
  status.applied                       integer
  status.enabled                       Values: true, false
  status.failed                        integer
  status.failed_restarts               integer
  status.interesting                   Values: true, false
  status.pending                       integer
  status.restarted                     integer
  status.skipped                       integer
  subnet                               string
  subnet.name                          text
  subnet6                              string
  subnet6.name                         text
  subscription_id                      string
  subscription_name                    string
  subscription_status                  Values: valid, partial, invalid, unknown, disabled, unsubscribed_hypervisor
  subscription_uuid                    string
  trace_status                         Values: reboot_needed, process_restart_needed, updated
  upgradable_debs                      string
  upgradable_rpms                      string
  usage                                text
  usage_status                         Values: mismatched, matched, not_specified
  user.firstname                       string
  user.lastname                        string
  user.login                           string
  user.mail                            string
  usergroup                            string
  usergroup.name                       string
  uuid                                 string

2.55.4. Hammer 策略信息

显示策略

Usage:
    hammer policy <info|show> [OPTIONS]

Options:
 --fields LIST                 Show specified fields or predefined field sets only. (See below)
 --id VALUE
 --location VALUE              Set the current location context for the request
 --location-id NUMBER          Set the current location context for the request
 --location-title VALUE        Set the current location context for the request
 --name VALUE                  Name to search by
 --organization VALUE          Set the current organization context for the request
 --organization-id NUMBER      Set the current organization context for the request
 --organization-title VALUE    Set the current organization context for the request
 -h, --help                    Print help

Predefined field sets:
  --------------------------|-----|---------|-----
  FIELDS                    | ALL | DEFAULT | THIN
  --------------------------|-----|---------|-----
  Id                        | x   | x       | x
  Name                      | x   | x       | x
  Created at                | x   | x       |
  Period                    | x   | x       |
  Weekday                   | x   | x       |
  Day of month              | x   | x       |
  Cron line                 | x   | x       |
  Scap content id           | x   | x       |
  Scap content profile id   | x   | x       |
  Tailoring file id         | x   | x       |
  Tailoring file profile id | x   | x       |
  Deployment option         | x   | x       |
  Locations/                | x   | x       |
  Organizations/            | x   | x       |
  Hostgroups/               | x   | x       |
  --------------------------|-----|---------|-----

Option details:
  Here you can find option types and the value an option can accept:

  BOOLEAN             One of true/false, yes/no, 1/0
  DATETIME            Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format
  ENUM                Possible values are described in the option's description
  FILE                Path to a file
  KEY_VALUE_LIST      Comma-separated list of key=value.
                      JSON is acceptable and preferred way for such parameters
  LIST                Comma separated list of values. Values containing comma should be quoted or escaped with backslash.
                      JSON is acceptable and preferred way for such parameters
  MULTIENUM           Any combination of possible values described in the option's description
  NUMBER              Numeric value. Integer
  SCHEMA              Comma separated list of values defined by a schema.
                      JSON is acceptable and preferred way for such parameters
  VALUE               Value described in the option's description. Mostly simple string

2.55.5. Hammer 策略列表

列出策略

Usage:
    hammer policy <list|index> [OPTIONS]

Options:
 --fields LIST                 Show specified fields or predefined field sets only. (See below)
 --location VALUE              Set the current location context for the request
 --location-id NUMBER          Set the current location context for the request
 --location-title VALUE        Set the current location context for the request
 --order VALUE                 Sort and order by a searchable field, e.g. '<field> DESC'
 --organization VALUE          Set the current organization context for the request
 --organization-id NUMBER      Set the current organization context for the request
 --organization-title VALUE    Set the current organization context for the request
 --page NUMBER                 Page number, starting at 1
 --per-page VALUE              Number of results per page to return, 'all' to return all results
 --search VALUE                Filter results
 -h, --help                    Print help

Predefined field sets:
  -----------|-----|---------|-----
  FIELDS     | ALL | DEFAULT | THIN
  -----------|-----|---------|-----
  Id         | x   | x       | x
  Name       | x   | x       | x
  Created at | x   | x       |
  -----------|-----|---------|-----

Option details:
  Here you can find option types and the value an option can accept:

  BOOLEAN             One of true/false, yes/no, 1/0
  DATETIME            Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format
  ENUM                Possible values are described in the option's description
  FILE                Path to a file
  KEY_VALUE_LIST      Comma-separated list of key=value.
                      JSON is acceptable and preferred way for such parameters
  LIST                Comma separated list of values. Values containing comma should be quoted or escaped with backslash.
                      JSON is acceptable and preferred way for such parameters
  MULTIENUM           Any combination of possible values described in the option's description
  NUMBER              Numeric value. Integer
  SCHEMA              Comma separated list of values defined by a schema.
                      JSON is acceptable and preferred way for such parameters
  VALUE               Value described in the option's description. Mostly simple string

Search / Order fields:
  content                 string
  location                string
  location_id             integer
  name                    string
  organization            string
  organization_id         integer
  profile                 string
  tailoring_file          string
  tailoring_file_profile  string

2.55.6. Hammer 策略更新

更新策略

Usage:
    hammer policy update [OPTIONS]

Options:
 --cron-line VALUE                  Policy schedule cron line (only if period == “custom”)
 --day-of-month NUMBER              Policy schedule day of month (only if period == “monthly”)
 --deploy-by ENUM                   How the policy should be deployed
                                    Possible value(s): 'puppet', 'ansible', 'manual'
 --description VALUE                Policy description
 --host-ids LIST                    Apply policy to hosts
 --hostgroup-ids LIST               Apply policy to host groups
 --hostgroups LIST
 --hosts LIST
 --id VALUE
 --location VALUE                   Name to search by
 --location-id NUMBER               Set the current location context for the request
 --location-ids LIST                REPLACE locations with given ids
 --locations LIST
 --name VALUE                       Policy name
 --new-name VALUE                   Policy name
 --organization VALUE               Name to search by
 --organization-id NUMBER           Set the current organization context for the request
 --organization-ids LIST            REPLACE organizations with given ids.
 --organizations LIST
 --period VALUE                     Policy schedule period (weekly, monthly, custom)
 --scap-content VALUE               SCAP content title
 --scap-content-id NUMBER           Policy SCAP content ID
 --scap-content-profile VALUE       Name to search by
 --scap-content-profile-id NUMBER   Policy SCAP content profile ID
 --tailoring-file VALUE             Tailoring file name
 --tailoring-file-id NUMBER         Tailoring file ID
 --tailoring-file-profile-id NUMBER Tailoring file profile ID
 --weekday VALUE                    Policy schedule weekday (only if period == “weekly”)
 -h, --help                         Print help

Option details:
  Here you can find option types and the value an option can accept:

  BOOLEAN             One of true/false, yes/no, 1/0
  DATETIME            Date and time in YYYY-MM-DD HH:MM:SS or ISO 8601 format
  ENUM                Possible values are described in the option's description
  FILE                Path to a file
  KEY_VALUE_LIST      Comma-separated list of key=value.
                      JSON is acceptable and preferred way for such parameters
  LIST                Comma separated list of values. Values containing comma should be quoted or escaped with backslash.
                      JSON is acceptable and preferred way for such parameters
  MULTIENUM           Any combination of possible values described in the option's description
  NUMBER              Numeric value. Integer
  SCHEMA              Comma separated list of values defined by a schema.
                      JSON is acceptable and preferred way for such parameters
  VALUE               Value described in the option's description. Mostly simple string