Shared groups API
The shared groups API enables creating host groups based on host filters (the same ones used in inventory) and assigning CMDB data to them.
Create group
URI:https://hub.cfengine.com/api/host-groups/shared/
Method: POST
Parameters:
name(string)Group name.
description(string)Group description.
priority(number)Group priority. Groups with a higher priority will take precedence in case of conflicts when merging CMDB data. (A lower number indicates higher priority, so 1 means 1st priority, 2 means 2nd most important, and so on).
filter(json object) Group filter object. Includes inventory filter and classes filters
- filter(json object) Optional parameter.Inventory filter data. You can use array values for multiple filter, the logic will be AND. Format is
- hostContextInclude(array) Optional parameter.Includes only results that concern hosts which have all specified CFEngine contexts (class) set.
- hostContextExclude(array) Optional parameter.Excludes results that concern hosts which have specified CFEngine context (class) set. Hosts that have at least oneof the specified contexts set will be excluded from the results.
- hostFilter(json object) Optional parameter.
- includes(json object) Optional parameter.Object that specifies hosts to be included.
- includeAdditionally(boolean) Default:
falseDefines if hosts will be added to the results returned by inventory filters or class filters. - entries(json object) Filter entries object. Where the key is an entry type and the value is an array of stringsAllowed entry types:
hostkey,hostname,ip,mac,ip_mask
- includeAdditionally(boolean) Default:
- excludes(json object) Optional parameter.Object that specifies hosts to be excluded.
- entries(json object) Filter entries object. Where the key is an entry type and the value is an array of stringsAllowed entry types:
hostkey,hostname,ip,mac,ip_mask
- entries(json object) Filter entries object. Where the key is an entry type and the value is an array of stringsAllowed entry types:
code{"filter":{"filter":{"Attribute name":{"operator":"value2"}},"hostFilter":{"includes":{"includeAdditionally":false,"entries":{"ip":["192.168.56.5"],"hostkey":[],"hostname":["ubuntu-bionic"],"mac":["08:00:27:0b:a4:99","08:00:27:dd:e1:59","02:9f:d3:59:7e:90"],"ip_mask":["10.0.2.16/16"]}},"excludes":{"entries":{"ip":[],"hostkey":[],"hostname":[],"mac":[],"ip_mask":[]}}},"hostContextExclude":["class_value"],"hostContextInclude":["class_value"]}}
Operators:
For filtering you can use the operators below:
| Operator |
|---|
| < |
| > |
| = |
| != |
| <= |
| >= |
| matches |
| not_match |
| contains |
| not_contain |
| regex_matches |
| regex_not_match |
| is_reported |
| is_not_reported |
curl -k --user <username>:<password> \ -X POST \ https://hub.cfengine.com/api/host-groups/shared/ \ -H 'content-type: application/json' \ -d '{ "name":"AIX hosts", "description":"Host name", "filter":{ "filter": { "Architecture": { "matches": "86" } }, "hostContextInclude": [ "aix" ] } }'Example response:
{"id":"4"}Update group
URI:https://hub.cfengine.com/api/host-groups/shared/:id
Method: PATCH
Parameters:
id(integer)Unique group identifier.
name(string)Group name.
priority(number)Group priority. Groups with a higher priority will take precedence in case of conflicts when merging CMDB data. (A lower number indicates higher priority, so 1 means 1st priority, 2 means 2nd most important, and so on).
description(string)Group description.
filter(json object) Group filter object. Includes inventory filter and classes filters
- filter(json object) Optional parameter.Inventory filter data. You can use array values for multiple filter, the logic will be AND. Format is
- hostContextInclude(array) Optional parameter.Includes only results that concern hosts which have all specified CFEngine contexts (class) set.
- hostContextExclude(array) Optional parameter.Excludes results that concern hosts which have specified CFEngine context (class) set. Hosts that have at least oneof the specified contexts set will be excluded from the results.
- hostFilter(json object) Optional parameter.
- includes(json object) Optional parameter.Object that specifies hosts to be included.
- includeAdditionally(boolean) Default:
falseDefines if hosts will be added to the results returned by inventory filters or class filters. - entries(json object) Filter entries object. Where the key is an entry type and the value is an array of stringsAllowed entry types:
hostkey,hostname,ip,mac,ip_mask
- includeAdditionally(boolean) Default:
- excludes(json object) Optional parameter.Object that specifies hosts to be excluded.
- entries(json object) Filter entries object. Where the key is an entry type and the value is an array of stringsAllowed entry types:
hostkey,hostname,ip,mac,ip_mask
- entries(json object) Filter entries object. Where the key is an entry type and the value is an array of stringsAllowed entry types:
{"filter":{"filter":{"Attribute name":{"operator":"value2"}},"hostFilter":{"includes":{"includeAdditionally":false,"entries":{"ip":["192.168.56.5"],"hostkey":[],"hostname":["ubuntu-bionic"],"mac":["08:00:27:0b:a4:99","08:00:27:dd:e1:59","02:9f:d3:59:7e:90"],"ip_mask":["10.0.2.16/16"]}},"excludes":{"entries":{"ip":[],"hostkey":[],"hostname":[],"mac":[],"ip_mask":[]}}},"hostContextExclude":["class_value"],"hostContextInclude":["class_value"]}}Operators:
For filtering you can use the operators below:
| Operator |
|---|
| < |
| > |
| = |
| != |
| <= |
| >= |
| matches |
| not_match |
| contains |
| not_contain |
| regex_matches |
| regex_not_match |
| is_reported |
| is_not_reported |
Example request:
curl -k --user <username>:<password> \ -X PATCH \ https://hub.cfengine.com/api/host-groups/shared/5 \ -H 'content-type: application/json' \ -d '{ "name":"AIX hosts", "description":"Host name", "filter":{ "filter": { "Architecture": { "matches": "86" } }, "hostContextInclude": [ "aix" ] } }'Example response:
{"id":"4"}Get group
URI:https://hub.cfengine.com/api/host-groups/shared/:id
Method: GET
Parameters:
- id(integer)Unique group identifier.
Example request:
curl -k --user <username>:<password> \ -X GET \ https://hub.cfengine.com/api/host-groups/shared/4 \ -H 'content-type: application/json'Example response:
{"id":4,"name":"AIX hosts","priority":3,"description":"Host name","creator":"admin","creation_time":"2023-06-14 10:41:25.601112+00","filter":{"filter":{"Architecture":{"matches":"86"}},"hostContextExclude":"","hostContextInclude":["aix"]},"type":"shared"}Remove group
URI:https://hub.cfengine.com/api/host-groups/shared/:id
Method: DELETE
Parameters:
- id(integer)Unique group identifier.
Example request:
curl -k --user <username>:<password> \ -X DELETE \ https://hub.cfengine.com/api/host-groups/shared/4 \ -H 'content-type: application/json'Groups list
URI:https://hub.cfengine.com/api/host-groups/shared
Method: GET
Example request:
curl -k --user <username>:<password> \ -X GET \ https://hub.cfengine.com/api/host-groups/shared\ -H 'content-type: application/json'Example response:
{"data":[{"id":1,"name":"All hosts","priority":1,"description":"","creator":"admin","creation_time":"2023-05-29 09:55:36.878271+00","filter":[]},{"id":4,"name":"AIX hosts","priority":2,"description":"Host name","creator":"admin","creation_time":"2023-06-14 10:41:25.601112+00","filter":{"filter":{"Architecture":{"matches":"86"}},"hostContextExclude":"","hostContextInclude":["aix"]}}],"meta":{"count":2,"page":1,"timestamp":1686739758,"total":2,"hostsCountCacheTime":null}}Make shared group personal
URI:https://hub.cfengine.com/api/host-groups/shared/:id/makePersonal
Method: POST
Parameters:
- id(integer)Unique group identifier.
Example request:
curl -k --user <username>:<password> \ -X POST \ https://hub.cfengine.com/api/host-groups/shared/5/makePersonalExample response:
API returns new ID of the personal group.
{"id":"6"}Shared Groups CMDB
The configuration management database (CMDB) API enables you to manage classes and variables for specific host groups.
List CMDB
You can see a list of stored group-specific configurations
URI:https://hub.cfengine.com/api/host-groups/shared/:id/cmdb
Method: GET
Parameters:
- id(integer)Unique group identifier.
- fromEpoch(integer)Returns configurations with epoch value greater than set in the filter.Epoch is the sequence number of the latest CMDB change. In every API list request,
cmdb_epochwill be present in the meta section, which contains the maximumepoch value among selected items. Optional parameter. - fromTime(timestamp)Include changes performed within interval. Format:
YYYY-mm-dd HH:MM:SSorYYYY-mm-dd. Optional parameter. - toTime(timestamp)Include changes performed within interval. Format:
YYYY-mm-dd HH:MM:SSorYYYY-mm-dd. Optional parameter. - skip(integer)Number of results to skip for the processedquery. The Mission Portal uses this for pagination. Optional parameter.
- limit(integer)Limit the number of results in the query. Optional parameter.
Example request (curl):
curl -k --user <username>:<password> \ -X GET \ https://hub.cfengine.com/api/host-groups/shared/4/cmdb?epochFrom=2Example response:
HTTP 200 Ok{ "data": { "5": { "classes": { "My_class": {}, "My_class2": { "comment": "comment helps to understand what this class serves for" } }, "variables": { "HubCMDB:My.hostname": { "value": "host1.cfengine.com", "comment": "comment" }, "Namespace:BundleName.VariableName": { "value": "myvalue" } } } }, "meta": { "count": "1", "page": 1, "timestamp": 1619116399, "total": "1", "cmdb_epoch": "13" }}Get group's specific configuration
URI:https://hub.cfengine.com/api/host-groups/shared/:id/cmdb/:type/:name/
Method: GET
Parameters:
id(integer)Unique group identifier.
type(string)Configuration type. Allowed value:
variables,classesname(string)Configuration name. Classes or variables name.
Example request (curl):
curl -k --user <username>:<password> \ -X GET \ https://hub.cfengine.com/api/host-groups/shared/5/cmdb/variables/HubCMDB:My.hostname/Example response:
HTTP 200 Ok{ "group_id": "5", "variables": { "default:def.augment_inputs": { "tags": [ "suggestion-004" ], "value": [], "comment": "Add filenames to this list to make the CFEngine agent parse them. Note: Update the bundle sequence to evaluate bundles from these policy files." } }}Get group's configurations
URI:https://hub.cfengine.com/api/host-groups/shared/:id/cmdb
Method: GET
Parameters:
- id(string)Unique group identifier.
Example request (curl):
curl -k --user <username>:<password> \ -X GET \ https://hub.cfengine.com/api/host-groups/shared/5/cmdbExample response:
HTTP 200 Ok{ "group_id": "5", "value": { "classes": { "My_class": {}, "My_class2": { "comment": "" } }, "variables": { "HubCMDB:My.hostname": { "value": "host1.cfengine.com", "comment": "My hostname should be set to this" }, "Namespace:BundleName.VariableName": { "value": "myvalue" } } }}Create configuration
URI:https://hub.cfengine.com/api/host-groups/shared/:id/cmdb/:type/:name/
Method: POST
Parameters:
id(string)Unique group identifier.
type(string)Configuration type. Allowed value:
variables,classesname(string)Configuration name. Classes or variables name.
Request body parameters:
value(string|array)Variable value, can be array or text. Classes do not support values.
comment(string)Variables or classes description. Optional parameter.
tags(array)Variables or classes tags. Optional parameter.
Example request (curl):
curl -k --user <username>:<password> \ -X POST \ https://hub.cfengine.com/api/host-groups/shared/5/cmdb/variables/Namespace:BundleName.Ports/ \ -H 'content-type: application/json' \ -d ' { "value": ["80", "443"], "comment":"Openning ports", "tags" : ["ports", "tag"] }'Example response:
HTTP 200 OkUpdate configuration
URI:https://hub.cfengine.com/api/host-groups/shared/:id/cmdb/:type/:name/
Method: PATCH
Parameters:
id(string)Unique group identifier.
type(string)Configuration type. Allowed value:
variables,classesname(string)Configuration name. Classes or variables name.
Request body parameters:
value(string|array)Variable value, can be array or text. Classes do not support values.
comment(string)Variables or classes description. Optional parameter.
tags(array)Variables or classes tags. Optional parameter.
name(string)New name, in case of renaming. Optional parameter.
Example request (curl):
curl -k --user <username>:<password> \ -X PATCH \ https://hub.cfengine.com/api/host-groups/shared/5/cmdb/variables/Namespace:BundleName.Ports/ \ -H 'content-type: application/json' \ -d ' { "value": ["80", "443"], "comment":"Openning ports", "tags" : ["ports", "tag"] }'Example response:
HTTP 200 OkDelete group's configurations
URI:https://hub.cfengine.com/api/host-groups/shared/:id/cmdb
Method: DELETE
Parameters:
- id(string)Unique group identifier.
Example request (curl):
curl -k --user <username>:<password> \ -X DELETE \ https://hub.cfengine.com/api/host-groups/shared/5/cmdbExample response:
HTTP 204 No ContentDelete specific configuration
URI:https://hub.cfengine.com/api/host-groups/shared/:id/cmdb/:type/:name/
Method: DELETE
Parameters:
id(string)Unique group identifier.
type(string)Configuration type. Allowed value:
variables,classesname(string)Configuration name. Classes or variables name.
Example request (curl):
curl -k --user <username>:<password> \ -X DELETE \ https://hub.cfengine.com/api/host-groups/shared/5/cmdb/classes/My_class2/Example response:
HTTP 204 No Content- Overview
- Getting started
- Reference
- Components
- Functions
- accessedbefore
- accumulated
- ago
- and
- basename
- bundlesmatching
- bundlestate
- callstack_callers
- callstack_promisers
- canonify
- canonifyuniquely
- cf_version_after
- cf_version_at
- cf_version_before
- cf_version_between
- cf_version_maximum
- cf_version_minimum
- changedbefore
- classesmatching
- classfiltercsv
- classify
- classmatch
- concat
- countclassesmatching
- countlinesmatching
- data_expand
- data_readstringarray
- data_readstringarrayidx
- data_regextract
- data_sysctlvalues
- datastate
- difference
- dirname
- diskfree
- escape
- eval
- every
- execresult
- execresult_as_data
- expandrange
- file_hash
- fileexists
- filesexist
- filesize
- filestat
- filter
- findfiles
- findfiles_up
- findprocesses
- format
- getclassmetatags
- getenv
- getfields
- getgid
- getindices
- getuid
- getuserinfo
- getusers
- getvalues
- getvariablemetatags
- grep
- groupexists
- hash
- hash_to_int
- hashmatch
- host2ip
- hostinnetgroup
- hostrange
- hostsseen
- hostswithclass
- hubknowledge
- ifelse
- int
- intersection
- ip2host
- iprange
- irange
- isdir
- isexecutable
- isgreaterthan
- isipinsubnet
- islessthan
- islink
- isnewerthan
- isplain
- isreadable
- isvariable
- join
- lastnode
- laterthan
- ldaparray
- ldaplist
- ldapvalue
- length
- lsdir
- makerule
- maparray
- mapdata
- maplist
- max
- mean
- mergedata
- min
- network_connections
- none
- not
- now
- nth
- on
- or
- packagesmatching
- packageupdatesmatching
- parseintarray
- parsejson
- parserealarray
- parsestringarray
- parsestringarrayidx
- parseyaml
- peerleader
- peerleaders
- peers
- processexists
- product
- randomint
- read_module_protocol
- readcsv
- readdata
- readenvfile
- readfile
- readintarray
- readintlist
- readjson
- readrealarray
- readreallist
- readstringarray
- readstringarrayidx
- readstringlist
- readtcp
- readyaml
- regarray
- regcmp
- regex_replace
- regextract
- registryvalue
- regldap
- regline
- reglist
- remoteclassesmatching
- remotescalar
- returnszero
- reverse
- rrange
- selectservers
- shuffle
- some
- sort
- splayclass
- splitstring
- storejson
- strcmp
- strftime
- string
- string_downcase
- string_head
- string_length
- string_mustache
- string_replace
- string_reverse
- string_split
- string_tail
- string_trim
- string_upcase
- sublist
- sum
- sysctlvalue
- translatepath
- type
- unique
- url_get
- usemodule
- userexists
- validdata
- validjson
- variablesmatching
- variablesmatching_as_data
- variance
- version_compare
- Language concepts
- Masterfiles Policy Framework
- promises.cf
- .no-distrib/
- update.cf
- standalone_self_upgrade.cf
- cfe_internal/
- cfe_internal/CFE_cfengine.cf
- cfe_internal/core/
- cfe_internal/core/watchdog
- cfe_internal/core/watchdog/watchdog.cf
- cfe_internal/enterprise/
- cfe_internal/enterprise/federation/
- cfe_internal/enterprise/federation/federation.cf
- cfe_internal/recommendations.cf
- cfe_internal/update/
- cfe_internal/update/cfe_internal_dc_workflow.cf
- cfe_internal/update/cfe_internal_update_from_repository.cf
- cfe_internal/update/lib.cf
- cfe_internal/update/systemd_units.cf
- cfe_internal/update/update_bins.cf
- cfe_internal/update/update_policy.cf
- cfe_internal/update/update_processes.cf
- controls/
- controls/cf_agent.cf
- controls/cf_execd.cf
- controls/cf_hub.cf
- controls/cf_monitord.cf
- controls/cf_runagent.cf
- controls/cf_serverd.cf
- controls/def.cf
- controls/def_inputs.cf
- controls/reports.cf
- controls/update_def.cf
- controls/update_def_inputs.cf
- inventory/
- inventory/any.cf
- inventory/debian.cf
- inventory/freebsd.cf
- inventory/generic.cf
- inventory/linux.cf
- inventory/lsb.cf
- inventory/macos.cf
- inventory/os.cf
- inventory/redhat.cf
- inventory/suse.cf
- inventory/windows.cf
- lib/
- lib/autorun.cf
- lib/bundles.cf
- lib/cfe_internal.cf
- lib/cfe_internal_hub.cf
- lib/cfengine_enterprise_hub_ha.cf
- lib/commands.cf
- lib/common.cf
- lib/databases.cf
- lib/edit_xml.cf
- lib/event.cf
- lib/examples.cf
- lib/feature.cf
- lib/files.cf
- lib/guest_environments.cf
- lib/monitor.cf
- lib/packages.cf
- lib/paths.cf
- lib/processes.cf
- lib/reports.cf
- lib/services.cf
- lib/stdlib.cf
- lib/storage.cf
- lib/testing.cf
- lib/users.cf
- lib/vcs.cf
- modules/
- modules/mustache/
- modules/packages/
- modules/packages/vendored/
- modules/promises/
- modules/promises/cfengine.py
- modules/promises/cfengine.sh
- services/
- services/autorun/
- services/main.cf
- Macros
- Promise types
- Special variables
- All promise and body types
- Release notes
- Web UI
- Settings
- Health
- Hosts
- Alerts and notifications
- Custom actions for alerts
- Enterprise reporting
- Federated reporting
- Measurements app
- Hub administration
- Decommissioning hosts
- Extending Mission Portal
- Extending query builder in Mission Portal
- Adjusting schedules
- Backup and restore
- Configure a custom LDAP port
- Custom LDAPs certificate
- Custom SSL certificate
- Enable plain http
- Lookup license info
- Policy deployment
- Public key distribution
- Re-installing Enterprise hub
- Regenerate self signed SSL certificate
- Reset administrative credentials
- Debugging Mission Portal
- License
- Examples and tutorials
- Example snippets
- General examples
- Administration examples
- Measuring examples
- Software administration examples
- Commands, scripts, and execution examples
- File and directory examples
- File template examples
- Interacting with directory services
- Database examples
- Network examples
- System security examples
- System information examples
- System administration examples
- System file examples
- Windows registry examples
- File permissions
- User management examples
- Common promise patterns
- Aborting execution
- Change detection
- Check filesystem space
- Copy single files
- Create files and directories
- Customize message of the day
- Distribute ssh keys
- Ensure a process is not running
- Ensure a service is enabled and running
- Find the MAC address
- Install packages
- Mount NFS filesystem
- Restart a process
- Set up name resolution with DNS
- Set up sudo
- Set up time management through NTP
- Updating from a central policy server
- Tutorials
- JSON and YAML support in CFEngine
- Installing CFEngine Enterprise agent
- Managing local users
- Managing network time protocol
- Managing processes and services
- Package management
- Writing CFEngine policy
- Distributing files from a central location
- File editing
- Reporting and remediation of security vulnerabilities
- Masterfiles Policy Framework upgrade
- Tags for variables, classes, and bundles
- Custom inventory
- Dashboard alerts
- Integrating alerts with PagerDuty
- Integrating alerts with ticketing systems
- Integrating with Sumo Logic
- Rendering files with Mustache templates
- Reporting
- File comparison
- High availability
- Writing and serving policy
- Example snippets
- Resources
- FAQ
- Why knowledge management?
- Requesting a CFEngine Enterprise License
- Uninstalling / reinstalling
- Agent output email
- Debugging slow queries
- Enterprise Report Filtering
- Enterprise report collection
- Enterprise reporting database
- How can I tell what classes and variables are defined?
- How do I find the public key for a given host
- How do I fix trust after an IP change?
- How do I fix undefined body errors?
- How do I integrate custom policy?
- How do I pass a data type variable?
- Manual execution
- Mustache templating
- Unable to log into Mission Portal
- Users
- What is promise locking?
- Why are remote agents not updating?
- Why are some files inside masterfiles not being updated/distributed?
- Why does CFEngine install into /var/cfengine instead of following the FHS?
- Bootstrapping
- Tuning PostgreSQL
- What did CFEngine do?
- External resources
- Additional topics
- Best practices
- FAQ
- API
- Enterprise API examples
- Enterprise API reference
- Actions API
- Build API
- CMDB API
- Changes REST API
- Federated reporting configuration API
- File changes API
- Health diagnostic API
- Host REST API
- Import & export API
- Import & export compliance report API
- Inventory API
- LDAP authentication API
- Personal groups API
- Query REST API
- SQL schema
- SSH keys API
- Shared groups API
- Status and settings REST API
- Two-factor authentication API
- Users and access-control REST API
- VCS settings API
- Web RBAC API