Skip to content

Commit

Permalink
Refactor for Chef Server 12
Browse files Browse the repository at this point in the history
This commit refactors the cookbook for Chef Server 12. The README
covers the new scope of this cookbook. We’ve attempted to preserve
parity in platform support with that of Chef Server 12 itself.

* Remove the omnitruck API client library and related attributes
* Use packagecloud repository for packages through the
chef_server_ingredient resource
* Remove the “dev” recipe
* Remove the dependency on the git cookbook
* Remove the Vagrantfile - we use test-kitchen now
* Update the Berksfile accordingly
* Add ServerSpec tests

Fixes #46, COOK-4691: use IP address as hostname.

Fixed merge conflicts:

	.kitchen.yml
	recipes/default.rb

Added tests for the no-fqdn suite.

whitespace, be aligned correctly

chef-solo needs dependencies

In the README steps for doing the chef-solo run with this cookbook we
also need to get the dependencies in place, since we don’t have a
depsolver to do this.

also update the cloud in the kitchen

it's cool when you forget to save all changes

use supermarket for all cookbooks in the solo instructions
  • Loading branch information
jtimberman committed Feb 25, 2015
1 parent 5139271 commit 0f2d123
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 627 deletions.
15 changes: 11 additions & 4 deletions .kitchen.cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ provisioner:
require_chef_omnibus: latest

platforms:
- name: centos-5.8
- name: centos-5.11
driver_plugin: digital_ocean
driver_config:
size: 2gb
image: centos-5-8-x64
image: centos-5-11-x64
region: <%= ENV['DIGITAL_OCEAN_REGION'] %>
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %>

- name: centos-6.5
- name: centos-6.6
driver_plugin: digital_ocean
driver_config:
size: 2gb
image: centos-6-5-x64
image: centos-6-6-x64
region: <%= ENV['DIGITAL_OCEAN_REGION'] %>
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %>
Expand Down Expand Up @@ -84,3 +84,10 @@ suites:
attributes:
machine_fqdn: chef.computers.biz
fqdn_as_hostname: true
- name: no-fqdn
run_list:
- recipe[test]
- recipe[chef-server::default]
attributes:
chef-server:
api_fqdn: ""
28 changes: 21 additions & 7 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
driver:
name: vagrant
customize:
memory: 1024
cpus: 2

provisioner:
name: chef_zero
require_chef_omnibus: latest

platforms:
- name: ubuntu-10.04
- name: ubuntu-10.10
- name: ubuntu-12.04
- name: ubuntu-12.10
- name: ubuntu-13.04
- name: ubuntu-13.10
- name: centos-6.5
- name: ubuntu-14.04
- name: centos-6.6
- name: centos-5.10
- name: centos-5.11

suites:
- name: default
run_list:
- recipe[test]
- recipe[chef-server]
attributes: {}
attributes:
chef-server:
api_fqdn: 'chef-server-tk.example.com'

- name: no-fqdn
run_list:
- recipe[test]
- recipe[chef-server]
driver:
network:
- ['private_network', {ip: '192.168.243.2'}]
attributes:
chef-server:
api_fqdn: ''
6 changes: 2 additions & 4 deletions Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ source 'https://supermarket.chef.io'

metadata

group :dev do
cookbook 'git'
cookbook 'apt'
cookbook 'fqdn'
group :integration do
cookbook 'test', :path => './test/fixtures/cookbooks/test'
end
241 changes: 44 additions & 197 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,251 +1,97 @@
Chef Server
===========
# chef-server

This cookbook configures a system to be a Chef Server. It will install
the appropriate platform-specific chef-server Omnibus package and
perform the initial configuration of Chef Server.
This cookbook configures a system to be a *standalone* Chef Server. It will install the appropriate platform-specific chef-server Omnibus package from Package Cloud and perform the initial configuration.

