Skip to content
/ Monk Public

🔥Easy To Use Chef Cookbooks To Automate Boring Stuff

License

Notifications You must be signed in to change notification settings

Clivern/Monk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monk

Easy To Use Chef Recipes To Automate Boring Stuff.

Setup

Install the Chef Server Ubuntu 16.04 x64

  1. Ensure that the Server is Accessible by Hostname The first task you need to perform is to ensure that the hostname of the server is a resolvable fully qualified domain name (FQDN) or IP address. You can check this by typing:
hostname -f

It should be something like the following:

sudo nano /etc/hosts
127.0.1.1 fqdn_or_IP_address host_alias
127.0.0.1 localhost
IP_address fqdn_or_IP_address host_alias
  1. Ensure that Server are up-to-date:
sudo apt-get update
  1. Download the latest Chef server core (12.17.15 at the time of writing):
wget https://packages.chef.io/files/stable/chef-server/12.17.15/ubuntu/16.04/chef-server-core_12.17.15-1_amd64.deb
  1. Install the server:
sudo dpkg -i chef-server-core_*.deb
  1. Remove the download file:
rm chef-server-core_*.deb
  1. Run the chef-server-ctl command to start the Chef server services:
sudo chef-server-ctl reconfigure

Create an Admin User and Organization

  1. We can use the user-create sub-command of the chef-server-ctl command. The command requires a number of fields to be passed and The general syntax is:
chef-server-ctl user-create USERNAME FIRST_NAME LAST_NAME EMAIL PASSWORD

For example, Let's go with the following:

sudo chef-server-ctl user-create monk john doe hello@monk.com password -f monk.pem
  1. You can create an organization with the org-create sub-command.
chef-server-ctl org-create SHORTNAME LONGNAME --association_user USERNAME

For example, let's go with the following:

sudo chef-server-ctl org-create clivern "Clivern.com" --association_user monk -f clivern-validator.pem

Install Management Server

In order to install the management server, Just run the following:

chef-server-ctl install chef-manage
chef-server-ctl reconfigure
chef-manage-ctl reconfigure

Configure a Chef Workstation

  1. Clone this repository.
git clone https://github.com/Clivern/Monk.git Monk
  1. Download and Install the Chef Development Kit.

  2. Create .chef directory inside Monk repository.

cd Monk
mkdir .chef
  1. Then transfer the previously created private keys on chef server to .chef directory.
cd Monk
scp root@chef_server_domain_or_ip:/root/monk.pem ./.chef
scp root@chef_server_domain_or_ip:/root/clivern-validator.pem ./.chef

Configuring Knife to Manage your Chef Environment

Now that you have your Chef keys available on your workstation, we can configure the knife to connect to and control your Chef infrastructure. This is done through a knife.rb file that we will place inside .chef directory along with our keys.

nano ./.chef/knife.rb

In this file, paste the following information:

current_dir = File.dirname(__FILE__)
log_level                :info
log_location             STDOUT
node_name                "username"
client_key               "#{current_dir}/name_of_user_key"
validation_client_name   "organization_name-validator"
validation_key           "#{current_dir}/organization_key"
chef_server_url          "https://server_domain_or_IP/organizations/organization_name"
syntax_check_cache_path  "#{ENV['HOME']}/.chef/syntaxcache"
cookbook_path            ["#{current_dir}/../cookbooks"]

Which on our case should be something like the following:

current_dir = File.dirname(__FILE__)
log_level                :info
log_location             STDOUT
node_name                "monk"
client_key               "#{current_dir}/monk.pem"
validation_client_name   "clivern-validator"
validation_key           "#{current_dir}/clivern-validator.pem"
chef_server_url          "https://server_domain_or_IP/organizations/clivern"
syntax_check_cache_path  "#{ENV['HOME']}/.chef/syntaxcache"
cookbook_path            ["#{current_dir}/../cookbooks"]

Now if we run knife client list, we should get clivern-validator.

Bootstrapping a New Node with Knife

In order to bootstrap a new node, you can use the following command:

knife bootstrap node_domain_or_IP [options]

In case we want to bootstrap a node with name node-01 and username is root and the private key is in .chef directory, we should run the following on our chef workstation.

knife bootstrap node_domain_or_IP -x root -A -N node-01

Once your new node is bootstrapped, you should have a new client and a new node:

$ knife client list

    clivern-validator
    node-01


$ knife node list

    node-01

Our Cookbooks

Community Cookbooks

  • Users: Manages OS users from databags.

Acknowledgements

© 2018, Clivern. Released under The Apache Software License, Version 2.0.

Monk is authored and maintained by @clivern.