loading table of contents...
4.2.2.1.1. Using Chef-Solo

If you start with Chef and simply want to set up a system on a single machine, you should use the chef-solo client utility as it doesn't require a Chef Server or an account for Hosted Chef.

Prerequisites

Before you can start deploying the components with chef-solo, you need to fulfill the following requirements:

  • Install chef-solo.

  • Provide the RPM artifacts either from a local directory or from a remote YUM repository.

Additionally, there are some optional requirements, mostly used to set up a development or test system:
  • Provide a Zip archive of a content export, either as a local file or from a remote accessible URL.

Installing Chef Client

To install Chef Client (including chef-solo) execute the following command:

sudo true && curl -L https://www.chef.io/chef/install.sh | sudo bash
Configuring the solo.rb file

The file to configure the chef-solo client is solo.rb, it contains the paths' to the cookbooks and the roles and the logging configuration of Chef. You have to create this file. A simple solo.rb file should look like the example below.

# CHEF ENVIRONMENT CONFIGURATION
log_level       :info
log_location    "/var/log/chef/chef-solo.log"
cookbook_path   "PATH_TO_YOUR_CHEF_REPO/cookbooks"
role_path       "PATH_TO_YOUR_CHEF_REPO/roles"
        

Example 4.14. An example solo.rb file


Install Berkshelf and vendor the cookbooks. To do so,

        cd boxes/chef/chef-repo
        berks vendor
      

Afterwards the new generated berks-cookbooks directory must be added to the cookbooks path of the solo.rb.

Configuring the node.json file

The node.json file contains all the configurations you want to apply with the chef-solo run. This includes the attributes you want to set but also the roles and recipes you want to apply. The example below configures a complete CoreMedia 7 run.

{
  "fqdn":"YOUR_ALIAS",
  "mysql":{
    "allow_remote_root":true,
    "bind_address":"0.0.0.0",
    "use_upstart":false,
    "server_repl_password":"coremedia",
    "server_debian_password":"coremedia",
    "server_root_password":"coremedia",
    "tunable":{
      "wait_timeout":"7200"
    },
    "client": {
      "packages": ["mysql-community-client", "mysql-community-devel"]
    },
    "server": {
      "packages": ["mysql-community-server"]
    }
  },
  "coremedia":{
    "db":{
      "schemas":["cm7management",
                 "cm7master",
                 "cm7replication",
                 "cm7caefeeder",
                 "cm7mcaefeeder"]
    },
    "yum":{
      "local": {
        "path": "YOUR_LOCAL_RPM_REPO",
        "archive": "YOUR_RPM_REPO_ARCHIVE_URL"
      }
    },
    "content_archive": "YOUR_CONTENT_ARCHIVE"
    },
    "configuration":{
      "configure.STUDIO_TLD":"YOUR_ALIAS",
      "configure.DELIVERY_TLD":"YOUR_ALIAS",
      "configure.CROWD_APP_NAME":"YOUR_CROWD_APP_NAME",
      "configure.CROWD_PASSWORD":"YOUR_CROWD_PASSWORD",
      "configure.CROWD_SERVER":"YOUR_CROWD_SERVER:8443",
      "configure.ELASTIC_MAIL_HOST":"YOUR_MAIL_SERVER",
      "configure.DELIVERY_REPOSITORY_HTTP_PORT":"42080",
      "configure.DELIVERY_SOLR_PORT":"44080"
    },
    "logging":{
      "default":{
        "com.coremedia":{"level":"info"},
        "cap.server":{"level":"info"},
        "hox.corem.server":{"level":"info"},
        "workflow.server":{"level":"info"}
      }
    },
    "tomcat":{
      "manager":{
        "credentials":{
          "admin":{
            "username":"admin",
            "password" : "tomcat",
            "roles"    : "manager-gui"
          },
          "script": {
            "username" :"script",
            "password" : "tomcat",
            "roles"    : "manager-jmx,manager-script"
          }
        }
      }
    }
  },
  "run_list":[
  "recipe[blueprint-yum::default]",
  "recipe[coremedia::chef_logging]",
  "recipe[coremedia::reporting]",
  "recipe[mysql::server]",
  "recipe[coremedia::db_schemas]",
  "recipe[mongodb::default]",
  "recipe[coremedia::solr_master]",
  "recipe[coremedia::master_live_server]",
  "recipe[coremedia::content_management_server]",
  "recipe[coremedia::workflow_server]",
  "recipe[coremedia::caefeeder_preview]",
  "recipe[coremedia::caefeeder_live]",
  "recipe[coremedia::studio]",
  "recipe[coremedia::studio_apache]",
  "recipe[coremedia::certificate_generator]",
  "recipe[coremedia::delivery]",
  "recipe[coremedia::delivery_apache]"
  ]
}
        

Example 4.15. An example node.json file


Before you can execute chef-solo with this configuration, you need to replace all uppercase values starting with YOUR_. The following table lists the most important ones:

TokenReplacement

YOUR_ALIAS

If your machine has an alias and you want the system to use it instead of the resolved hostname, you can set it here.

YOUR_LOCAL_RPM_REPO

The path of the local directory containing the RPM artifacts. If you want to use this option, remove the attribute coremedia['yum']['local']['archive'].

YOUR_LOCAL_RPM_REPO_ARCHIVE_URL

The URL to a remote archive of the RPM artifacts. If you want to use this option, you can remove the attribute coremedia['yum']['local']['path] and Chef will use the default for this value (/shared/rpm-repo).

YOUR_LOCAL_CONTENT_ARCHIVE

An array of paths to local Zip archives containing content, typically an archive with global content and some content archives of extensions which you have activated.

Table 4.2. node.js configurations


Now, you can simply start chef-solo by executing:

chef-solo -c solo.rb -j node.json

Configuring a Jenkins Setup

As described above, RPM repository and example content can be specified with and retrieved from a remote HTTP URL. For a quick retest system with Jenkins, you can use the REST API of Jenkins to retrieve those archives via the lastSuccessfulBuild URLs. All you need to do is activate archiving for the boxes/target/shared/rpm-repo/ folder and if you have a corresponding content job, you can apply this pattern there too.

For the chef-repo, you can choose between using the archived artifacts or directly reference the jobs workspace using the *zip* controller of Jenkins. The Jenkins job then only needs execute a script, that downloads and extract the chef-repo archive and configure the paths in the solo.rb correctly.

The script itself can be committed together with the node.json in the VCS that the Jenkins job checks out.

The following list shows example URLs using lastSuccessFul artifact URLs for RPM repository and content and a direct workspace URL for the chef-repo:

  • http://MY_JENKINS/job/MY_CM7_JOB/lastSuccessfulBuild/artifact/boxes/target/shared/rpm-repo/*zip*/rpm-repo.zip

  • http://MY_JENKINS/job/MY_CM7_CONTENT_JOB/lastSuccessfulBuild/artifact/target/content-users.zip

  • http://MY_JENKINS/job/MY_CM7_JOB/ws/boxes/chef/chef-repo/*zip*/chef-repo.zip