Debian Codegraph @

docs/src/cdist-integration.rst

raw
1 cdist integration / using cdist as library
2 ==========================================
3
4 Description
5 -----------
6
7 cdist can be integrate with other applications by importing cdist and other
8 cdist modules and setting all by hand. There are also helper functions which
9 aim to ease this integration. Just import **cdist.integration** and use its
10 functions:
11
12 * :strong:`cdist.integration.configure_hosts_simple` for configuration
13 * :strong:`cdist.integration.install_hosts_simple` for installation.
14
15 Functions require `host` and `manifest` parameters.
16 `host` can be specified as a string representing host or as iterable
17 of hosts. `manifest` is a path to initial manifest. For other cdist
18 options default values will be used. `verbose` is a desired verbosity
19 level which defaults to VERBOSE_INFO. `cdist_path` parameter specifies
20 path to cdist executable, if it is `None` then functions will try to
21 find it first from local lib directory and then in PATH.
22
23 In case of cdist error :strong:`cdist.Error` exception is raised.
24
25 :strong:`WARNING`: cdist integration helper functions are not yet stable!
26
27 Examples
28 --------
29
30 .. code-block:: sh
31
32 # configure host from python interactive shell
33 >>> import cdist.integration
34 >>> cdist.integration.configure_hosts_simple('185.203.114.185',
35 ... '~/.cdist/manifest/init')
36
37 # configure host from python interactive shell, specifying verbosity level
38 >>> import cdist.integration
39 >>> cdist.integration.configure_hosts_simple(
40 ... '185.203.114.185', '~/.cdist/manifest/init',
41 ... verbose=cdist.argparse.VERBOSE_TRACE)
42
43 # configure specified dns hosts from python interactive shell
44 >>> import cdist.integration
45 >>> hosts = ('dns1.ungleich.ch', 'dns2.ungleich.ch', 'dns3.ungleich.ch', )
46 >>> cdist.integration.configure_hosts_simple(hosts,
47 ... '~/.cdist/manifest/init')