Cookbook Recipe : 6
Example6: Adding Multiple cookbooks to Multiple Nodes.
[root@chef-workstation recipes]# knife node list
Node-1
Node-2
[root@chef-workstation recipes]# vi node.sh
[root@chef-workstation recipes]# cat node.sh
for i in Node-1 Node-2
do
knife node run_list add $i "recipe[cookbook1]","recipe[cookbook2]"
done
[root@chef-workstation recipes]# knife node show Node-1
Node Name: Node-1
Environment: _default
FQDN: node1
IP: 192.168.2.133
Run List:
Roles:
Recipes:
Platform: centos 7.9.2009
Tags:
[root@chef-workstation recipes]# knife node show Node-2
Node Name: Node-2
Environment: _default
FQDN: node2
IP: 192.168.2.128
Run List: recipe[cookbook1], recipe[cookbook2]
Roles:
Recipes:
Platform: centos 7.9.2009
Tags:
[root@chef-workstation recipes]# ./node.sh
Node-1:
run_list:
recipe[cookbook1]
recipe[cookbook2]
Node-2:
run_list:
recipe[cookbook1]
recipe[cookbook2]
[root@chef-workstation recipes]# knife node show Node-1
Node Name: Node-1
Environment: _default
FQDN: node1
IP: 192.168.2.133
Run List: recipe[cookbook1], recipe[cookbook2]
Roles:
Recipes:
Platform: centos 7.9.2009
Tags:
[root@chef-workstation recipes]# knife node show Node-2
Node Name: Node-2
Environment: _default
FQDN: node2
IP: 192.168.2.128
Run List: recipe[cookbook1], recipe[cookbook2]
Roles:
Recipes:
Platform: centos 7.9.2009
Tags:
[root@chef-workstation recipes]#
Adding cookbook3 to all Nodes in the server.
[root@chef-workstation recipes]# knife node list
Node-1
Node-2
[root@chef-workstation recipes]# vi all_node.sh
[root@chef-workstation recipes]# chmod +x all_node.sh
[root@chef-workstation recipes]# cat all_node.sh
for i in $(knife node list)
do
knife node run_list add $i "recipe[cookbook3]"
done
[root@chef-workstation recipes]# ./all_node.sh
Node-1:
run_list:
recipe[cookbook1]
recipe[cookbook2]
recipe[cookbook3]
Node-2:
run_list:
recipe[cookbook1]
recipe[cookbook2]
recipe[cookbook3]
[root@chef-workstation recipes]#
----------------------------End of Example6---------------------------------------
Great
ReplyDelete