## Omnibus-based Chef-Server Overview
It is not in the scope of this cookbook to handle more complex Chef Server topologies like 'tiered' or 'ha'. Nor is it in the scope of this cookbook to install and configure premium features or other add-ons. For clustered Chef Server deployments, see [chef-server-cluster](https://github.com/opscode-cookbooks/chef-server-cluster). For primitives for installing `chef-server-core` or other Chef Server add-ons, see [chef-server-ingredient](https://supermarket.chef.io/cookbooks/chef-server-ingredient).

To understand how this cookbook works it is useful to understand how a
Chef Server instance installed via Omnibus packages behaves.
It is also not in the scope of this cookbook to handle older versions of Chef Server, such as 11 or 10. For Chef Server 11, see version 2.1.x of this cookbook on Supermarket, or the `chef11` branch of this repository.

### Know an Omnibus
# Requirements

Omnibus allows you to build self-contained full-stack software
packages. We use Omnibus to to distribute the Chef Server bundled with
its dependencies such as Erlang, Ruby, PostgreSQL, RabbitMQ, and
Nginx. The result is a single package that can be installed on the
target system and configured.
This cookbook is tested with Chef (client) 12. It may work with or without modification on earlier versions of Chef, but Chef 12 is recommended.

Omnibus packages separate the installation step from the configuration
step. After an Omnibus package is installed, a configuration step must
be run before the installed system can be used. In particular, this
approach makes handling upgrades easier.
## Cookbooks

### Configuring Chef Server

Chef Server is configured through the
`/etc/chef-server/chef-server.rb` file. Standalone single-server
configurations do not require custom configuration and can use the
default values for everything.

You can read all about Chef Server's
[configuration options](http://docs.chef.io/config_rb_chef_server.html).

### Applying configuration changes

The `chef-server-ctl reconfigure` command reads the
`/etc/chef-server/chef-server.rb` file and applies the specified
configuration to the system. Any time you make a change to your
configuration, you need to run `chef-server-ctl reconfigure` to apply
it.

### chef-server-ctl

Omnibus-based Chef Server installs have a command line utility,
`chef-server-ctl`, which is used to operate the Chef Server. For
example, you can use `chef-server-ctl` to start and stop individual
services, reconfigure the entire server, and tail server log files.

`chef-server-ctl` commands are documented below:

$ chef-server-ctl COMMAND

command | Action
-----------|---------
help | Print a list of all the available chef-server-ctl commands.
status | Shows the status of the Chef Server services.
start | Start all the enabled Chef Server services.
stop | Stop all the enabled Chef Server services.
restart | Restart all the enabled chef server services.
tail | Follow the Chef Server logs for all services.
test | Executes, chef-pedant, the integration test suite against the Chef Server installation. By default only a subset of tests are run, add the `--all` flag to run the full test suite.

The status, start, stop, restart, and tail commands can optionally be
applied to a single service by adding the service name to the end of
the command line. For example, to get the status of the erchef
component of Chef Server, you can run:

chef-server-ctl status erchef


REQUIREMENTS
============

Chef 10
* chef-server-ingredient cookbook

Platform
--------
## Platform

Chef Server Omnibus packages are available for the following platforms:
This cookbook is tested on the following platforms using the [Test Kitchen](http://kitchen.ci) `.kitchen.yml` in the repository.

* CentOS 5 64-bit
* CentOS 6 64-bit
* RHEL/CentOS 5 64-bit
* RHEL/CentOS 6 64-bit
* Ubuntu 10.04, 10.10 64-bit
* Ubuntu 11.04, 11.10 64-bit
* Ubuntu 12.04, 12.10 64-bit

ATTRIBUTES
==========
Unlisted platforms in the same family, of similar or equivalent versions may work with or without modification to this cookbook. For a list of supported platforms for Chef Server, see the [Chef documentation](https://docs.chef.io/supported_platforms.html#chef-server-title).

# Attributes

The attributes used by this cookbook are under the `chef-server` name space.

Attribute | Description |Type | Default
-----------------|-------------|-----|--------
api_fqdn | Fully qualified domain name that you want to use for accessing the Web UI and API. | String | node['fqdn']
api_fqdn | Fully qualified domain name that you want to use for accessing the Web UI and API. If set to `nil` or empty string (`""`), the IP address will be used as hostname. | String | node['fqdn']
configuration | Configuration values to pass down to the underlying server config file (i.e. `/etc/chef-server/chef-server.rb`). | Hash | Hash.new
package_file | Location of the Omnibus package to install. This should not be set if you wish to pull the packages from the Omnitruck S3 bucket. | String | nil
package_checksum | SHA256 checksum of package referenced by `package_file`. | String | nil
version | Chef Server version to install. This value is ignored if `package_file` is set. | String | :latest
prereleases | Indicates prerelease builds should be downloaded from Omnitruck. Prerelease builds come out in the weeks leading up to a major release. Prereleases offer an early preview of the next upcoming stable release and are intended for testers and advanced users. This value is ignored if `package_file` is set. | Boolean | false
nightlies | Indicates nightly builds should be downloaded from Omnitruck. Nightly builds of chef-server usually come out every night, but may be less frequent if there are no changes to the code, or the CI infrastructure is unable to create a build that day. The nightly builds are intended for testing only. This value is ignored if `package_file` is set. | Boolean | false
version | Chef Server version to install. If `nil`, the latest version is installed | String | nil

Previous versions of this cookbook had several other attributes used to control the version of the Chef Server package to install. This is deprecated.

RECIPES
========
# Recipes

This section describes the recipes in the cookbook and how to use them
in your environment.
This section describes the recipes in the cookbook and how to use them in your environment.

default
-------
## default

This recipe:

* Installs the appropriate platform-specific chef-server Omnibus package.
* Installs the appropriate platform-specific chef-server Omnibus package from our Package Cloud [repository](https://packagecloud.io/chef/stable)
* Creates the initial `/etc/chef-server/chef-server.rb` file.
* Performs initial system configuration via `chef-server-ctl reconfigure`.
* Updates the `/etc/hosts` file with the `api_fqdn` if that FQDN cannot be resolved.

Omnibus package selection is done based on the following logic:

1. If a value has been provided, the chef-server Omnibus package is
fetched from `node['chef-server']['package_file']`
2. If `node['chef-server']['package_file']` is unset (ie nil or empty
string), the candidate package is retrieved from the Omnitruck REST
API based on `node['chef-server']['version']` AND the node
platform, platform_version and architecture. By default the latest package
is installed. If you would like to download pre-release or nightly builds
set appropriate attribute to `true`.

dev
---

This recipe converts a Chef Server installation into development mode
for easy hacking on the underlying server components. This recipe should
not be run on a production server.

This recipe will place checkouts for all of Chef Server's main
software components at `/opt/chef-server-dev/code`. These component
checkouts will also be symlinked into the underlying Chef Server
installation. Changes made to component code will be reflected in the
running Chef Server instance (most often only after a restart of the
given service).

INSTALL METHODS
===============
# Install Methods

## Bootstrap Chef (server) with Chef (solo)

The easiest way to get a Chef Server up and running is to install
chef-solo (via the chef-client Omnibus packages) and bootstrap the
system using this cookbook:
The easiest way to get a Chef Server up and running is to install chef-solo (via the chef-client Omnibus packages) and bootstrap the system using this cookbook:

# install chef-solo
curl -L https://www.chef.io/chef/install.sh | sudo bash
# create required bootstrap dirs/files
sudo mkdir -p /var/chef/cache /var/chef/cookbooks/chef-server
sudo mkdir -p /var/chef/cache /var/chef/cookbooks
# pull down this chef-server cookbook
sudo wget -qO- https://github.com/chef-cookbooks/chef-server/archive/master.tar.gz | tar xvzC /var/chef/cookbooks/chef-server --strip-components=1
wget -qO- https://supermarket.chef.io/cookbooks/chef-server/download | sudo tar xvzC /var/chef/cookbooks
# pull down dependency cookbooks
wget -qO- https://supermarket.chef.io/cookbooks/chef-server-ingredient/download | sudo tar xvzC /var/chef/cookbooks
wget -qO- https://supermarket.chef.io/cookbooks/packagecloud/download | sudo tar xvzC /var/chef/cookbooks
# GO GO GO!!!
sudo chef-solo -o 'recipe[chef-server::default]'

If you need more control over the final configuration of your Chef
Server instance you can create a JSON attributes file and set
underlying configuration via the
`node['chef-server']['configuration']` attribute. For example, you can
disable the webui with the following configuration:

echo '{
"chef-server": {
"configuration": {
"chef_server_webui": {
"enable": false
}
}
},
"run_list": [ "recipe[chef-server::default]" ]
}' > /tmp/no-webui.json

You would then pass this file to the initial chef-solo command:

chef-solo -j /tmp/no-webui.json

## Demo Chef Server with Vagrant and Berkshelf

We <3 the wonderful open-source tools
[Berkshelf](http://berkshelf.com/) and
[Vagrant](http://vagrantup.com/). You can take Chef Server for a spin
using the Berksfile and Vagrantfile that ship alongside this cookbook.
The only requirements for standing up a virtualized Chef Server are:

* VirtualBox - native packages exist for most platforms and can be downloaded
from the [VirtualBox downloads page](https://www.virtualbox.org/wiki/Downloads).
* Vagrant 1.3.2+ - native packages exist for most platforms and can be downloaded
from the [Vagrant downloads page](http://downloads.vagrantup.com/).

The [vagrant-berkshelf](https://github.com/RiotGames/vagrant-berkshelf) and
[vagrant-omnibus](https://github.com/schisamo/vagrant-omnibus) Vagrant plugins
are also required and can be installed easily with the following commands:

```shell
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
```

Once the pre-requisites are installed you can start the virtualized environment
with the following command:

```shell
$ vagrant up
```

Although things have only been tested with Vagrant's `virtualbox` provider
everything should work with other providers like `vmware_fusion` or `ec2`.
Be sure to download and untar the `chef-server-ingredient` and `packagecloud` cookbooks. They're dependencies of this cookbook.

You can easily SSH into the running VM using the `vagrant ssh` command.
The VM can easily be stopped and deleted with the `vagrant destroy`
command. Please see the official
[Vagrant documentation](http://vagrantup.com/v1/docs/commands.html) for a more
in depth explanation of available commands.
If you need more control over the final configuration of your Chef Server instance you can create a JSON attributes file and set underlying configuration via the `node['chef-server']['configuration']` attribute. See the [attributes/default.rb](attributes/default.rb)

The running Chef-Server components are accessible from the host machine
using the following URLs:
Then pass this file to the initial chef-solo command:

* Web UI: https://33.33.33.50/ (Note: Attempts to hit via straight http will be
redirected to the Vagrant guest's internal hostname)
* Version Manifest: https://33.33.33.50/version
* Chef Server API (routing requires `X-OPS-USERID` HTTP header being properly
set): https://33.33.33.50/
chef-solo -j /tmp/dna.json

*Note: It can be helpful to use the host workstation's /etc/hosts file to map
33.33.33.50 to chef-server-berkshelf.*
### Configuring Chef Server

## Contribute to and Hack on Chef Server (including Erchef)
You can read all about Chef Server's configuration options on the [Chef Documentation site](http://docs.chef.io/server/config_rb_server.html).

This cookbook ships with a recipe named `dev` that will take any Chef
Server instance and flip it into development mode. If you want to use
the Vagrant-based environment referenced above, edit the `chef.run_list`
value in the `Vagrantfile` to include an additional
`recipe[chef-server::dev]` run list item.
### Applying configuration changes

The `chef-server-ctl` command is the administrative interface to the Chef Server. It has its own [documentation](https://docs.chef.io/ctl_chef_server.html). Various administrative functions provided by `chef-server-ctl` are not in the scope of this cookbook. Special/customized needs should be managed in your own cookbook.

LICENSE AND AUTHORS
===================
# License and Authors

* Author: Seth Chisamore <schisamo@chef.io>
* Author: Joshua Timberman <joshua@chef.io>
* Copyright 2012-2015, Chef Software, Inc

Copyright 2012, Chef Software, Inc

```text
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand All @@ -256,3 +102,4 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
```
Loading

0 comments on commit 0f2d123

Please sign in to comment.