Sha256: af4cc6d126c32400a02f6cde0cb7cd1a5a725bd100291242f475706cf43174a5

Contents?: true

Size: 1.56 KB

Versions: 39

Compression:

Stored size: 1.56 KB

Contents

---
title: About the yaml Resource
platform: os
---

# yaml

Use the `yaml` InSpec audit resource to test configuration data in a Yaml file.

<br>

## Syntax

A `yaml` resource block declares the configuration data to be tested. Assume the following Yaml file:

    name: foo
    array:
      - zero
      - one

This file can be queried using:

    describe yaml('filename.yml') do
      its('name') { should eq 'foo' }
      its(['array', 1]) { should eq 'one' }
    end

where

* `name` is a configuration setting in a Yaml file
* `should eq 'foo'` tests a value of `name` as read from a Yaml file versus the value declared in the test

Like the `json` resource, the `yaml` resource can read a file, run a command, or accept content inline:

    describe yaml('config.yaml') do
      its(['driver', 'name']) { should eq 'vagrant' }
    end

    describe yaml({ command: 'retrieve_data.py --yaml' }) do
      its('state') { should eq 'open' }
    end

    describe yaml({ content: "\"key1: value1\nkey2: value2\"" }) do
      its('key2') { should cmp 'value2' }
    end

<br>

## Examples

The following examples show how to use this InSpec audit resource.

### Test a kitchen.yml file driver

    describe yaml('.kitchen.yaml') do
      its(['driver','name']) { should eq('vagrant') }
    end

<br>

## Matchers

For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).

### name

The `name` matcher tests the value of `name` as read from a Yaml file versus the value declared in the test:

    its('name') { should eq 'foo' }

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
inspec-core-2.2.55 docs/resources/yaml.md.erb
inspec-2.2.55 docs/resources/yaml.md.erb
inspec-core-2.2.54 docs/resources/yaml.md.erb
inspec-2.2.54 docs/resources/yaml.md.erb
inspec-core-2.2.50 docs/resources/yaml.md.erb
inspec-2.2.50 docs/resources/yaml.md.erb
inspec-core-2.2.41 docs/resources/yaml.md.erb
inspec-2.2.41 docs/resources/yaml.md.erb
inspec-core-2.2.35 docs/resources/yaml.md.erb
inspec-2.2.35 docs/resources/yaml.md.erb
inspec-core-2.2.34 docs/resources/yaml.md.erb
inspec-2.2.34 docs/resources/yaml.md.erb
inspec-core-2.2.27 docs/resources/yaml.md.erb
inspec-2.2.27 docs/resources/yaml.md.erb
inspec-core-2.2.20 docs/resources/yaml.md.erb
inspec-2.2.20 docs/resources/yaml.md.erb
inspec-core-2.2.16 docs/resources/yaml.md.erb
inspec-2.2.16 docs/resources/yaml.md.erb
inspec-core-2.2.10 docs/resources/yaml.md.erb
inspec-2.2.10 docs/resources/yaml.md.erb