octocatalog-diff 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/.version +1 -0
  3. data/LICENSE +20 -0
  4. data/README.md +82 -0
  5. data/bin/octocatalog-diff +75 -0
  6. data/doc/advanced-bootstrap.md +33 -0
  7. data/doc/advanced-cache-dir.md +24 -0
  8. data/doc/advanced-catalog-only.md +37 -0
  9. data/doc/advanced-ci.md +13 -0
  10. data/doc/advanced-dynamic-ignores.md +123 -0
  11. data/doc/advanced-future-parser.md +11 -0
  12. data/doc/advanced-ignores.md +224 -0
  13. data/doc/advanced-output-formats.md +96 -0
  14. data/doc/advanced-output-hacks.md +45 -0
  15. data/doc/advanced-override-facts.md +67 -0
  16. data/doc/advanced-pe-enc.md +52 -0
  17. data/doc/advanced-puppet-master.md +50 -0
  18. data/doc/advanced-puppet-versions.md +9 -0
  19. data/doc/advanced-storeconfigs.md +72 -0
  20. data/doc/advanced-using-without-git.md +15 -0
  21. data/doc/advanced.md +43 -0
  22. data/doc/basic.md +70 -0
  23. data/doc/configuration-enc.md +69 -0
  24. data/doc/configuration-hiera.md +103 -0
  25. data/doc/configuration-puppetdb.md +49 -0
  26. data/doc/configuration.md +51 -0
  27. data/doc/dev/README.md +1 -0
  28. data/doc/dev/coverage.md +34 -0
  29. data/doc/dev/how-to-add-options.md +83 -0
  30. data/doc/dev/integration-tests.md +63 -0
  31. data/doc/dev/releasing.md +19 -0
  32. data/doc/installation.md +49 -0
  33. data/doc/limitations.md +34 -0
  34. data/doc/optionsref.md +947 -0
  35. data/doc/requirements.md +16 -0
  36. data/doc/roadmap.md +26 -0
  37. data/doc/similar.md +17 -0
  38. data/doc/troubleshooting.md +54 -0
  39. data/lib/octocatalog-diff.rb +12 -0
  40. data/lib/octocatalog-diff/bootstrap.rb +53 -0
  41. data/lib/octocatalog-diff/catalog-diff/cli.rb +205 -0
  42. data/lib/octocatalog-diff/catalog-diff/cli/catalogs.rb +240 -0
  43. data/lib/octocatalog-diff/catalog-diff/cli/diffs.rb +145 -0
  44. data/lib/octocatalog-diff/catalog-diff/cli/helpers/fact_override.rb +99 -0
  45. data/lib/octocatalog-diff/catalog-diff/cli/options.rb +173 -0
  46. data/lib/octocatalog-diff/catalog-diff/cli/options/basedir.rb +14 -0
  47. data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_environment.rb +18 -0
  48. data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_script.rb +14 -0
  49. data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrap_then_exit.rb +12 -0
  50. data/lib/octocatalog-diff/catalog-diff/cli/options/bootstrapped_dirs.rb +18 -0
  51. data/lib/octocatalog-diff/catalog-diff/cli/options/cached_master_dir.rb +21 -0
  52. data/lib/octocatalog-diff/catalog-diff/cli/options/catalog_only.rb +14 -0
  53. data/lib/octocatalog-diff/catalog-diff/cli/options/color.rb +13 -0
  54. data/lib/octocatalog-diff/catalog-diff/cli/options/compare_file_text.rb +15 -0
  55. data/lib/octocatalog-diff/catalog-diff/cli/options/debug.rb +12 -0
  56. data/lib/octocatalog-diff/catalog-diff/cli/options/display_datatype_changes.rb +16 -0
  57. data/lib/octocatalog-diff/catalog-diff/cli/options/display_detail_add.rb +12 -0
  58. data/lib/octocatalog-diff/catalog-diff/cli/options/display_source_file_line.rb +12 -0
  59. data/lib/octocatalog-diff/catalog-diff/cli/options/enc.rb +31 -0
  60. data/lib/octocatalog-diff/catalog-diff/cli/options/existing_catalogs.rb +25 -0
  61. data/lib/octocatalog-diff/catalog-diff/cli/options/fact_file.rb +23 -0
  62. data/lib/octocatalog-diff/catalog-diff/cli/options/fact_override.rb +19 -0
  63. data/lib/octocatalog-diff/catalog-diff/cli/options/facts_terminus.rb +16 -0
  64. data/lib/octocatalog-diff/catalog-diff/cli/options/from_puppetdb.rb +13 -0
  65. data/lib/octocatalog-diff/catalog-diff/cli/options/header.rb +24 -0
  66. data/lib/octocatalog-diff/catalog-diff/cli/options/hiera_config.rb +18 -0
  67. data/lib/octocatalog-diff/catalog-diff/cli/options/hiera_path_strip.rb +12 -0
  68. data/lib/octocatalog-diff/catalog-diff/cli/options/hostname.rb +13 -0
  69. data/lib/octocatalog-diff/catalog-diff/cli/options/ignore.rb +24 -0
  70. data/lib/octocatalog-diff/catalog-diff/cli/options/ignore_attr.rb +16 -0
  71. data/lib/octocatalog-diff/catalog-diff/cli/options/ignore_tags.rb +23 -0
  72. data/lib/octocatalog-diff/catalog-diff/cli/options/include_tags.rb +12 -0
  73. data/lib/octocatalog-diff/catalog-diff/cli/options/master_cache_branch.rb +12 -0
  74. data/lib/octocatalog-diff/catalog-diff/cli/options/output_file.rb +15 -0
  75. data/lib/octocatalog-diff/catalog-diff/cli/options/output_format.rb +15 -0
  76. data/lib/octocatalog-diff/catalog-diff/cli/options/parallel.rb +12 -0
  77. data/lib/octocatalog-diff/catalog-diff/cli/options/parser.rb +48 -0
  78. data/lib/octocatalog-diff/catalog-diff/cli/options/pass_env_vars.rb +19 -0
  79. data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_ca.rb +15 -0
  80. data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_client_cert.rb +14 -0
  81. data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_ssl_client_key.rb +14 -0
  82. data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token.rb +15 -0
  83. data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token_file.rb +17 -0
  84. data/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_url.rb +19 -0
  85. data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_binary.rb +16 -0
  86. data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master.rb +16 -0
  87. data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_api_version.rb +20 -0
  88. data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_ca.rb +19 -0
  89. data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_client_cert.rb +19 -0
  90. data/lib/octocatalog-diff/catalog-diff/cli/options/puppet_master_ssl_client_key.rb +19 -0
  91. data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_ca.rb +15 -0
  92. data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_cert.rb +14 -0
  93. data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_key.rb +14 -0
  94. data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_password.rb +14 -0
  95. data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_ssl_client_password_file.rb +13 -0
  96. data/lib/octocatalog-diff/catalog-diff/cli/options/puppetdb_url.rb +18 -0
  97. data/lib/octocatalog-diff/catalog-diff/cli/options/quiet.rb +12 -0
  98. data/lib/octocatalog-diff/catalog-diff/cli/options/retry_failed_catalog.rb +13 -0
  99. data/lib/octocatalog-diff/catalog-diff/cli/options/safe_to_delete_cached_master_dir.rb +15 -0
  100. data/lib/octocatalog-diff/catalog-diff/cli/options/storeconfigs.rb +12 -0
  101. data/lib/octocatalog-diff/catalog-diff/cli/options/suppress_absent_file_details.rb +14 -0
  102. data/lib/octocatalog-diff/catalog-diff/cli/options/to_from_branch.rb +16 -0
  103. data/lib/octocatalog-diff/catalog-diff/cli/printer.rb +52 -0
  104. data/lib/octocatalog-diff/catalog-diff/differ.rb +615 -0
  105. data/lib/octocatalog-diff/catalog-diff/display.rb +125 -0
  106. data/lib/octocatalog-diff/catalog-diff/display/json.rb +25 -0
  107. data/lib/octocatalog-diff/catalog-diff/display/text.rb +452 -0
  108. data/lib/octocatalog-diff/catalog-util/bootstrap.rb +145 -0
  109. data/lib/octocatalog-diff/catalog-util/builddir.rb +289 -0
  110. data/lib/octocatalog-diff/catalog-util/cached_master_directory.rb +169 -0
  111. data/lib/octocatalog-diff/catalog-util/command.rb +96 -0
  112. data/lib/octocatalog-diff/catalog-util/enc.rb +77 -0
  113. data/lib/octocatalog-diff/catalog-util/enc/noop.rb +22 -0
  114. data/lib/octocatalog-diff/catalog-util/enc/pe.rb +99 -0
  115. data/lib/octocatalog-diff/catalog-util/enc/pe/v1.rb +61 -0
  116. data/lib/octocatalog-diff/catalog-util/enc/script.rb +88 -0
  117. data/lib/octocatalog-diff/catalog-util/facts.rb +89 -0
  118. data/lib/octocatalog-diff/catalog-util/fileresources.rb +83 -0
  119. data/lib/octocatalog-diff/catalog-util/git.rb +65 -0
  120. data/lib/octocatalog-diff/catalog.rb +209 -0
  121. data/lib/octocatalog-diff/catalog/computed.rb +205 -0
  122. data/lib/octocatalog-diff/catalog/json.rb +30 -0
  123. data/lib/octocatalog-diff/catalog/noop.rb +19 -0
  124. data/lib/octocatalog-diff/catalog/puppetdb.rb +82 -0
  125. data/lib/octocatalog-diff/catalog/puppetmaster.rb +121 -0
  126. data/lib/octocatalog-diff/external/pson/LICENSE +17 -0
  127. data/lib/octocatalog-diff/external/pson/README.md +20 -0
  128. data/lib/octocatalog-diff/external/pson/common.rb +370 -0
  129. data/lib/octocatalog-diff/external/pson/pure.rb +15 -0
  130. data/lib/octocatalog-diff/external/pson/pure/generator.rb +395 -0
  131. data/lib/octocatalog-diff/external/pson/pure/parser.rb +307 -0
  132. data/lib/octocatalog-diff/external/pson/version.rb +8 -0
  133. data/lib/octocatalog-diff/facts.rb +125 -0
  134. data/lib/octocatalog-diff/facts/json.rb +20 -0
  135. data/lib/octocatalog-diff/facts/puppetdb.rb +59 -0
  136. data/lib/octocatalog-diff/facts/yaml.rb +29 -0
  137. data/lib/octocatalog-diff/puppetdb.rb +163 -0
  138. data/lib/octocatalog-diff/util/colored.rb +20 -0
  139. data/lib/octocatalog-diff/util/httparty.rb +158 -0
  140. data/lib/octocatalog-diff/util/parallel.rb +170 -0
  141. data/lib/octocatalog-diff/util/puppetversion.rb +24 -0
  142. data/lib/octocatalog-diff/version.rb +7 -0
  143. metadata +386 -0
