Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

RSS

export-node (3) Versions 1.0.0

Exports node attributes to a json file

Berkshelf/Librarian
Policyfile
Knife
cookbook 'export-node', '= 1.0.0'
cookbook 'export-node', '= 1.0.0', :supermarket
knife cookbook site install export-node
knife cookbook site download export-node
README
Dependencies
Quality 100%

export-node

export-node exports node attributes to a json file so that it can be retrieved from a kitchen test.

Usage

Add the export-node cookbook to the end of the runlist in your kitchen suites:

suites:
  - name: my-suite
    run_list:
      - recipe[cookbook-under-test]
      - recipe[export-node]

Now your tests can access any node attribute by parsing the file's json to a hash:

describe file('/etc/haproxy/haproxy.cfg') do
  let(:node) { JSON.parse(IO.read('/tmp/export-node/node.json')) }
  let(:subnet) {
    ip = node["automatic"]["ipaddress"]
    ip[0,ip.rindex(".")]
  }
  let(:current_env) { node["chef_environment"].upcase}

  it { should be_a_file }
  its(:content) {
    should match <<-EOS
        backend elasticsearch_backend
            mode http
            balance roundrobin
            server #{current_env}SEARCH01 #{subnet}.121:9200 weight 1 check port 9200
            server #{current_env}SEARCH02 #{subnet}.122:9200 weight 1 check port 9200
            server #{current_env}SEARCH03 #{subnet}.123:9200 weight 1 check port 9200


        backend web_backend
            mode http
            balance roundrobin
            timeout server 5m
            server #{current_env}WEB01 #{subnet}.131:80 weight 1 check port 80
            server #{current_env}WEB02 #{subnet}.132:80 weight 1 check port 80


        backend rabbit_backend
            mode http
            balance roundrobin
            server #{current_env}RABBIT01 #{subnet}.141:15672 weight 1 check port 15672
            server #{current_env}RABBIT02 #{subnet}.142:15672 weight 1 check port 15672
            server #{current_env}RABBIT03 #{subnet}.143:15672 weight 1 check port 15672
    EOS
  }
end

Windows instances will store the node data in %TEMP%\export-node\node.json and other platforms will store the node data in /tmp/export-node/node.json.

Dependent cookbooks

This cookbook has no specified dependencies.

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Foodcritic Metric
            

1.0.0 passed this metric