Skip to content

Instantly share code, notes, and snippets.

@jayd3e
jayd3e / gist:3179315
Created July 25, 2012 23:23
Programception
def run_question_mark(program):
try:
program()
return True
except Exception:
return False
@jayd3e
jayd3e / gist:3191194
Created July 28, 2012 00:29
Chef Error
:/opt/clusterstack$ sudo /var/lib/gems/1.8/gems/chef-0.10.8/bin/chef-solo -j roles/clusterflunk_dev.json -c solo.rb
[2012-07-28T00:28:17+00:00] INFO: *** Chef 0.10.8 ***
[2012-07-28T00:28:17+00:00] INFO: Setting the run_list to ["role[web_server]", "role[smtp_server]", "recipe[clusterflunk]"] from JSON
[2012-07-28T00:28:17+00:00] ERROR: Role web_server is in the runlist but does not exist. Skipping expand.
[2012-07-28T00:28:17+00:00] ERROR: Role smtp_server is in the runlist but does not exist. Skipping expand.
[2012-07-28T00:28:17+00:00] FATAL: Stacktrace dumped to /opt/clusterstack/chef-stacktrace.out
[2012-07-28T00:28:17+00:00] FATAL: Chef::Exceptions::MissingRole: Chef::Exceptions::MissingRole
@jayd3e
jayd3e / gist:3191206
Created July 28, 2012 00:34
Clusterflunk Role
{
"name": "clusterflunk_dev",
"chef_type": "role",
"run_list": [
"role[web_server]",
"role[smtp_server]",
"recipe[clusterflunk]"
]
}
@jayd3e
jayd3e / gist:3191224
Created July 28, 2012 00:39
Chef Error #2
sudo /var/lib/gems/1.8/gems/chef-0.10.8/bin/chef-solo -j roles/clusterflunk_dev.json -c solo.rb
[2012-07-28T00:38:29+00:00] INFO: *** Chef 0.10.8 ***
[2012-07-28T00:38:30+00:00] INFO: Setting the run_list to ["role[web_server]", "role[smtp_server]", "recipe[clusterflunk]"] from JSON
[2012-07-28T00:38:30+00:00] FATAL: Stacktrace dumped to /opt/clusterstack/chef-stacktrace.out
[2012-07-28T00:38:30+00:00] FATAL: NoMethodError: undefined method `run_list_for' for #<Hash:0xb6b93028>
@jayd3e
jayd3e / gist:3191257
Created July 28, 2012 00:46
Stacktrace
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_list/run_list_expansion.rb:139:in `expand_run_list_items'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_list/run_list_expansion.rb:78:in `expand'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_list.rb:138:in `expand'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/node.rb:437:in `expand!'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:267:in `build_node'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:154:in `run'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:207:in `run_application'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in `loop'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in `run_application'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application.rb:70:in `run'
@jayd3e
jayd3e / gist:3191439
Created July 28, 2012 02:08
Override attributes
{
"name": "clusterflunk_prod",
"chef_type": "role",
"default_attributes": {
"clusterflunk": {
"user": "vagrant"
}
},
"run_list": [
"role[web_server]",
@jayd3e
jayd3e / gist:3194750
Created July 28, 2012 20:53
How to make a recommended item guide
# The recommended guide for earthshaker
op.bulk_insert(guides,
[
{'id': 1, 'name': 'Earthshaker - Recommended Items'}
])
# Connecting a item_build(group of items) to our guide above. This represents the 'early;
# item section
op.bulk_insert(item_builds,
[
./configure: line 2332: config.log: Permission denied
./configure: line 2342: config.log: Permission denied
vagrant@ubuntu-oneiric:/tmp/Python-2.7$ sudo ./configure --prefix=/opt/python-2.7.3
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux3
checking EXTRAPLATDIR...
checking machine type as reported by uname -m... x86_64
checking for --without-gcc... no
checking for gcc... gcc
@jayd3e
jayd3e / gist:3234660
Created August 2, 2012 07:03
Fabric error
[localhost] put: <file obj> -> /etc/nginx/sites-enabled/clusterflunk
Fatal error: sudo() received nonzero return code 1 while executing!
Requested: mv "aa8f798a2bd5000dbc79ec6b84c40b4569e757a7" "/etc/nginx/sites-enabled/clusterflunk"
Executed: sudo -S -p 'sudo password:' /bin/bash -l -c "mv \"aa8f798a2bd5000dbc79ec6b84c40b4569e757a7\" \"/etc/nginx/sites-enabled/clusterflunk\""
============================================================================================= Standard output =============================================================================================
mv: cannot stat `aa8f798a2bd5000dbc79ec6b84c40b4569e757a7': No such file or directory
@jayd3e
jayd3e / gist:3234664
Created August 2, 2012 07:04
Upload file with fabric
filename = '/etc/nginx/sites-enabled/clusterflunk'
if not exists(filename):
put('clusterstack/templates/clusterflunk', filename, use_sudo=True)