@@ -0,0 +1,96 @@
1
+ # Output formats
2
+
3
+ By default, when you run `octocatalog-diff`, it will display the results in color on STDOUT.
4
+
5
+ An example of the output display is shown on the [main page](/README.md#example).
6
+
7
+ Log messages will be written to STDERR.
8
+
9
+ ## Writing to a file
10
+
11
+ If you would like to write the results to a file instead, specify:
12
+
13
+ octocatalog-diff -o OUTPUT_FILE_PATH [other options]
14
+
15
+ When you output to a file, the default output format is the same as the on-screen format, but without the color.
16
+
17
+ If you would like to redirect the debug/log output to a file, you can use shell redirection:
18
+
19
+ octocatalog-diff [options] 2>/var/log/octocatalog-diff.log
20
+
21
+ ## Alternate output formats
22
+
23
+ You can specify the `--output-format FORMAT` command line options with one of the following values for FORMAT:
24
+
25
+ | FORMAT | Explanation |
26
+ | ------ | ----------- |
27
+ | text | (Default) Traditional human readable output |
28
+ | json | JSON output of the difference array |
29
+
30
+ ## Color
31
+
32
+ As previously noted, color text is enabled for on-screen display and disabled for file output.
33
+
34
+ You can override the automatic selection via:
35
+
36
+ - `--color` to turn colored text on
37
+ - `--no-color` to turn colored text off
38
+
39
+ Note: There is no color used for JSON output, regardless of whether the display is on-screen or redirected to a file, and regardless of whether you specify the `--color` command line option.
40
+
41
+ ## JSON format
42
+
43
+ ### Top level format
44
+
45
+ The JSON result is in the following format:
46
+
47
+ ```
48
+ {
49
+ "diff": [
50
+ DIFFERENCE_ARRAY_1,
51
+ DIFFERENCE_ARRAY_2,
52
+ ...
53
+ ],
54
+ "header": "HEADER STRING"
55
+ }
56
+ ```
57
+
58
+ ### Format of difference arrays
59
+
60
+ Each difference array is in one of the following formats:
61
+
62
+ #### Addition or removal
63
+
64
+ ```
65
+ [
66
+ (String) Change Type (+ or -),
67
+ (String) Type, Title separated by \f,
68
+ (Hash) Object as it exists in old or new catalog,
69
+ (Hash) { file: "MANIFEST FILENAME", line: LINE_NUMBER }
70
+ ]
71
+ ```
72
+
73
+ When the change type is '+' this indicates that the resource was added (i.e., it exists in the new catalog and not the old). '-' indicates that the resource was removed (i.e., it exists in the old catalog, but not the new). It is important to note that a removed resource does not necessarily cause cleanup on the target system.
74
+
75
+ #### Change
76
+
77
+ ```
78
+ [
79
+ (String) Change Type (~ or !),
80
+ (String) Type, Title, Attribute separated by \f,
81
+ (?) Object as it exists in old catalog,
82
+ (?) Object as it exists in new catalog,
83
+ (Hash) { file: "MANIFEST FILENAME", line: LINE_NUMBER } from old catalog,
84
+ (Hash) { file: "MANIFEST FILENAME", line: LINE_NUMBER } from new catalog
85
+ ]
86
+ ```
87
+
88
+ Note that `~` and `!` are used internally to signify different types of changes, but for display purposes they should be considered equivalent.
89
+
90
+ The objects as they appear in the old and new catalogs can be many different data types. Strings, integers, and booleans are the most common. `null` represents that the attribute was not present in the catalog or that it was set to Puppet's `undef`. (`null` in JSON is equivalent to Ruby's `nil`.)
91
+
92
+ ### Notes
93
+
94
+ - In the second array field, the type, title, and attribute are separated by the form feed (`\f`) character. This was chosen because it is unlikely to be encountered in actual naming. You are guaranteed that when splitting on `\f`, the first item is the type, the second item is the title, and the third (and subsequent) items represent the attribute, with each key in the data structure also separated by `\f`.
95
+
96
+ - If the manifest name and line number are not reported in the catalog, the hashes may have `nil` values for the file and line keys.
@@ -0,0 +1,45 @@
1
+ # Output hacks
2
+
3
+ This document describes command line options that are useful to format the output of the human readable text format (which is the default). Note that if you are [outputting in JSON](/doc/advanced-output-formats.md#json-format), none of these options will have any effect.
4
+
5
+ See also [Output formats](/doc/advanced-output-formats.md) for details on text vs. JSON and color vs. non-color.
6
+
7
+ ## Displaying the detail of added resources (`--display-detail-add`)
8
+
9
+ By default, `octocatalog-diff` will display an added resource on one line, without displaying all of the parameters. For example:
10
+
11
+ ```
12
+ + File[/tmp/my-file]
13
+ ```
14
+
15
+ If you would like to see the detail (all parameters and other settings), provide the `--display-detail-add` command line argument. Then the display will look more like:
16
+
17
+ ```
18
+ + File[/tmp/my-file] =>
19
+ parameters =>
20
+ "content": "This is my amazing new file",
21
+ "ensure": "file",
22
+ "group": "root",
23
+ "mode": "0755",
24
+ "owner": "root"
25
+ ```
26
+
27
+ If any line is too long, it will be abbreviated with `...`.
28
+
29
+ ## Displaying the file and line giving rise to a resource (`--display-source`)
30
+
31
+ To get help tracking down the file and line giving rise to a resource, provide the `--display-source` command line argument.
32
+
33
+ If the file name and line number are known in the catalog, they will be displayed with the resource.
34
+
35
+ If this information is the same between the old and new catalogs, it will be displayed just once. If the information differs, it will be displayed twice in a `diff` format: the `-` represents the location in the old catalog, and `+` represents the location in the new catalog.
36
+
37
+ ## Tuning the level of debugging (`--debug`, `--quiet`)
38
+
39
+ `octocatalog-diff` comes with 3 levels of log output. From least to most:
40
+
41
+ | Command line option | Description |
42
+ | ------------------- | ----------- |
43
+ | `--quiet` (or `-q`) | Only critical errors are displayed to STDERR |
44
+ | (default) | Critical errors and informational messages (statistics mainly) are displayed to STDERR |
45
+ | `--debug` (or `-d`) | Full debugging messages are displayed to STDERR |
@@ -0,0 +1,67 @@
1
+ # Overriding facts
2
+
3
+ One powerful feature of `octocatalog-diff` allows you to override facts when compiling the catalogs, to predict the effect of a fact change on the catalog. This is useful to simulate a change in agent node configuration without actually setting up an agent to do so.
4
+
5
+ ## Usage
6
+
7
+ To override a fact in the "to" catalog:
8
+
9
+ ```
10
+ --to-fact-override factname=value
11
+ ```
12
+
13
+ To override a fact in the "from" catalog:
14
+
15
+ ```
16
+ --from-fact-override factname=value
17
+ ```
18
+
19
+ You may use as many of these arguments as you wish to adjust as many facts as you wish.
20
+
21
+ ## Examples
22
+
23
+ Simulate a change to its IP address in the "to" branch:
24
+
25
+ ```
26
+ octocatalog-diff -n some-node.example.com -f master -t master \
27
+ --to-fact-override ipaddress=10.0.0.1
28
+ ```
29
+
30
+ Simulate a change in operating system version (in this case, from Ubuntu trusty to xenial):
31
+
32
+ ```
33
+ octocatalog-diff -n some-node.example.com -f master -t master \
34
+ --from-fact-override lsbdistcodename=trusty --to-fact-override lsbdistcodename=xenial
35
+ ```
36
+
37
+ Simulate changes to multiple facts, in this case the effect of moving a physical machine into EC2:
38
+
39
+ ```
40
+ octocatalog-diff -n some-node.example.com -f master -t master \
41
+ --to-fact-override ec2=true --to-fact-override ec2_ami_id=ami-abcdef01 \
42
+ --to-fact-override ec2_hostname=ip-172-16-0-1.internal --to-fact-override ec2_instance_id=i-ba987654 \
43
+ --to-fact-override ec2_instance_type=c4.2xlarge ...... \
44
+ --to-fact-override virtual=xenhvm
45
+ ```
46
+
47
+ Note that each of the examples specified the from branch and to branch to be `master`. There is no requirement that you do this, but you can generally obtain the most accurate test results by changing only one variable at a time.
48
+
49
+ ## Advanced usage
50
+
51
+ The `octocatalog-diff` parser will attempt to guess the data type based on the input. However, you can force the data type using the following syntax:
52
+
53
+ ```
54
+ octocatalog-diff -n some-node.example.com -f master -t master \
55
+ --to-fact-override some_fact='(string)42' fact_to_delete='(nil)'
56
+ ```
57
+
58
+ The following data types in parentheses are supported:
59
+
60
+ | Data type in parentheses | Description |
61
+ | ------------------------ | ------------|
62
+ | `(string)` | Treat the input as a string |
63
+ | `(fixnum)` | Treat the input as an integer (calls the `.to_i` method in ruby) |
64
+ | `(float)` | Treat the input as an integer (calls the `.to_f` method in ruby) |
65
+ | `(json)` | Treat the input as a JSON string (calls `JSON.parse` in ruby) |
66
+ | `(boolean)` | Treat the input as a boolean -- it must be `true` or `false`, case-insensitive |
67
+ | `(nil)` | Ignore any characters after `(nil)` and deletes the fact if the fact exists |
@@ -0,0 +1,52 @@
1
+ # Puppet Enterprise node classification service
2
+
3
+ If you are using Puppet Enterprise, `octocatalog-diff` can use the node classifier service API instead of an external node classifier.
4
+
5
+ ## Basics
6
+
7
+ To use the Puppet Enterprise node classifier service instead of an ENC, you must supply the URL to your node classifier service API endpoint, and either an authentication token or a whilelisted SSL client keypair. It is recommended to supply the SSL Certificate Authority (CA) file as well, to verify the identity of the server to which you are connecting.
8
+
9
+ To use Puppet Enterprise node classifier service with an authentication token:
10
+
11
+ ```
12
+ octocatalog-diff \
13
+ --pe-enc-url https://your.pe.console.server:4433/classifier-api \
14
+ --pe-enc-token-file /path/to/token/file.txt \
15
+ --pe-enc-ssl-ca /path/to/ca.crt \
16
+ [other options]
17
+ ```
18
+
19
+ To use Puppet Enterprise node classifier service with a whitelisted SSL client keypair:
20
+
21
+ ```
22
+ octocatalog-diff \
23
+ --pe-enc-url https://your.pe.console.server:4433/classifier-api \
24
+ --pe-enc-ssl-ca /path/to/ca.crt \
25
+ --pe-enc-ssl-client-cert /path/to/client.crt \
26
+ --pe-enc-ssl-client-key /path/to/client.key \
27
+ [other options]
28
+ ```
29
+
30
+ ## Details
31
+
32
+ ### Requirements
33
+
34
+ - Your PE console server must be accessible to the machine from which you are running `octocatalog-diff` on the appropriate port (by default, 4433). This port is *not* required to run Puppet agents, so it's possible that you have it firewalled off.
35
+
36
+ ### Authentication token
37
+
38
+ Please see [Authentication token](https://docs.puppet.com/pe/latest/nc_forming_requests.html#authentication-token) in the official Puppet documentation.
39
+
40
+ The referenced document contains links to generate a token with the `puppet-access` command.
41
+
42
+ Note that if you wish to hard-code an authentication token in your [configuration file](/doc/configuration.md), the internal variable key is `:pe_enc_token` and the content is a string containing the entire token. (The `--pe-enc-token-file` option simply reads the provided file and stores the content in the `:pe_enc_token` key. See [source](/lib/octocatalog-diff/catalog-diff/cli/options/pe_enc_token_file.rb).)
43
+
44
+ ### SSL client keypair
45
+
46
+ If you wish to use a SSL client keypair instead of a token, please see [Whilelisted certificate](https://docs.puppet.com/pe/latest/nc_forming_requests.html#whitelisted-certificate) in the official Puppet documentation.
47
+
48
+ The referenced document contains instructions to add the certificate name to the whitelist file and restart the necessary services.
49
+
50
+ ### Further reading
51
+
52
+ [Puppet documentation on node classifier endpoints](https://docs.puppet.com/pe/latest/nc_index.html)
@@ -0,0 +1,50 @@
1
+ # Fetching catalogs from Puppet Master / PuppetServer
2
+
3
+ `octocatalog-diff` can fetch catalogs from a Puppet Master, PuppetServer, or Puppet Enterprise server by calling their HTTPS API, just as a node would when it fetches its catalog. For simplicity, this document will refer only to "Puppet Master" but unless otherwise noted, the instructions apply equally to the open source PuppetServer and Puppet Enterprise PuppetServer as well.
4
+
5
+ Please note the following caveats:
6
+
7
+ 0. This method will put some load on your Puppet Master to build the catalog. Depending on how you use `octocatalog-diff` you should ensure that this extra load will not overwhelm your Puppet Master (especially if you create a "thundering herd" by launching several instances of `octocatalog-diff` simultaneously).
8
+
9
+ 0. You will need to deploy your Puppet code to an environment on your Puppet Master prior to running `octocatalog-diff` for that environment. `octocatalog-diff` does not deploy code for you.
10
+
11
+ 0. You will need to configure authorization for one or more whitelisted certificates on your Puppet Master. The default permissions allow a node to retrieve its own catalog via the API, but you need a certificate for `octocatalog-diff` that permits it to retrieve any catalog. See the [Certificate authorization](#certificate-authorization) section below.
12
+
13
+ ## Command line options
14
+
15
+ The following command line options are used to retrieve a catalog from a Puppet Master:
16
+
17
+ | Option | Description |
18
+ | ------ | ----------- |
19
+ | `-f ENVIRONMENT` | Environment name to use for the "from" catalog |
20
+ | `-t ENVIRONMENT` | Environment name to use for the "to" catalog |
21
+ | `--puppet-master HOSTNAME:PORT | The hostname and port number of the Puppet Master. (By default the port used by Puppet Master is 8140.) |
22
+ | `--puppet-master-api-version VERSION | The API version used by the Puppet Master. API versions 2 and 3 are supported. Puppet Master 3.x uses API version 2, and the PuppetServer for Puppet 4.x uses API version 3. By default, API version 3 is used, so you only need to set this option if you are using Puppet Master 3.x. |
23
+ | `--puppet-master-ssl-ca PATH` | Path to the CA certificate (public portion of certificate only) for your Puppet Master. This file will be on your Puppet Master and all Puppet agents. You can find it by running `puppet config print cacert` on any Puppet-managed host. |
24
+ | `--puppet-master-ssl-client-cert PATH` | Path to the client certificate. Please see the section below on certificate authentication. |
25
+ | `--puppet-master-ssl-client-key PATH` | Path to the client private key. Please see the section below on certificate authentication. |
26
+
27
+ If you wish to use a different Puppet Master to compile the "to" and "from" catalogs, you may prefix any of the `--puppet-master...` options with `to` or `from`. For example, perhaps you are testing an upgrade from Puppet 3.x to 4.x. You could use:
28
+
29
+ ```
30
+ ... --from-puppet-master puppet3-x.yourdomain.com:8140 --from-puppet-master-api-version 2 --to-puppet-master puppet4-x.yourdomain.com:8140 ...
31
+ ```
32
+
33
+ It is possible to "mix and match" catalog generation methods. For example, you could retrieve a "from" catalog from a Puppet Master using `--from-puppet-master` while compiling a "to" catalog from local code. Please note that some enhanced options of `octocatalog-diff`, such as comparing file text instead of file source location, may not be available for all such combinations.
34
+
35
+ ## Certificate authorization
36
+
37
+ In order to use `octocatalog-diff` you will need to create one or more certificates that are empowered to retrieve all catalogs. This requires both creating the certificate, and reconfiguring your Puppet Master to expand the scope of authorization for that certificate.
38
+
39
+ Puppet Masters use the [legacy auth.conf file](https://docs.puppet.com/puppet/latest/reference/config_file_auth.html) and/or [PuppetServer auth.conf file](https://docs.puppet.com/puppetserver/latest/config_file_auth.html) to control access to HTTPS API.
40
+
41
+ In particular, the following entry in the legacy auth.conf permits a particular agent to retrieve its own catalog:
42
+
43
+ ```
44
+ # allow nodes to retrieve their own catalog (ie their configuration)
45
+ path ~ ^/catalog/([^/]+)$
46
+ method find
47
+ allow $1
48
+ ```
49
+
50
+ Please follow the instructions for the version of Puppet Master, PuppetServer, or Puppet Enterprise that you are using in order to generate and authorize the certificates.
@@ -0,0 +1,9 @@
1
+ # Compiling the same catalog with different Puppet versions
2
+
3
+ `octocatalog-diff` can be a valuable tool when upgrading from one Puppet version to another. By instructing `octocatalog-diff` to compile the "from" catalog with one version of Puppet, and the "to" catalog with another version of Puppet, you can look for changes that arise due to different Puppet versions.
4
+
5
+ To use this feature, simply point `octocatalog-diff` at the Puppet binary you wish to use for each catalog.
6
+
7
+ - `--from-puppet-binary DIRECTORY_PATH/puppet` will compile the "from" catalog with the specified Puppet binary
8
+ - `--to-puppet-binary DIRECTORY_PATH/puppet` will compile the "to" catalog with the specified Puppet binary
9
+ - `--puppet-binary DIRECTORY_PATH/puppet` will compile both catalogs with the specified Puppet binary
@@ -0,0 +1,72 @@
1
+ # Enabling storeconfigs for exported resources in PuppetDB
2
+
3
+ The "storeconfigs" setting in Puppet is a feature related to [exported resources](https://docs.puppet.com/puppet/latest/reference/lang_exported.html).
4
+
5
+ It is possible to enable the collection of exported resources when `octocatalog-diff` compiles catalogs, to give the most accurate representation possible of the catalogs before they are compared.
6
+
7
+ ## Usage
8
+
9
+ When you provide the `--storeconfigs` command line option, or set `settings[:storeconfigs] = true` in the [configuration file](/doc/configuration.md), the following behavior is triggered:
10
+
11
+ - `octocatalog-diff` will create a `puppetdb.conf` file in its temporary compilation directory, using the [PuppetDB configuration settings](/doc/configuration-puppetdb.md) that you have specified, either as command line parameters or in a configuration file.
12
+
13
+ - `octocatalog-diff` will install the SSL client certificates you have provided for PuppetDB, if any, in its temporary compilation directory, so that Puppet will pick these up and use them to connect to PuppetDB. This allows SSL client authentication to PuppetDB. (Please note: Puppet *must* connect to PuppetDB over an SSL connection, although not necessarily an authenticated SSL connection.)
14
+
15
+ - `octocatalog-diff` will create a `routes.yaml` file in its temporary compilation directory so that Puppet does not try to send fact data, resource data, or reports back to PuppetDB. We have done our best to make this connection be "read only" although we do encourage you to set up a separate, read-only port for PuppetDB to ensure this.
16
+
17
+ ## Caveats
18
+
19
+ - Beware of load this may cause on PuppetDB, especially if you run `octocatalog-diff` simultaneously in a CI environment. At GitHub, we run `octocatalog-diff` distributed across 8 CI nodes, each of which is capable of performing 16 simultaneous catalog compilations. We have noticed performance degradation or outages when a "thundering herd" of 128 catalog compilations hit PuppetDB at the same time, leading us to implement a layer of caching on top of PuppetDB.
20
+
21
+ - `octocatalog-diff` compiles a "before" and "after" catalog in mostly parallel fashion, but it is possible that the order of operations happens as follows: (a) "before" catalog compiles; (b) something else writes updated data to PuppetDB; (c) "after" catalog compiles. In this case, there can be false differences reported in the output.
22
+
23
+ ## Advanced configuration
24
+
25
+ This section contains tips on setting up a proxy in front of PuppetDB to control access and/or enable caching. You are not required to do this in order to use `--storeconfigs` but you may find these tips useful if simultaneous runs of `octocatalog-diff` put too much load on your PuppetDB instance.
26
+
27
+ ### Making a read-only PuppetDB port
28
+
29
+ It is possible to create a read-only endpoint to PuppetDB by setting up a proxy that only allows the desired URLs. This ensures that the Puppet runs cannot submit fact data, resource data, or reports back to PuppetDB from `octocatalog-diff` runs. (As noted previously, we do set up `routes.yaml` to prevent this, but the strategy in this section provides an extra layer of security.)
30
+
31
+ To allow only the desired traffic, you should configure a port on your proxy that will pass to these URLs only:
32
+
33
+ - /pdb/query
34
+ - /pdb/meta
35
+
36
+ ### Caching
37
+
38
+ To reduce the impact of a "thundering herd" of simultaneous `octocatalog-diff` runs, you can set up a caching proxy in front of the `/pdb/query` endpoint.
39
+
40
+ Here is a portion of the nginx configuration that has provided the best balance between performance and accuracy. We have chosen a 1 minute TTL on results, and incorporated the request body into the cache key. You will need to adjust and incorporate this configuration into your own nginx proxy.
41
+
42
+ ```
43
+ upstream puppetdb {
44
+ server localhost:8080;
45
+ }
46
+
47
+ proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=pdb_cache:10m max_size=25g inactive=2m;
48
+
49
+ server {
50
+ listen 10.0.0.1:8082;
51
+
52
+ # Some SSL settings omitted. Configure as per your own needs.
53
+ ssl_client_certificate /etc/nginx/ca.crt
54
+ ssl_verify_client on;
55
+
56
+ proxy_cache_key "$scheme$proxy_host$uri$is_args$args|$request_body";
57
+
58
+ deny all;
59
+
60
+ location /pdb/query {
61
+ proxy_cache pdb_cache;
62
+ proxy_ignore_headers Cache-Control;
63
+ proxy_cache_valid any 1m;
64
+ proxy_pass http://puppetdb;
65
+ proxy_redirect off;
66
+ add_header X-Cache-Status $upstream_cache_status;
67
+ allow all;
68
+ }
69
+
70
+ # Other settings omitted.
71
+ }
72
+ ```
@@ -0,0 +1,15 @@
1
+ # Using `octocatalog-diff` without git
2
+
3
+ `octocatalog-diff` is designed to be used with git, and is developed by GitHub. This means that on a daily basis, it is run thousands of times on repositories backed by GitHub for CI jobs reported to GitHub.
4
+
5
+ If you do not manage your Puppet code with git, it is still possible to use `octocatalog-diff`, but you will not be able to take advantage of the git integrations and will need to do some things manually.
6
+
7
+ ## Usage
8
+
9
+ You will need to use these command line options (at minimum):
10
+
11
+ - `--bootstrapped-from-dir`: The directory containing your checked out "from" Puppet code, and if there is any [bootstrapping](/doc/advanced-bootstrap.md) it must already be done.
12
+
13
+ - `--bootstrapped-to-dir`: The directory containing your checked out "to" Puppet code, and if there is any [bootstrapping](/doc/advanced-bootstrap.md) it must already be done.
14
+
15
+ You are responsible for the process by which you check out code from your version control system into two separate directories and run any necessary bootstrapping. You will need to script that step *before* invoking `octocatalog-diff`.
@@ -0,0 +1,43 @@
1
+ # Advanced usage
2
+
3
+ With `--octocatalog-diff` supporting over 75 command line options (and counting), there's a little something for everyone. On this page, we document some interesting use cases that can be accomplished with creative combinations of options.
4
+
5
+ If you find a creative use of `octocatalog-diff` that we haven't thought of, we encourage you to create a document named `advanced-SOMETHING.md` and link to it from here!
6
+
7
+ See also:
8
+
9
+ - [Basic usage](/doc/basic.md) - Common use cases to get you started
10
+ - [Command line options reference](/doc/optionsref.md) - A list of *all* the options
11
+ - [How to add new command line options](/doc/dev/how-to-add-options.md) - If you'd like to add an option of your own
12
+
13
+ ## Advanced usage documentation
14
+
15
+ ### Building catalogs
16
+
17
+ - [Bootstrapping your Puppet checkout](/doc/advanced-bootstrap.md)
18
+ - [Building catalogs instead of diffing catalogs](/doc/advanced-catalog-only.md)
19
+ - [Enabling storeconfigs for exported resources in PuppetDB](/doc/advanced-storeconfigs.md)
20
+ - [Fetching catalogs from Puppet Master / PuppetServer](/doc/advanced-puppet-master.md)
21
+ - [Overriding facts](/doc/advanced-override-facts.md)
22
+ - [Puppet Enterprise node classification service](/doc/advanced-pe-enc.md)
23
+ - [Using `octocatalog-diff` without git](/doc/advanced-using-without-git.md)
24
+
25
+ ### Controlling output
26
+
27
+ - [Ignoring certain changes via command line options](/doc/advanced-ignores.md)
28
+ - [Dynamic ignoring of changes via tags in Puppet manifests](/doc/advanced-dynamic-ignores.md)
29
+ - [Output formats](/doc/advanced-output-formats.md)
30
+ - [Useful output hacks](/doc/advanced-output-hacks.md)
31
+
32
+ ### Using `octocatalog-diff` in CI
33
+
34
+ - [Using `octocatalog-diff` in CI](/doc/advanced-ci.md)
35
+
36
+ ### Using `octocatalog-diff` on your workstation
37
+
38
+ - [Enabling the cache directory](/doc/advanced-cache-dir.md)
39
+
40
+ ### Using `octocatalog-diff` to help you upgrade
41
+
42
+ - [Compiling the same catalog with different Puppet versions](/doc/advanced-puppet-versions.md)
43
+ - [Enabling the future parser](/doc/advanced-future-parser.md)