A Chef-Solo package to wrap workstation cookbook to manage your workstation.
-
Download the ChefDK.
-
Install it.
-
Check the install
chef-solo -v Chef: 13.6.4
This Chef-Solo package expect to find the attributes and solo.rb files in /opt/chef-solo
to be able to schedule the chef run periodically.
The init create a symlink from where you clone the repo to /opt/chef-solo
.
Edit attributes.json
file with you preferences. (refer to Workstation Setup Examples)
The run.sh
tool is here to help you with this chef-solo package.
./run.sh --help / -H
- Show help
./run.sh --init / -I
- Initialize the chef-solo package
./run.sh --vendor / -V
- Vendoring dependencies
Vendoring is the moving of all 3rd party items such as plugins, gems and even rails into the /vendor directory. This is one method for ensuring that all files are deployed to the production server the same as the dev environment. With Berkshelf, the vendoring folder is
berks-cookbooks
.
./run.sh --whyrun / -W
- Execute chef-solo un whyrun mode (nothing will be updated)
./run.sh --test / -T
- Execute the Inspec tests.
./run.sh
- Execute a whyrun as first step, then, if the whyrun would have updated one resource or more, exeute the chef-solo convergence and finally run the Inspec tests.
A solo.rb file is used to specify the configuration details for chef-solo.
- This file is loaded every time chef-solo is run
- The default location in which chef-solo expects to find this file is /etc/chef/solo.rb; use the --config option from the command line to change this location
- When a solo.rb file is present in this directory, the settings contained within that file will override the default configuration settings
chef-solo does not interact with the Chef server. Consequently, node-specific attributes must be located in a JSON file on the target system, a remote location (such as Amazon Simple Storage Service (S3)), or a web server on the local network.
The JSON file must also specify the recipes that are part of the run-list.
Use berks vendor to vendor groups of cookbooks (as specified by group name) into a directory.
Berkshelf is a dependency manager for Chef cookbooks. With it, you can easily depend on community cookbooks and have them safely included in your workflow. You can also ensure that your CI systems reproducibly select the same cookbook versions, and can upload and bundle cookbook dependencies without needing a locally maintained copy. Berkshelf is included in the Chef Development Kit.
Note
run.sh
tool include an auto vendoring if berks-cookbooks
fodler doesn't exist :
test_vendoring() {
if [ ! -d "./berks-cookbooks" ]
then
berks_vendor
fi
}
Usefull for the first usage of this chef-solo cookbook.
Unlike chef-client, where the node object is stored on the Chef server, chef-solo stores its node objects as JSON files on local disk. By default, chef-solo stores these files in a nodes folder in the same directory as your cookbooks directory. You can control the location of this directory via the node_path value in your configuration file.
Note
Be carefull with the removing of resource instances as they can not be removed fom the node object.
For example, if you decide to uninstall a system package, you will uninstall it then remove it from default['workstation']['packages']
:
before:
"workstation": {
"packages": [
"vim",
"git",
"meld"
after:
"workstation": {
"packages": [
"vim",
"git"
But, it's still inside normal['workstation']['packages']
:
{
"normal": {
"workstation": {
"packages": [
"vim",
"git",
"meld"
]
}
}
}
To ensure that the next chef-solo run will not re-install it, be sure to remove it from nodes/node.name
.json.
The proper approach is still to manage a package uninstallation in 3 steps :
-
Remove the package's reference from
attributes.json
. -
Uninstall the package from a
workstation
cookbook's recipe:package 'FOO' do action :remove end
-
Remove the package remove resource from the recipe.
This Chef-Solo package is intented to be used with workstation.
Edit attributes.json
to customize your setup.
['workstation']['users']
:
List of users to configure.
"users": [
{
"name": "username",
"home": "/home/username"
}
],
['workstation']['packages']
:
List of system packages to install.
"packages": [
"vim",
"git",
"meld",
"evolution",
"evolution-ews",
"chromium-browser",
"ruby-full",
"gcc",
"make"
]
['workstation']['gems']
:
List of gems to install.
"gems": [
"bundler",
"rake",
"inspec",
"ohai",
"chef",
"docker",
"test-kitchen",
"kitchen-docker",
"kitchen-ansible"
]
['workstation']['pip']
:
List of pip packages to install.
"pip": {
"ansible": "2.3.2.0",
"pyOpenSSL": "17.5.0"
}
['workstation']['hosts']
:
List of /etc/hosts
entries.
"hosts": [
{"127.0.1.1": "My_Super_Workstation.local.net"},
{"127.0.0.1": "consul"},
{"127.0.0.1": "nomad"},
]
['workstation']['ssh_config']
:
List of ssh configs.
"ssh_config": [
{
"name": "bastion",
"options": {
"HostName": "1.2.3.4",
"User": "remote_username",
"IdentityFile": "~/.ssh/ssh_key"
},
"user": "my_username"
}
]
Add sublime_text
cookbook's default recipe in your run_list :
"run_list": [
"recipe[workstation::default]",
"recipe[sublime_text::default]"
]
And override the sublime_text
attributes :
List the users for whom you want to configure Sublime Text:
"sublime_text": {
"users": [
"username"
],
List the PackageControl's packages you want :
"packages": [
{
"name": "Jinja2",
"url": "https://github.com/kudago/jinja2-tmbundle/archive/master.zip"
},
{
"name": "SummitLinter",
"url": "https://github.com/corvisa/SummitLinter/archive/master.zip"
},
{
"name": "Pylinter",
"url": "https://github.com/biermeester/Pylinter/archive/master.zip"
},
{
"name": "SublimeLinter-contrib-ansible-lint",
"url": "https://github.com/mliljedahl/SublimeLinter-contrib-ansible-lint/archive/master.zip"
},
{
"name": "SublimeLinter-pylint",
"url": "https://github.com/SublimeLinter/SublimeLinter-pylint/archive/master.zip"
},
{
"name": "Terraform",
"url": "https://github.com/alexlouden/Terraform.tmLanguage/archive/master.zip"
}
],
And finally, set the syntax specific configs you want :
"syntax_specific": {
"Python": {
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"Ruby": {
"tab_size": 2,
"translate_tabs_to_spaces": true
},
"Ruby Haml": {
"tab_size": 2,
"translate_tabs_to_spaces": true
}
}
}
Add atom
cookbook's platform recipe in your run_list :
"run_list": [
"recipe[workstation::default]",
"recipe[atom::debian]"
]
"run_list": [
"recipe[workstation::default]",
"recipe[atom::macos]"
]
"run_list": [
"recipe[workstation::default]",
"recipe[atom::windows]"
]