|
5 | 5 | `catalog` returns an `OctocatalogDiff::Catalog` object built with the octocatalog-diff compiler, obtained from a Puppet server, or read in from a file. This is analogous to using the `--catalog-only` option with the octocatalog-diff command-line script. |
6 | 6 |
|
7 | 7 | ``` |
8 | | -catalog_obj = OctocatalogDiff::API::V1.catalog( |
9 | | -
|
10 | | -) |
| 8 | +catalog_obj = OctocatalogDiff::API::V1.catalog(<Hash>) |
| 9 | +#=> OctocatalogDiff::API::V1::Catalog |
11 | 10 | ``` |
12 | 11 |
|
13 | | -## Options |
| 12 | +The return value is an [`OctocatalogDiff::API::V1::Catalog`](/doc/dev/api/v1/objects/catalog.md) object. |
| 13 | + |
| 14 | +For an example, see [catalog-builder-local-files.rb](/examples/api/v1/catalog-builder-local-files.rb). |
14 | 15 |
|
| 16 | +## Parameters |
15 | 17 |
|
16 | | -**NOTE**: Additional options as described in the [options reference](/doc/optionsref.md) may also have an effect on catalog generation. |
| 18 | +The `catalog` method takes one argument, which is a Hash containing parameters. |
17 | 19 |
|
18 | | -## Return value |
| 20 | +The list of parameters here is not exhaustive. The `.catalog` method accepts most parameters described in [Configuration](/doc/configuration.md), [Building catalogs instead of diffing catalogs](/doc/advanced-catalog-only.md), and [Command line options reference](/doc/optionsref.md). |
19 | 21 |
|
20 | | -The return value is an [`OctocatalogDiff::API::V1::Catalog`](/doc/dev/api/v1/objects/catalog.md) object. |
| 22 | +It is also possible to use the parameters from [OctocatalogDiff::API::V1.config](/doc/dev/api/v1/calls/config.md) for the catalog compilation. Simply combine the hash returned by `.config` with any additional keys, and pass the merged hash to the `.catalog` method. |
| 23 | + |
| 24 | +### Global parameters |
| 25 | + |
| 26 | +#### `:logger` (Logger, Optional) |
| 27 | + |
| 28 | +Debugging and informational messages will be logged to this object as the catalog is built. |
| 29 | + |
| 30 | +If no Logger object is passed, these messages will be silently discarded. |
| 31 | + |
| 32 | +#### `:node` (String, Required) |
| 33 | + |
| 34 | +The node name whose catalog is to be compiled or obtained. This should be the fully qualified domain name that matches the node's name as seen in Puppet. |
| 35 | + |
| 36 | +### Computed catalog parameters |
| 37 | + |
| 38 | +#### `:basedir` (String, Optional) |
| 39 | + |
| 40 | +Directory that contains a git repository with the Puppet code. Use in conjunction with `:to_branch` to specify the branch name that should be checked out. |
| 41 | + |
| 42 | +If your Puppet code is not in a git repository, or you already have the branch checked out via some other process, use `:bootstrapped_to_dir` instead. |
| 43 | + |
| 44 | +#### `:bootstrap_script` (String, Optional) |
| 45 | + |
| 46 | +Path to a script to run after checking out the selected branch of Puppet code from the git repository. See [Bootstrapping your Puppet checkout](/doc/advanced-bootstrap.md) for details. |
| 47 | + |
| 48 | +#### `:bootstrapped_to_dir` (String, Optional) |
| 49 | + |
| 50 | +Directory that is already prepared ("bootstrapped") and can have Puppet run against its contents to compile the catalog. |
| 51 | + |
| 52 | +Often this means that you have done the following to this directory: |
| 53 | + |
| 54 | +- Checked out the necessary branch of Puppet code from your version control system |
| 55 | +- Installed any third party modules (e.g. with librarian-puppet or r10k) |
| 56 | + |
| 57 | +#### `:enc` (String, Optional) |
| 58 | + |
| 59 | +File path to your External Node Classifier. |
| 60 | + |
| 61 | +See [Configuring octocatalog-diff to use ENC](/doc/configuration-enc.md) for details on using octocatalog-diff with an External Node Classifier. |
| 62 | + |
| 63 | +#### `:fact_file` (String, Optional) |
| 64 | + |
| 65 | +Path to the file that contains the facts for the node whose catalog you are going to compile. |
| 66 | + |
| 67 | +Generally, must either specify the fact file, or [configure octocatalog-diff to use PuppetDB](/doc/configuration-puppetdb.md) to retrieve node facts. |
| 68 | + |
| 69 | +#### `:hiera_config` (String, Optional) |
| 70 | + |
| 71 | +Path to the Hiera configuration file (generally named `hiera.yaml`) for your Puppet installation. Please see [Configuring octocatalog-diff to use Hiera](/doc/configuration-hiera.md) for details on Hiera configuration. |
| 72 | + |
| 73 | +#### `:hiera_path` (String, Optional) |
| 74 | + |
| 75 | +Directory within your Puppet installation where Hiera data is stored. Please see [Configuring octocatalog-diff to use Hiera](/doc/configuration-hiera.md) for details on Hiera configuration. |
| 76 | + |
| 77 | +If your Puppet setup is modeled after the [Puppet control repository template](https://github.com/puppetlabs/control-repo), the correct setting for `:hiera_path` is `'hieradata'`. |
| 78 | + |
| 79 | +#### `:puppet_binary` (String, Required) |
| 80 | + |
| 81 | +Path to the Puppet binary on your system. |
| 82 | + |
| 83 | +Please refer to [Configuring octocatalog-diff to use Puppet](/doc/configuration-puppet.md) for details of connecting octocatalog-diff to your Puppet installation. |
| 84 | + |
| 85 | +#### `:puppetdb_url` (String, Optional) |
| 86 | + |
| 87 | +URL to PuppetDB. See [Configuring octocatalog-diff to use PuppetDB](/doc/configuration-puppetdb.md) for instructions on this setting, and other settings that may be needed in your environment. |
| 88 | + |
| 89 | +#### `:to_branch` (String, Optional) |
| 90 | + |
| 91 | +Branch name in git repository to use for Puppet code. This option must be used in conjunction with `:basedir` so that code can be located. |
21 | 92 |
|
22 | 93 | ## Exceptions |
| 94 | + |
| 95 | +The following exceptions may occur during the compilation of a catalog: |
| 96 | + |
| 97 | +- `OctocatalogDiff::Errors::BootstrapError` |
| 98 | + |
| 99 | + Bootstrapping failed. |
| 100 | + |
| 101 | +- `OctocatalogDiff::Errors::CatalogError` |
| 102 | + |
| 103 | + Catalog failed to compile. Please note that whenever possible, a `OctocatalogDiff::API::V1::Catalog` object is still constructed for a failed catalog, with `#valid?` returning false. |
| 104 | + |
| 105 | +- `OctocatalogDiff::Errors::GitCheckoutError` |
| 106 | + |
| 107 | + Git checkout failed. |
| 108 | + |
| 109 | +- `OctocatalogDiff::Errors::PuppetVersionError` |
| 110 | + |
| 111 | + The version of Puppet could not be determined, generally because the Puppet binary was not found, or does not respond as expected to `puppet version`. |
| 112 | + |
| 113 | +- `OctocatalogDiff::Errors::ReferenceValidationError` |
| 114 | + |
| 115 | + See [Catalog validation](/doc/advanced-catalog-validation.md). |
0 commit comments