ARCHIVED: This project is unmaintained, reach out if you would like to adopt
Manipulate Chef attributes via Knife
Install via rubygems:
gem install knife-attribute
Or for more recent Chef or ChefDK installations:
chef gem install knife-attribute
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).
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"]
.
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.
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']
.
Valid attribute types for roles are: ['default', 'override']
.
For usage, see node attribute set
above.
Valid attribute types for roles are: ['default', 'override']
.
For usage, see node attribute get
above.
Valid attribute types for roles are: ['default', 'override']
.
For usage, see node attribute delete
above.
Valid attribute types for environments are: ['default', 'override']
.
For usage, see node attribute set
above.
Valid attribute types for environments are: ['default', 'override']
.
For usage, see node attribute get
above.
Valid attribute types for environments are: ['default', 'override']
.
For usage, see node attribute delete
above.