Giter VIP home page Giter VIP logo

knife-attribute's Introduction

ARCHIVED: This project is unmaintained, reach out if you would like to adopt

knife-attribute

Manipulate Chef attributes via Knife

Installation

Install via rubygems:

gem install knife-attribute

Or for more recent Chef or ChefDK installations:

chef gem install knife-attribute

Usage

To work with attributes of type default, normal or override, use the -t TYPE flag (the default type if unspecified is normal for nodes, and default for all other entity types).

node attribute set

Setting node attributes may be achieved as follows:

knife node attribute set foo.example.org tz 'Australia/Melbourne'

The above would set the foo.example.org node's normal attribute tz to the string Austraila/Melbourne.

You may specify either a regular string, or a JSON structure, ie:

knife node attribute set foo.example.org apache.listen_ports '["80", "443"]' -t override

The above would set the foo.example.org node's override attribute ['apache']['listen_ports'] to the array ["80", "443"].

node attribute get

Getting node attributes may be achieved as follows:

knife node attribute get foo.example.org apache.listen_ports

Use the standard -F FORMAT flag to set the output format for complex data structures.

Unlike other actions, by default the get action will return the combined (effective) value for the attribute, if an attribute type (-t TYPE) is not specified.

knife node attribute get foo.example.org apache.listen_ports -t override -F json

The above would get the foo.example.org node's override attribute ['apache']['listen_ports'] and output it as JSON.

node attribute delete

Deleting node attributes may be achieved as follows:

knife node attribute delete foo.example.org tz

The above would delete the foo.example.org node's normal attribute tz.

knife node attribute delete foo.example.org apache.listen_ports -t override

The above would delete the foo.example.org node's override attribute ['apache']['listen_ports'].

role attribute set

Valid attribute types for roles are: ['default', 'override'].

For usage, see node attribute set above.

role attribute get

Valid attribute types for roles are: ['default', 'override'].

For usage, see node attribute get above.

role attribute delete

Valid attribute types for roles are: ['default', 'override'].

For usage, see node attribute delete above.

environment attribute set

Valid attribute types for environments are: ['default', 'override'].

For usage, see node attribute set above.

environment attribute get

Valid attribute types for environments are: ['default', 'override'].

For usage, see node attribute get above.

environment attribute delete

Valid attribute types for environments are: ['default', 'override'].

For usage, see node attribute delete above.

knife-attribute's People

Contributors

pdf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

knife-attribute's Issues

dot

Unable to handle a dot (.) character in attribute key name while setting or getting an attribute.

Setting a boolean value sets a string instead

Trying to set a boolean value ends up setting a string instead.

knife node attribute set testnode testvalue true
Successfully set node testnode attribute testvalue to: "true"

on line

new_value = Chef::JSONCompat.from_json(value)
Chef::JSONCompat.from_json(value) only allows values where the top level is a hash or array.

Chef::Exceptions::JSON::ParseError: Top level JSON object must be a Hash or Array. (actual: TrueClass)

Support -t automatic for "node attribute get"

This should be very simple to implement.
I want to be able to display specific -t automatic entries without resorting to not specifying -t at all (which does the merge and includes -t default stuff as well)
If this is as easy as adding 'automatic' to the typemap, i will do it and submit a pull request.

delete bug

Line 53 should contain attribute rather than new_attribute, this way delete fails with an error.

Set bool or integers

I know this has not been updated in a while but im looking if its possible to set booleans and integers with this as i can only get strings.

Thanks

Not working with `knife rehash`

Hi

bash# chef gem install knife-attribute
Fetching: knife-attribute-1.1.0.gem (100%)
Successfully installed knife-attribute-1.1.0
1 gem installed

bash# knife rehash

bash# knife node attribute get sql-server mariadb

/Users/balazsasd/.chefdk/gem/ruby/2.4.0/gems/knife-attribute-1.1.0/lib/knife-attribute/node/get.rb:4:in <class:NodeAttributeGet>': uninitialized constant KnifeAttribute::Node::Helpers (NameError) from /Users/balazsasd/.chefdk/gem/ruby/2.4.0/gems/knife-attribute-1.1.0/lib/knife-attribute/node/get.rb:3:in module:Node'
from /Users/balazsasd/.chefdk/gem/ruby/2.4.0/gems/knife-attribute-1.1.0/lib/knife-attribute/node/get.rb:2:in <module:KnifeAttribute>' from /Users/balazsasd/.chefdk/gem/ruby/2.4.0/gems/knife-attribute-1.1.0/lib/knife-attribute/node/get.rb:1:in <top (required)>'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/knife/core/hashed_command_loader.rb:80:in load' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/knife/core/hashed_command_loader.rb:80:in block in load_command'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/knife/core/hashed_command_loader.rb:78:in each' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/knife/core/hashed_command_loader.rb:78:in load_command'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/knife/core/subcommand_loader.rb:109:in command_class_from' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/knife.rb:153:in subcommand_class_from'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/knife.rb:214:in run' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/lib/chef/application/knife.rb:156:in run'
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4/bin/knife:25:in <top (required)>' from /usr/local/bin/knife:255:in load'
from /usr/local/bin/knife:255:in `

'

bash# chef --version
Chef Development Kit Version: 2.4.17
chef-client version: 13.6.4
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.19.2
inspec version: 1.45.13
bash#

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.