Configuration procedure

  1. Configure the Chef server:

    # Create user key file admin.pem for the workstation. Specify the workstation username as Herbert George Wells, the Email address as abc@xyz.com, and the password as 123456.

    $ chef-server-ctl user-create Herbert George Wells abc@xyz.com 123456 –filename=/etc/chef/admin.pem
    

    # Create organization key file admin_org.pem for the workstation. Specify the abbreviated organization name as ABC and the organization name as ABC Technologies Co., Limited. Associate the organization with the user Herbert.

    $ chef-server-ctl org-create ABC_org "ABC Technologies Co., Limited" –association_user Herbert –filename =/etc/chef/admin_org.pem
    

    # Create user key file client.pem for the Chef client. Specify the Chef client username as Herbert George Wells, the Email address as abc@xyz.com, and the password as 123456.

    $ chef-server-ctl user-create Herbert George Wells abc@xyz.com 123456 –filename=/etc/chef/client.pem
    

    # Create organization key file validator.pem for the Chef client. Specify the abbreviated organization name as ABC and the organization name as ABC Technologies Co., Limited. Associate the organization with the user Herbert.

    $ chef-server-ctl org-create ABC "ABC Technologies Co., Limited" –association_user Herbert –filename =/etc/chef/validator.pem
    

    # Create Chef configuration file chefclient.rb for the Chef client.

    log_level :info 
    log_location STDOUT
    node_name 'Herbert'
    chef_server_url 'https://1.1.1.2:443/organizations/hpe'
    validation_key 'flash:/chef/validator.pem'
    client_key 'flash:/chef/client.pem' 
    cookbook_path [ 'flash:/chef-repo/cookbooks' ]
    
  2. Configure the workstation:

    # Create the chef-repo directory on the workstation. This directory will be used as the working path.

    $ mkdir /chef-repo
    

    # Create the .chef directory. This directory will be used to store the Chef configuration file for the workstation.

    $ mkdir –p /chef-repo/.chef
    

    # Create Chef configuration file knife.rb in the /chef-repo/.chef0 directory.

    log_level                :info
    log_location             STDOUT
    node_name                'admin'
    client_key               '/root/chef-repo/.chef/admin.pem'
    validation_key           '/root/chef-repo/.chef/admin_org.pem'
    chef_server_url          'https://chef-server:443/organizations/hpe'
    

    # Use TFTP or FTP to download the key files for the workstation from the Chef server to the /chef-repo/.chef directory on the workstation. (Details not shown.)

    # Create resource directory netdev.

    $ knife cookbook create netdev
    

    After the command is executed, the netdev directory is created in the current directory. The directory contains files and subdirectories for the resource. The recipes directory stores the resource file.

    # Create resource file default.rb in the recipes directory.

    netdev_vlan 'vlan3' do
     vlan_id 3
     action :create
    end
    

    # Upload the resource file to the Chef server.

    $ knife cookbook upload –all
    
  3. Configure the Chef client:

    # Configure SSH login and enable NETCONF over SSH on the device. (Details not shown.)

    # Use TFTP or FTP to download Chef configuration file chefclient.rb from the Chef server to the root directory of the Flash memory on the Chef client. Make sure this directory is the same as the directory specified by using the --config=filepath option in the third-part-process start command.

    # Use TFTP or FTP to download key files validator.pem and client.pem from the Chef server to the flash:/chef/ directory.

    # Start Chef. Specify the Chef configuration file name and path as flash:/chefclient.rb and the resource file name as netdev.

    <ChefClient> system-view
    [ChefClient] third-part-process start name chef-client arg --config=flash:/chefclient.rb --runlist recipe[netdev]
    

    After the command is executed, the Chef client downloads the resource file from the Chef server and loads the settings in the resource file.