Commit e2a15193 authored by Darko Poljak's avatar Darko Poljak

Merge inventory from beta branch.

parent 2b6177c9
......@@ -11,6 +11,9 @@ docs/src/cdist-reference.rst
# Ignore cdist cache for version control
/cache/
# Ignore inventory basedir
cdist/inventory/
# Python: cache, distutils, distribution in general
__pycache__/
*.pyc
......
This diff is collapsed.
......@@ -17,9 +17,9 @@ REQUIRED PARAMETERS
uri
The uri from which to fetch the tarball.
Can be anything understood by curl, e.g:
| http://path/to/stage.tgz
| tftp:///path/to/stage.tgz
| file:///local/path/stage.tgz
| http://path/to/stage.tgz
| tftp:///path/to/stage.tgz
| file:///local/path/stage.tgz
OPTIONAL PARAMETERS
......
......@@ -38,6 +38,9 @@ import cdist.hostsource
import cdist.exec.local
import cdist.exec.remote
from cdist import inventory
import cdist.util.ipaddr as ipaddr
from cdist import core
......@@ -134,11 +137,42 @@ class Config(object):
base_root_path = cls.create_base_root_path(args.out_path)
hostcnt = 0
for host in itertools.chain(cls.hosts(args.host),
cls.hosts(args.hostfile)):
if args.tag or args.all_tagged_hosts:
inventory.determine_default_inventory_dir(args)
if args.all_tagged_hosts:
inv_list = inventory.InventoryList(
hosts=None, istag=True, hostfile=None,
db_basedir=args.inventory_dir)
else:
inv_list = inventory.InventoryList(
hosts=args.host, istag=True, hostfile=args.hostfile,
db_basedir=args.inventory_dir,
has_all_tags=args.has_all_tags)
it = inv_list.entries()
else:
it = itertools.chain(cls.hosts(args.host),
cls.hosts(args.hostfile))
for entry in it:
if isinstance(entry, tuple):
# if configuring by specified tags
host = entry[0]
host_tags = entry[1]
else:
# if configuring by host then check inventory for tags
host = entry
inventory.determine_default_inventory_dir(args)
inv_list = inventory.InventoryList(
hosts=(host,), db_basedir=args.inventory_dir)
inv = tuple(inv_list.entries())
if inv:
# host is present in inventory and has tags
host_tags = inv[0][1]
else:
# host is not present in inventory or has no tags
host_tags = None
host_base_path, hostdir = cls.create_host_base_dirs(
host, base_root_path)
log.debug("Base root path for target host \"{}\" is \"{}\"".format(
host, host_base_path))
......@@ -147,11 +181,12 @@ class Config(object):
log.trace("Creating child process for %s", host)
process[host] = multiprocessing.Process(
target=cls.onehost,
args=(host, host_base_path, hostdir, args, True))
args=(host, host_tags, host_base_path, hostdir, args,
True))
process[host].start()
else:
try:
cls.onehost(host, host_base_path, hostdir,
cls.onehost(host, host_tags, host_base_path, hostdir,
args, parallel=False)
except cdist.Error as e:
failed_hosts.append(host)
......@@ -199,7 +234,8 @@ class Config(object):
return (remote_exec, remote_copy, )
@classmethod
def onehost(cls, host, host_base_path, host_dir_name, args, parallel):
def onehost(cls, host, host_tags, host_base_path, host_dir_name, args,
parallel):
"""Configure ONE system"""
log = logging.getLogger(host)
......@@ -216,6 +252,7 @@ class Config(object):
local = cdist.exec.local.Local(
target_host=target_host,
target_host_tags=host_tags,
base_root_path=host_base_path,
host_dir_name=host_dir_name,
initial_manifest=args.manifest,
......
......@@ -56,6 +56,7 @@ gencode-local
__object_fq: full qualified object id, iow: $type.name + / + object_id
__type: full qualified path to the type's dir
__files: full qualified path to the files dir
__target_host_tags: comma spearated list of host tags
returns: string containing the generated code or None
......@@ -74,6 +75,7 @@ gencode-remote
__object_fq: full qualified object id, iow: $type.name + / + object_id
__type: full qualified path to the type's dir
__files: full qualified path to the files dir
__target_host_tags: comma spearated list of host tags
returns: string containing the generated code or None
......@@ -106,6 +108,7 @@ class Code(object):
'__target_fqdn': self.target_host[2],
'__global': self.local.base_path,
'__files': self.local.files_path,
'__target_host_tags': self.local.target_host_tags,
}
def _run_gencode(self, cdist_object, which):
......
......@@ -77,6 +77,7 @@ class Explorer(object):
'__target_hostname': self.target_host[1],
'__target_fqdn': self.target_host[2],
'__explorer': self.remote.global_explorer_path,
'__target_host_tags': self.local.target_host_tags,
}
self._type_explorers_transferred = []
self.jobs = jobs
......
......@@ -42,6 +42,7 @@ common:
types are defined for use in type emulator
== local.type_path
__files: full qualified path to the files dir
__target_host_tags: comma spearated list of host tags
initial manifest is:
script: full qualified path to the initial manifest
......@@ -109,6 +110,7 @@ class Manifest(object):
'__target_hostname': self.target_host[1],
'__target_fqdn': self.target_host[2],
'__files': self.local.files_path,
'__target_host_tags': self.local.target_host_tags,
}
if self.log.getEffectiveLevel() == logging.DEBUG:
......
......@@ -49,6 +49,7 @@ class Local(object):
"""
def __init__(self,
target_host,
target_host_tags,
base_root_path,
host_dir_name,
exec_path=sys.argv[0],
......@@ -58,6 +59,10 @@ class Local(object):
quiet_mode=False):
self.target_host = target_host
if target_host_tags is None:
self.target_host_tags = ""
else:
self.target_host_tags = ",".join(target_host_tags)
self.hostdir = host_dir_name
self.base_path = os.path.join(base_root_path, "data")
......
This diff is collapsed.
......@@ -44,6 +44,7 @@ class Shell(object):
"cdist-shell-no-target-host",
"cdist-shell-no-target-host",
)
self.target_host_tags = ""
host_dir_name = cdist.str_hash(self.target_host[0])
base_root_path = tempfile.mkdtemp()
......@@ -51,6 +52,7 @@ class Shell(object):
self.local = cdist.exec.local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=host_base_path,
host_dir_name=host_dir_name)
......@@ -77,6 +79,7 @@ class Shell(object):
'__manifest': self.local.manifest_path,
'__explorer': self.local.global_explorer_path,
'__files': self.local.files_path,
'__target_host_tags': self.local.target_host_tags,
}
self.env.update(additional_env)
......
......@@ -42,6 +42,7 @@ class CdistTestCase(unittest.TestCase):
'cdisttesthost',
'cdisttesthost',
)
target_host_tags = "tag1,tag2,tag3"
def mkdtemp(self, **kwargs):
return tempfile.mkdtemp(prefix='tmp.cdist.test.', **kwargs)
......
......@@ -46,6 +46,7 @@ class CodeTestCase(test.CdistTestCase):
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir,
exec_path=cdist.test.cdist_exec_path,
......@@ -97,6 +98,8 @@ class CodeTestCase(test.CdistTestCase):
self.cdist_object.object_id)
self.assertEqual(output_dict['__object_name'], self.cdist_object.name)
self.assertEqual(output_dict['__files'], self.local.files_path)
self.assertEqual(output_dict['__target_host_tags'],
self.local.target_host_tags)
def test_run_gencode_remote_environment(self):
output_string = self.code.run_gencode_remote(self.cdist_object)
......@@ -120,6 +123,8 @@ class CodeTestCase(test.CdistTestCase):
self.cdist_object.object_id)
self.assertEqual(output_dict['__object_name'], self.cdist_object.name)
self.assertEqual(output_dict['__files'], self.local.files_path)
self.assertEqual(output_dict['__target_host_tags'],
self.local.target_host_tags)
def test_transfer_code_remote(self):
self.cdist_object.code_remote = self.code.run_gencode_remote(
......
......@@ -9,3 +9,4 @@ echo "echo __object: $__object"
echo "echo __object_id: $__object_id"
echo "echo __object_name: $__object_name"
echo "echo __files: $__files"
echo "echo __target_host_tags: $__target_host_tags"
......@@ -60,6 +60,7 @@ class ConfigRunTestCase(test.CdistTestCase):
os.makedirs(self.host_base_path)
self.local = cdist.exec.local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir)
......@@ -164,6 +165,7 @@ class ConfigRunTestCase(test.CdistTestCase):
"""Test if the dryrun option is working like expected"""
drylocal = cdist.exec.local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir,
# exec_path can not derivated from sys.argv in case of unittest
......@@ -181,6 +183,7 @@ class ConfigRunTestCase(test.CdistTestCase):
"""Test to show dependency resolver warning message."""
local = cdist.exec.local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=self.host_base_path,
host_dir_name=self.hostdir,
exec_path=os.path.abspath(os.path.join(
......
......@@ -53,6 +53,7 @@ class EmulatorTestCase(test.CdistTestCase):
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
......@@ -156,6 +157,7 @@ class EmulatorConflictingRequirementsTestCase(test.CdistTestCase):
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
......@@ -246,6 +248,7 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase):
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
......@@ -279,6 +282,7 @@ class OverrideTestCase(test.CdistTestCase):
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
......@@ -322,6 +326,7 @@ class ArgumentsTestCase(test.CdistTestCase):
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
......@@ -445,6 +450,7 @@ class StdinTestCase(test.CdistTestCase):
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
......@@ -511,6 +517,7 @@ class EmulatorAlreadyExistingRequirementsWarnTestCase(test.CdistTestCase):
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=host_base_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
......
......@@ -50,6 +50,7 @@ class ExplorerClassTestCase(test.CdistTestCase):
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=base_root_path,
host_dir_name=hostdir,
exec_path=test.cdist_exec_path,
......
This diff is collapsed.
......@@ -53,6 +53,7 @@ class ManifestTestCase(test.CdistTestCase):
base_root_path = os.path.join(out_path, hostdir)
self.local = local.Local(
target_host=self.target_host,
target_host_tags=self.target_host_tags,
base_root_path=base_root_path,
host_dir_name=hostdir,
exec_path=cdist.test.cdist_exec_path,
......@@ -93,6 +94,8 @@ class ManifestTestCase(test.CdistTestCase):
self.local.type_path)
self.assertEqual(output_dict['__manifest'], self.local.manifest_path)
self.assertEqual(output_dict['__files'], self.local.files_path)
self.assertEqual(output_dict['__target_host_tags'],
self.local.target_host_tags)
def test_type_manifest_environment(self):
cdist_type = core.CdistType(self.local.type_path, '__dump_environment')
......@@ -126,6 +129,8 @@ class ManifestTestCase(test.CdistTestCase):
self.assertEqual(output_dict['__object_id'], cdist_object.object_id)
self.assertEqual(output_dict['__object_name'], cdist_object.name)
self.assertEqual(output_dict['__files'], self.local.files_path)
self.assertEqual(output_dict['__target_host_tags'],
self.local.target_host_tags)
def test_debug_env_setup(self):
current_level = self.log.getEffectiveLevel()
......
......@@ -9,4 +9,5 @@ __global: $__global
__cdist_type_base_path: $__cdist_type_base_path
__manifest: $__manifest
__files: $__files
__target_host_tags: $__target_host_tags
DONE
......@@ -13,4 +13,5 @@ __object: $__object
__object_id: $__object_id
__object_name: $__object_name
__files: $__files
__target_host_tags: $__target_host_tags
DONE
......@@ -5,8 +5,8 @@ _cdist()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
prevprev="${COMP_WORDS[COMP_CWORD-2]}"
opts="-h --help -d --debug -v --verbose -V --version"
cmds="banner shell config install"
opts="-h --help -q --quiet -v --verbose -V --version"
cmds="banner config install inventory shell"
case "${prevprev}" in
shell)
......@@ -18,6 +18,41 @@ _cdist()
;;
esac
;;
inventory)
case "${prev}" in
list)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --invento/y -a --all -f --file -H --host-only \
-t --tag"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
add-host)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -f --file"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
del-host)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -a --all -f --file"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
add-tag)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -f --file -T --tag-file -t --taglist"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
del-tag)
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -a --all -f --file -T --tag-file -t --taglist"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
esac
;;
esac
case "${prev}" in
......@@ -26,23 +61,31 @@ _cdist()
return 0
;;
banner)
opts="-h --help -d --debug -v --verbose"
opts="-h --help -q --quiet -v --verbose"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
shell)
opts="-h --help -d --debug -v --verbose -s --shell"
opts="-h --help -q --quiet -v --verbose -s --shell"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
config|install)
opts="-h --help -d --debug -v --verbose -b --beta \
-C --cache-path-pattern -c --conf-dir -f --file -i --initial-manifest -j --jobs \
-n --dry-run -o --out-dir -p --parallel -r --remote-out-dir -s --sequential \
--remote-copy --remote-exec"
opts="-h --help -q --quiet -v --verbose -b --beta \
-I --inventory -C --cache-path-pattern -c --conf-dir \
-f --file -i --initial-manifest -A --all-tagged \
-j --jobs -n --dry-run -o --out-dir -p --parallel \
-r --remote-out-dir \
-s --sequential --remote-copy --remote-exec -t --tag -a --all"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
inventory)
cmds="list add-host del-host add-tag del-tag"
opts="-h --help -q --quiet -v --verbose"
COMPREPLY=( $(compgen -W "${opts} ${cmds}" -- ${cur}) )
return 0
;;
*)
;;
esac
......
......@@ -11,16 +11,16 @@ _cdist()
case $state in
opts_cmds)
_arguments '1:Options and commands:(banner config shell install -h --help -d --debug -v --verbose -V --version)'
_arguments '1:Options and commands:(banner config install inventory shell -h --help -q --quiet -v --verbose -V --version)'
;;
*)
case $words[2] in
-*)
opts=(-h --help -d --debug -v --verbose -V --version)
opts=(-h --help -q --quiet -v --verbose -V --version)
compadd "$@" -- $opts
;;
banner)
opts=(-h --help -d --debug -v --verbose)
opts=(-h --help -q --quiet -v --verbose)
compadd "$@" -- $opts
;;
shell)
......@@ -30,16 +30,45 @@ _cdist()
compadd "$@" -- $shells
;;
*)
opts=(-h --help -d --debug -v --verbose -s --shell)
opts=(-h --help -q --quiet -v --verbose -s --shell)
compadd "$@" -- $opts
;;
esac
;;
config|install)
opts=(-h --help -d --debug -v --verbose -b --beta -C --cache-path-pattern -c --conf-dir -f --file -i --initial-manifest -j --jobs -n --dry-run -o --out-dir -p --parallel -r --remote-out-dir -s --sequential --remote-copy --remote-exec)
opts=(-h --help -q --quiet -v --verbose -a --all -b --beta -C --cache-path-pattern -c --conf-dir -f --file -i --initial-manifest -j --jobs -n --dry-run -o --out-dir -p --parallel -r --remote-out-dir -s --sequential --remote-copy --remote-exec -t --tag -I --inventory -A --all-tagged)
compadd "$@" -- $opts
;;
*)
inventory)
case $words[3] in
list)
opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -a --all -f --file -H --host-only -t --tag)
compadd "$@" -- $opts
;;
add-host)
opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -f --file)
compadd "$@" -- $opts
;;
del-host)
opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -a --all -f --file)
compadd "$@" -- $opts
;;
add-tag)
opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -f --file -T --tag-file -t --taglist)
compadd "$@" -- $opts
;;
del-tag)
opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -a --all -f --file -T --tag-file -t --taglist)
compadd "$@" -- $opts
;;
*)
cmds=(list add-host del-host add-tag del-tag)
opts=(-h --help -q --quiet -v --verbose)
compadd "$@" -- $cmds $opts
;;
esac
;;
*)
;;
esac
esac
......
......@@ -2,6 +2,10 @@ Changelog
---------
next:
* Core: Add inventory functionality (Darko Poljak)
* Core: Expose inventory host tags in __target_host_tags env var (Darko Poljak)
4.5.0: 2017-07-20
* Types: Fix install types (Steven Armstrong)
* Core: Add -r command line option for setting remote base path (Steven Armstrong)
* Core: Allow manifest and gencode scripts to be written in any language (Darko Poljak)
......
Inventory
=========
Introduction
------------
cdist comes with simple built-in tag based inventory. It is a simple inventory
with list of hosts and a host has a list of tags.
Inventory functionality is still in **beta** so it can be used only if beta
command line flag is specified (-b, --beta) or setting CDIST_BETA env var.
Description
-----------
The idea is to have simple tagging inventory. There is a list of hosts and for
each host there are tags. Inventory database is a set of files under inventory
database base directory. Filename equals hostname. Each file contains tags for
hostname with each tag on its own line.
Using inventory you can now configure hosts by selecting them by tags.
Tags have no values, as tags are just tags. Tag name-value would in this
context mean that host has two tags and it is selected by specifying that both
tags are present.
This inventory is **KISS** cdist built-in inventory database. You can maintain it
using cdist inventory interface or using standard UNIX tools.
cdist inventory interface
-------------------------
With cdist inventory interface you can list host(s) and tag(s), add host(s),
add tag(s), delete host(s) and delete tag(s).
Configuring hosts using inventory
---------------------------------
config command now has new options, **-t**, **-a** and **-A**.
**-A** means that all hosts in tag db is selected.
**-a** means that selected hosts must contain ALL specified tags.
**-t** means that host specifies tag - all hosts that have specified tags are
selected.
Examples
--------
.. code-block:: sh
# List inventory content
$ cdist inventory list -b
# List inventory for specified host localhost
$ cdist inventory list -b localhost
# List inventory for specified tag loadbalancer
$ cdist inventory list -b -t loadbalancer
# Add hosts to inventory
$ cdist inventory add-host -b web1 web2 web3
# Delete hosts from file old-hosts from inventory
$ cdist inventory del-host -b -f old-hosts
# Add tags to specifed hosts
$ cdist inventory add-tag -b -t europe,croatia,web,static web1 web2
# Add tag to all hosts in inventory
$ cdist inventory add-tag -b -t vm
# Delete all tags from specified host
$ cdist inventory del-tag -b -a localhost
# Delete tags read from stdin from hosts specified by file hosts
$ cdist inventory del-tag -b -T - -f hosts
# Configure hosts from inventory with any of specified tags
$ cdist config -b -t web dynamic
# Configure hosts from inventory with all specified tags
$ cdist config -b -t -a web dynamic
# Configure all hosts from inventory db
$ cdist config -b -A
Example of manipulating database
--------------------------------
.. code-block:: sh
$ python3 scripts/cdist inventory list -b
$ python3 scripts/cdist inventory add-host -b localhost
$ python3 scripts/cdist inventory add-host -b test.mycloud.net
$ python3 scripts/cdist inventory list -b
localhost
test.mycloud.net
$ python3 scripts/cdist inventory add-host -b web1.mycloud.net web2.mycloud.net shell1.mycloud.net shell2.mycloud.net
$ python3 scripts/cdist inventory list -b
localhost
test.mycloud.net
web1.mycloud.net
web2.mycloud.net
shell1.mycloud.net
shell2.mycloud.net
$ python3 scripts/cdist inventory add-tag -b -t web web1.mycloud.net web2.mycloud.net
$ python3 scripts/cdist inventory add-tag -b -t shell shell1.mycloud.net shell2.mycloud.net
$ python3 scripts/cdist inventory add-tag -b -t cloud
$ python3 scripts/cdist inventory list -b
localhost cloud
test.mycloud.net cloud
web1.mycloud.net cloud,web
web2.mycloud.net cloud,web
shell1.mycloud.net cloud,shell
shell2.mycloud.net cloud,shell
$ python3 scripts/cdist inventory add-tag -b -t test,web,shell test.mycloud.net
$ python3 scripts/cdist inventory list -b
localhost cloud
test.mycloud.net cloud,shell,test,web
web1.mycloud.net cloud,web
web2.mycloud.net cloud,web
shell1.mycloud.net cloud,shell
shell2.mycloud.net cloud,shell
$ python3 scripts/cdist inventory del-tag -b -t shell test.mycloud.net
$ python3 scripts/cdist inventory list -b
localhost cloud
test.mycloud.net cloud,test,web
web1.mycloud.net cloud,web
web2.mycloud.net cloud,web
shell1.mycloud.net cloud,shell
shell2.mycloud.net cloud,shell
$ python3 scripts/cdist inventory add-tag -b -t all
$ python3 scripts/cdist inventory add-tag -b -t mistake
$ python3 scripts/cdist inventory list -b
localhost all,cloud,mistake
test.mycloud.net all,cloud,mistake,test,web
web1.mycloud.net all,cloud,mistake,web
web2.mycloud.net all,cloud,mistake,web
shell1.mycloud.net all,cloud,mistake,shell
shell2.mycloud.net all,cloud,mistake,shell
$ python3 scripts/cdist inventory del-tag -b -t mistake
$ python3 scripts/cdist inventory list -b
localhost all,cloud
test.mycloud.net all,cloud,test,web
web1.mycloud.net all,cloud,web
web2.mycloud.net all,cloud,web
shell1.mycloud.net all,cloud,shell
shell2.mycloud.net all,cloud,shell
$ python3 scripts/cdist inventory del-host -b localhost
$ python3 scripts/cdist inventory list -b
test.mycloud.net all,cloud,test,web
web1.mycloud.net all,cloud,web
web2.mycloud.net all,cloud,web
shell1.mycloud.net all,cloud,shell
shell2.mycloud.net all,cloud,shell
$ python3 scripts/cdist inventory list -b -t web
test.mycloud.net all,cloud,test,web
web1.mycloud.net all,cloud,web
web2.mycloud.net all,cloud,web
$ python3 scripts/cdist inventory list -b -t -a web test
test.mycloud.net all,cloud,test,web
$ python3 scripts/cdist inventory list -b -t -a web all
test.mycloud.net all,cloud,test,web
web1.mycloud.net all,cloud,web
web2.mycloud.net all,cloud,web
$ python3 scripts/cdist inventory list -b -t web all
test.mycloud.net all,cloud,test,web
web1.mycloud.net all,cloud,web
web2.mycloud.net all,cloud,web
shell1.mycloud.net all,cloud,shell
shell2.mycloud.net all,cloud,shell
$ cd cdist/inventory
$ ls -1
shell1.mycloud.net
shell2.mycloud.net
test.mycloud.net
web1.mycloud.net
web2.mycloud.net
$ ls -l
total 20
-rw-r--r-- 1 darko darko 16 Jun 24 12:43 shell1.mycloud.net