Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 284cece

Browse files
committed
Add dry-run proposal
1 parent c7f956d commit 284cece

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
.. vim:set ft=rst spell:
2+
3+
#######################
4+
Puppet Dry Run Via Wing
5+
#######################
6+
7+
Background
8+
==========
9+
10+
Using puppet's noop mode we can perform a proper dry-run of the changes that be
11+
performed on cluster instances.
12+
13+
See http://nrvale0.github.io/posts/the-basics-of-puppet-noop/ for an overview on noop mode.
14+
15+
Glossary
16+
--------
17+
18+
- **Puppet dry-run**: a puppet mode which calculates changes, but does not actually apply them to the instance.
19+
20+
Problem
21+
-------
22+
23+
Currently there is no way to verify what a ``puppet apply`` will do to nodes.
24+
In some situations, we would like to review the changes that Puppet would do on
25+
the system without actually applying them, to prevent causing destructive
26+
configuration changes.
27+
28+
We need a way to represent applying a set of puppet manifests to an instance,
29+
and a way to view the output of an application.
30+
31+
See:
32+
33+
- https://github.com/jetstack/tarmak/issues/224
34+
35+
Objective
36+
=========
37+
38+
Verify puppet will make sensible and expected changes to the cluster when running::
39+
40+
$ tarmak cluster puppet-plan
41+
42+
which complements ``cluster puppet-plan`` verifying Terraform changes.
43+
44+
Changes
45+
=======
46+
47+
To implement this, new objects will be added to Wing's API.
48+
49+
New API objects
50+
---------------
51+
52+
``PuppetManifest``
53+
******************
54+
55+
A resource representing a set of puppet manifests to apply to an instance.
56+
57+
This bundles together the source (S3, google Cloud Storage, etc) and
58+
verification of the source (a hash, PGP signature, etc).
59+
60+
.. code-block:: yaml
61+
62+
kind: PuppetManifest
63+
metadata:
64+
name: example-manifest
65+
hash: sha256:34242343
66+
source:
67+
s3:
68+
bucketName: something
69+
path: something-else/puppet.tar.gz
70+
71+
The source will be structured similarly to kubernetes' ``VolumeSource``, with a
72+
field for each type of source. For example, something like this in ``types.go``:
73+
74+
.. code-block:: go
75+
76+
type ManifestSource struct {
77+
S3 *S3ManifestSource `json:"s3ManifestSource"`
78+
}
79+
80+
type S3ManifestSource struct {
81+
BucketName string `json:"bucketName"`
82+
}
83+
84+
85+
``PuppetJob``
86+
*************
87+
88+
A resource representing the application of a ``PuppetManifest`` on an instance:
89+
90+
.. code-block:: yaml
91+
92+
kind: PuppetJob
93+
metadata:
94+
name: example-job
95+
spec:
96+
manifestRef:
97+
name: example-manifest
98+
operation: "dry-run"
99+
instanceID: 1234
100+
status:
101+
exitCode: 1
102+
messages: ""
103+
104+
This references a pre-existing ``PuppetManifest``, and performs the specified
105+
action on an instance.
106+
107+
Changes to existing API objects
108+
-------------------------------
109+
110+
``InstanceSpec`` will have a ``manifestRef`` field also linking to a ``PuppetManifest`` resource.
111+
This will be the manifest applied to the instance.
112+
113+
Changes to tarmak CLI
114+
---------------------
115+
116+
The tarmak CLI needs modification to add support for creating
117+
``PuppetManifest`` and ``PuppetJob`` resources.
118+
119+
The planned workflow is to run::
120+
121+
$ tarmak cluster puppet-plan
122+
123+
which creates ``PuppetJob`` resources for either a subset of instances of each
124+
type in the current cluster, or all instances. This blocks until
125+
``PuppetJob.Status.ExitCode`` for each created job is populated.
126+
127+
It would be nice to filter and only display results based on the exit code of puppet, but it seems the exit code is always ``0`` when ``--noop`` is enabled::
128+
129+
https://tickets.puppetlabs.com/browse/PUP-686
130+
131+
Notable items
132+
=============
133+
134+
Concerns
135+
--------
136+
137+
- Performing updates to puppet manifests will leave ``PuppetJob`` and
138+
``PuppetManifest`` resources hanging around. Should there be an automated clean
139+
up process for stale items?
140+
- We need to think about how to handle ``PuppetJob`` resources timing out in the case of an instance failure during a plan.

0 commit comments

Comments
 (0)