General chef question


#1

Hi,

I am new to Chef and trying to explore it. I downloaded the chef-dk and chef client on my switch which runs debian linux. I believe you need either a chef client or chef-dk to run on the switch which can talk to a chef-server isn’t?.

I looked at some examples of JunOS integrated with chef. If I use white box with a debian linux on it can I download ruby using apt-get and install chef client and write some ruby scripts to configure the linux switch?

I can program the switch and configure IP address or vlan using python scripts. Can we integrate the python scripts with chef?

Any help on these is much appreciated.

Thanks,


#2

You can write Chef recipes to manage your switch, especially if it’s
running Debian. Most Resources (user, service, packages, etc.) are going to
work just like a regular Linux box, but you can use the ‘execute’ resource
to call your Python scripts. I’d recommend looking through
Supermarket.chef.io for examples of the services you want to manage, or dig
into the Cisco cookbook to see a complex cookbook example.
https://supermarket.chef.io/cookbooks/cisco-cookbook

Thanks,
Matt Ray
Manager, Solutions Architect - APJ :: Chef
matt@chef.io
AUS: +61 457 231 372
US: +1 512 731 2218
mattray :: GitHub :: IRC :: Slack :: Twitter


#3

Thanks for the reply. I see that in the chef documentation the network nodes supported are cisco juniper, arista and F5.If we run one of the Linux based OS like openswitch, cumulus or any other OS do we need to add cookbooks to support it?


#4

If the chef-client runs on those network platforms, it probably works for
many things if it’s just Linux commands. For networking specific resources
(ie. bgp, vlans, etc.) there are not built-in features supporting them and
you may have to write new cookbooks to take advantage of those features.
Networking commands are very platform-specific, so what works on Cumulus
may not work on Arista for example.

Thanks,
Matt Ray
Manager, Solutions Architect - APJ :: Chef
matt@chef.io
AUS: +61 457 231 372
US: +1 512 731 2218
mattray :: GitHub :: IRC :: Slack :: Twitter


#5

Hi Matt,

Can you point me to the procedure to install the chef-client on a debian based linux switch. what are the steps involved. I used fhe following package chef_12.16.42-1_amd64.deb. I have installed this package in the
linux switch.
I have a chef-server running and also a chef workstation running in my network. If i run the ‘knife client list’ command on the cheff-workstation it shows the validator string.So check workstation and chef-server are able to connect.
I have a network node in the same network as chef-server and chef-workstation. what are the minimum steps to make the network switch as a chef-client after installing the debian package mentioned above.

Thanks.


#6

Unless you have a large number of switches to manage, you will probably end
up installing by hand or using “knife bootstrap” with a custom bootstrap
template if you have to use something not provided by the default install
(ie. a custom-ARM build).
https://docs.chef.io/knife_bootstrap.html

Thanks,
Matt Ray
Manager, Solutions Architect - APJ :: Chef
matt@chef.io
AUS: +61 457 231 372 <+61%20457%20231%20372>
US: +1 512 731 2218 <(512)%20731-2218>
mattray :: GitHub :: IRC :: Slack :: Twitter


#7

Hi Matt,

How can we pass parameters or attributes to recipes? In the below example I want the parameters of python script to be passed how can i do it. Below is the recipe under the cookbook test.cfg. I want the parameter id, port and name to be available dynamically when the chef-client runs on the node.

bash “Run python script” do
user "root"
cwd '/tmp/test/'
code <<-EOH
./show-version
python hostname
python example.py --add --id 100 --port eth2 <— how can I get value 100 and eth2 when chef-client executes
python example.py --del --name br100 <— here also I want the name to be passed to this recipe
EOH