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

ups_utils (1) Versions 0.1.0

Installs/Configures Network UPS Tools

Berkshelf
Policyfile
Knife
cookbook 'ups_utils', '~> 0.1.0'
cookbook 'ups_utils', '~> 0.1.0', :supermarket
knife supermarket install ups_utils
knife supermarket download ups_utils
README
Dependencies
Changelog
Quality 50%

ups_utils Cookbook

This cookbook sets up Network UPS Tools.

Contents

Requirements

platforms

  • Debian >= 9.0
  • Ubuntu >= 16.04

packages

  • none.

Attributes

Key Type Description, example Default
['ups_utils']['nut']['secrets'] String Chef-vault conf. for secrets (password,...). empty. See attributes/default.rb
['ups_utils']['nut']['hosts.conf'] Hash Conf. for CGI. empty. See attributes/default.rb
['ups_utils']['nut']['hosts.conf']['MONITORs'] Array e.g. ['by80s@upsd.example.com "@upsd - Omron BY80S"'] empty.
['ups_utils']['nut']['nut.conf'] Hash See attributes/default.rb
['ups_utils']['nut']['nut.conf']['MODE'] String 'none', 'netclient', 'standalone' or 'netserver' 'none'
['ups_utils']['nut']['ups.conf'] Hash empty. See attributes/default.rb
['ups_utils']['nut']['upsd.conf'] Hash See attributes/default.rb
['ups_utils']['nut']['upsd.conf']['LISTENs'] Array e.g. ['LISTEN 0.0.0.0 3493'] empty.
['ups_utils']['nut']['upsd.users'] String empty. See attributes/default.rb
['ups_utils']['nut']['upsmon.conf'] Hash See attributes/default.rb
['ups_utils']['nut']['upsmon.conf']['MONITORs'] Array e.g. ['by80s@localhost 1 upsmon {{upsmon_password}} master'] empty.
['ups_utils']['nut']['udev_usbups_rules'] Array e.g. ['ATTR{idVendor}=="0590", ATTR{idProduct}=="00a1", MODE="664", GROUP="nut"'] empty.

Usage

Recipes

ups_utils::default

This recipe does nothing.

ups_utils::nut

This recipe sets up a NUT server or client.

ups_utils::nut-cgi

This recipe configures NUT CGI.

Role Examples

  • roles/nut-server.rb
name 'nut-server'
description 'Network UPS Tools Server'

upsd_port = '3493'

run_list(
  'recipe[ups_utils::nut]',
)

override_attributes(
  'ups_utils' => {
    'nut' => {
      'secrets' => {
        'upsmon_password' => {
          'vault' => 'nut',
          'name' => 'upsmon',
          'env_context' => false,
          'key' => 'password',  # real hash path: "/password"
        },
      },    
      'nut.conf' => {
        'MODE' => 'netserver',
      },
      'ups.conf' => {
        'by80s' => {
          'driver' => 'blazer_usb',
          'port' => 'auto',
          'desc' => '"Omron UPS"',
          'vendorid' => '0590',
          'productid' => '00a1',
          'subdriver' => 'ippon',
          'default.battery.voltage.high' => '27.2',
          'default.battery.voltage.low' => '23.5',
        },
      },
      'upsd.conf' => {
        'LISTENs' => [
          "0.0.0.0 #{upsd_port}",
        ],
      },
      'upsd.users' => {
        'upsmon' => {
          'password' => '{{upsmon_password}}',
          'upsmon' => 'master',
        },
      },    
      'upsmon.conf' => {
        'MONITORs' => [
          'by80s@localhost 1 upsmon {{upsmon_password}} master',
        ],
      },
      'udev_usbups_rules' => [
        '# Omron BY80S - blazer_usb',
        'ATTR{idVendor}=="0590", ATTR{idProduct}=="00a1", MODE="664", GROUP="nut"',
      ],
    },
  },
)
  • roles/nut-client.rb
name 'nut-client'
description 'Network UPS Tools Client'

nut_host = 'upsd.example.com'

run_list(
  'recipe[ups_utils::nut]',
)

override_attributes(
  'ups_utils' => {
    'nut' => {
      'secrets' => {
        'upsmon_password' => {
          'vault' => 'nut',
          'name' => 'upsmon',
          'env_context' => false,
          'key' => 'password',  # real hash path: "/password"
        },
      },    
      'nut.conf' => {
        'MODE' => 'netclient',
      },
      'upsd.conf' => {
        'LISTENs' => [
          # empty,
        ],
      },
      'upsmon.conf' => {
        'MONITORs' => [
          "by80s@#{nut_host} 1 upsmon {{upsmon_password}} master",
        ],
      },
    },
  },
)
  • roles/nut-cgi.rb
name 'nut-cgi'
description 'Network UPS Tools CGI'

nut_host = 'upsd.example.com'

run_list(
  'role[nut-client]',
  'recipe[ups_utils::nut-cgi]',
)

override_attributes(
  'ups_utils' => {
    'nut' => {
      'hosts.conf' => {
        'MONITORs' => [
          %(by80s@#{nut_host} "@#{nut_host.split('.')[0]} - Omron BY80S"),
        ],
      },
    },
  },
)

Secrets management by Chef Vault

  • create vault items.
$ cat ~/sec/tmp/upsmon_password.json
{
  "password":"********************"
}

$ cd $CHEF_REPO_PATH
$ knife vault create nut upsmon --json ~/sec/tmp/upsmon_password.json
  • grant reference permission to the upsd host
$ knife vault update nut upsmon -S 'name:upsd-host.example.com'
  • modify attributes
override_attributes(
  'ups_utils' => {
    'nut' => {
      'secrets' => {
        'upsmon_password' => {
          'vault' => 'nut',
          'name' => 'upsmon',
          # single password or nested hash password path delimited by slash
          'env_context' => false,
          'key' => 'password',  # real hash path: "/password"
          # or nested hash password path delimited by slash
          #'env_context' => true,
          #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
        },
      },     
      # ...
    },
  },
)

License and Authors

  • Author:: whitestar at osdn.jp
Copyright 2018, whitestar

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Dependent cookbooks

ssl_cert >= 0.4.1

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

ups_utils CHANGELOG

0.1.0

  • Initial release of ups_utils

Collaborator Number Metric
            

0.1.0 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

0.1.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

0.1.0 passed this metric

No Binaries Metric
            

0.1.0 passed this metric

Publish Metric
            

0.1.0 passed this metric

Supported Platforms Metric
            

0.1.0 passed this metric

Testing File Metric
            

0.1.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

0.1.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number