How can I edit a chef attribute of an ec2 node using knife

后端 未结 3 1015
深忆病人
深忆病人 2021-01-02 23:44

I want to edit ec2 node\'s node_data using a knife node command.
I can manually do it by using below command.
knife node edit NODE_NAME

3条回答
  •  难免孤独
    2021-01-03 00:27

    if you want to

    add new attribute

    knife exec -E "nodes.find(:name => 'NODE-1') { |node|   node.normal_attrs[:attribute_name]='Value' ; node.save; }"
    

    Need to update attribute

    its depends on node attribute type

    if node attribute is json then run this command

    knife exec -E "nodes.find(:name => 'NODE-1') { |node|   node.normal_attrs['node_data'][:attribute_name]= 'Value' ; node.save; }"
    

    if node attribute in array type

    knife exec -E "nodes.find(:name => 'NODE-1') { |node|   node.normal.tags << {'attribute_name'=>'Value',''=>}; node.save; }"
    

提交回复
热议问题