Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cheatsheet.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ Linux
```

You might also specify output syntax highlighting by adding language
after the starting backticks and placing `[output]` in the first line.
This line won't be shown in the resulted HTML.
after the starting backticks and placing `{output}` at the end of the line.

```command
curl --user admin:admin https://test.cfengine.com/api/user
Expand Down
6 changes: 3 additions & 3 deletions content/examples/_index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ from the example.
3. Insert the example's bundle name in the `bundlesequence` section
of the main policy file `/var/cfengine/masterfiles/promises.cf`:

```cf3
```cf3 {skip TODO}
bundlesequence => {
...
"hello_world",
Expand All @@ -230,7 +230,7 @@ from the example.
4. Insert the policy file name in the [`inputs`][Components#inputs] section of the main policy file
`/var/cfengine/masterfiles/promises.cf`:

```cf3
```cf3 {skip TODO}
inputs => {
...
"hello_world.cf",
Expand All @@ -241,7 +241,7 @@ from the example.
5. You must also remove any inputs section from the example that
includes the external library:

```cf3
```cf3 {skip TODO}
inputs => {
"libraries/cfengine_stdlib.cf"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Copy and paste `abortbundleclasses => { "invalid" };` into
`/var/cfengine/masterfiles/controls/cf_agent.cf`. If you add it to
the end of the file it should look something like this:

```cf3
```cf3 {skip TODO}
...
# dryrun => "true";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ These variables provide path definitions for storing and deploying patches.

Add the following variable information to the `masterfiles/def.cf` file:

```cf3 {file="def.cf"}
```cf3 {file="def.cf" skip TODO}
"dir_patch_store"
string => "/storage/patches",
comment => "Define patch files source location",
Expand Down
10 changes: 5 additions & 5 deletions content/examples/tutorials/integrating-with-sumo-logic.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ First, we define a couple of variables.

The two Sumo variables are used to access the service, while the `curl_args` is the actual curl command that will upload our timestamp file to Sumo Logic.

```cf3
```cf3 {skip TODO}
vars:
"policy_update_file"
string => "/tmp/CFEngine_policy_updated";
Expand All @@ -47,7 +47,7 @@ We also ensures that the content of this file will be the value of the `sys.last

Finally, below you will see a body defining how CFEngine is going to detect changes in policy files, this time using an md5 hash and only looking for change in the content (not permissions or ownership).

```cf3
```cf3 {skip TODO}
files:
"$(policy_update_file)"
create => "true",
Expand All @@ -71,7 +71,7 @@ The final section in the CFEngine policy is where the command that uploads the f

The command will only be issued whenever a class called `new_policy_update` is set, which we above defined to be set when there is a change detection. The handle argument is a useful way to document your intentions.

```cf3
```cf3 {skip TODO}
commands:
new_policy_update::
"/usr/bin/curl"
Expand Down Expand Up @@ -105,7 +105,7 @@ Normally, to ensure your policy file is put into action, you would need to follo

Under the body common control, add `sumo_logic_policy_update` to your bundle sequence.

```cf3
```cf3 {skip TODO}
body common control

{
Expand All @@ -118,7 +118,7 @@ body common control

Under body common control, add /sumologic_policy_update.cf/ to your inputs section.

```cf3
```cf3 {skip TODO}
inputs => {
# File definition for global variables and classes
"sumologic_policy_update.cf",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ through them and look up values.

Well, you can change

```cf3
```cf3 {skip TODO}
"bykey" data => parsejson('{ "dev": ["c", "b"], "prod": ["flea"], "qa": ["a"], "private": ["linux"] }');
```

with

```cf3
```cf3 {skip TODO}
"bykey" data => data_readstringarray(...);
```

Expand All @@ -131,7 +131,7 @@ private linux

You can also use

```cf3
```cf3 {skip TODO}
"bykey" data => readjson(...);
```

Expand Down
50 changes: 22 additions & 28 deletions content/examples/tutorials/manage-ntp.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ You can think of bundles as a collection of desired states. You can have as many

#### vars

```cf3
```cf3 {skip TODO}
vars:
```

`vars` is a promise type that ensures the presence of variables that hold specific values. `vars:` starts a promise type block which ends when the next promise type block is declared.

##### ntp_package_name

```cf3
```cf3 {skip TODO}
"ntp_package_name" string => "ntp";
```

A variable with the name `ntp_package_name` is declared and it is assigned a value, `ntp`. This string variable will be referenced in the other sections of the bundle.

#### packages

```cf3
```cf3 {skip TODO}
packages:
"$(ntp_package_name)" -> { "StandardsDoc 3.2.1" }
policy => "present",
Expand All @@ -62,7 +62,7 @@ packages:

##### $(ntp_package_name)

```
```cf3 {skip TODO}
"$(ntp_package_name)" -> { "StandardsDoc 3.2.1" }
```

Expand All @@ -72,23 +72,23 @@ This promiser has a number of additional attributes defined:

###### policy

```cf3
```cf3 {skip TODO}
policy => "present",
```

The package_policy attribute describes what you want to do the package. In this case you want to ensure that it is present on the system. Other valid values of this attribute include delete, update, patch, reinstall, addupdate, and verify. Because of the self-healing capabilities of CFEngine, the agents will continuously check to make sure the package is installed. If it is not installed, CFEngine will try to install it according to its policy.

###### handle

```cf3
```cf3 {skip TODO}
handle => "ntp_packages_$(ntp_package_name)",
```

The handle uniquely identifies a promise within a policy. A recommended naming scheme for the handle is `bundle_name_promise_type_class_restriction_promiser`. It is often used for documentation and compliance purposes. As shown in this example, you can easily substitute values of variables for the handle.

###### classes

```cf3
```cf3 {skip TODO}
classes => results("bundle", "ntp_package_");
```

Expand Down Expand Up @@ -134,16 +134,10 @@ Validate it.
python -m json.tool < def.json
```

```output
```json {output}
{
"inputs": [
"services/ntp.cf"
],
"vars": {
"control_common_bundlesequence_end": [
"ntp"
]
}
"inputs": ["services/ntp.cf"],
"vars": { "control_common_bundlesequence_end": ["ntp"] }
}
```

Expand Down Expand Up @@ -213,7 +207,7 @@ Let's dissect this policy and review the differences in the policy.

#### vars

```cf3
```cf3 {skip TODO}
redhat::
"ntp_service_name" string => "ntpd";
debian::
Expand All @@ -224,7 +218,7 @@ The first thing that you will notice is that the variable declarations section h

#### reports

```cf3
```cf3 {skip TODO}
reports:
ntp_service_repaired.inform_mode::
"NTP service repaired";
Expand All @@ -238,7 +232,7 @@ ntp_service_repaired.inform_mode::

This line restricts the context for the promises that follow to hosts that have `ntp_service_repaired` and `inform_mode` defined. Note: `inform_mode` is defined when information level logging is requested, e.g. the `-I`, `--inform`, or `--log-level inform` options are given to `cf-agent` defined.

```cf3
```cf3 {skip TODO}
"NTP service repaired";
```

Expand Down Expand Up @@ -360,7 +354,7 @@ Let's review the different sections of the code, starting with the variable decl

#### vars

```cf3
```cf3 {skip TODO}
vars:
linux::
"ntp_package_name" string => "ntp";
Expand Down Expand Up @@ -390,7 +384,7 @@ A few new variables are defined. The variables `ntp_package_name`, `config_file`

Now let's walk through the files promise in detail.

```cf3
```cf3 {skip TODO}
files:
"$(config_file)"
create => "true",
Expand All @@ -406,55 +400,55 @@ The promiser here is referenced by the `config_file` variable. In this case, it

##### create

```cf3
```cf3 {skip TODO}
create => "true",
```

Valid values for this attribute are `true` or `false` to instruct the agent whether or not to create the file. In other words, the file must exist. If it does not exist, it will be created.

##### perms

```cf3
```cf3 {skip TODO}
perms => mog( "644", "root", "root" ),
```

This attribute sets the permissions and ownership of the file. [`mog()`][stdlib-mog] is a `perms` body in the CFEngine standard library that sets the `mode`, `owner`, and `group` of the file. In this example, the permissions for the NTP configuration file are set to `644` with _owner_ and _group_ both assigned to `root`.

##### handle

```cf3
```cf3 {skip TODO}
handle => "ntp_files_conf",
```

A handle uniquely identifies a promise within a policy set. The [policy style guide][Policy style guide#promise handles] recommends a naming scheme for the handles e.g. `bundle_name_promise_type_class_restriction_promiser`. Handles are optional, but can be very useful when reviewing logs and can also be used to influence promise ordering with `depends_on`.

##### classes

```cf3
```cf3 {skip TODO}
classes => results( "bundle", "ntp_config" );
```

The classes attribute here uses the [`results()`][lib/common.cf#results] classes body from the standard library. The `results()` body defines classes for every outcome a promise has. Every time this promise is executed classes will be defined bundle scoped classes prefixed with `ntp_config`. If the promise changes the file content or permissions the class `ntp_config_repaired` will be set.

##### template_method

```cf3
```cf3 {skip TODO}
template_method => "inline_mustache",
```

CFEngine supports multiple templating engines, the [template_method][files#template_method] attribute specifies how the promised file content will be resolved. The value `inline_mustache` indicates that we will use the mustache templating engine and specify the template in-line, instead of in an external file.

##### edit_template_string

```cf3
```cf3 {skip TODO}
edit_template_string => "$(config_template_string)",
```

The `edit_template_string` attribute is set to `$(config_template_string)` which holds the mustache template used to render the file content.

##### template_data

```cf3
```cf3 {skip TODO}
template_data => mergedata( '{ "driftfile": "$(driftfile)", "servers": servers }' ),
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ bundle agent myapp_confs
}
');
}
body agent __main__
bundle agent __main__
{
methods:
"myapp_confs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ reports:

A bonus to this is that you can get CFEngine to report system anomalies:

```cf3
```cf3 {skip TODO}
reports:

rootprocs_high_dev2::
Expand Down
4 changes: 2 additions & 2 deletions content/examples/tutorials/tags.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ way to categorize various data accessible to the agent.
Dynamic bundlesequences are extremely easy. First you find all the bundles whos
name matches a regular expression and N tags.

```cf3
```cf3 {skip TODO}
vars:
"bundles" slist => bundlesmatching("regex", "tag1", "tag2", ...);
```

Then every bundle matching the regular expression `regex` and **all**
the tags will be found and run.

```cf3
```cf3 {skip TODO}
methods:
"run $(bundles)" usebundle => $(bundles);
```
Expand Down
Loading