Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update chef prototype

  • Loading branch information...
commit 8c29fa35f083cc225057e15089996189773fdb57 1 parent adb7c17
@labisso labisso authored
Showing with 50 additions and 12 deletions.
  1. +48 −10 epu/provisioner/core.py
  2. +2 −2 epu/test/test_chef_proto.py
View
58 epu/provisioner/core.py
@@ -11,6 +11,7 @@
import logging
from itertools import izip
from socket import timeout
+import string
import yaml
from libcloud.compute.types import NodeState as LibcloudNodeState
@@ -1252,18 +1253,55 @@ def add_state_change(node, state):
node['state_changes'].append(state_change)
+_CHEF_INSTALL_SH_TMPL = """#!/bin/bash
+
+mkdir -p /etc/chef /var/log/chef
+
+cat >/etc/chef/validation.pem <<END
+${validation_key}
+END
+
+cat > /etc/chef/client.rb <<END
+log_level :info
+log_location "/var/log/chef/client.log"
+ssl_verify_mode :verify_none
+validation_client_name "chef-validator"
+validation_key "/etc/chef/validation.pem"
+client_key "/etc/chef/client.pem"
+chef_server_url "${server_url}"
+environment "_default"
+node_name "${node_name}"
+file_cache_path "/var/cache/chef"
+file_backup_path "/var/backups/chef"
+pid_file "/var/run/chef/client.pid"
+Chef::Log::Formatter.show_time = true
+END
+
+true && curl -L https://www.opscode.com/chef/install.sh | bash
+chef-client -d
+"""
+
+
def _make_chef_cloudinit_userdata(node_id):
- block = {
- "chef": {
- "install_type": "packages",
- "node_name": node_id,
- "validation_name": "chef-validator",
- "validation_key": CHEF_VALIDATION_KEY,
- "server_url": chef_api.url
- }
- }
- return "#cloud-config\n" + yaml.dump(block)
+ vals = dict(validation_key=CHEF_VALIDATION_KEY, server_url=chef_api.url,
+ node_name=node_id)
+
+ tmpl = string.Template(_CHEF_INSTALL_SH_TMPL)
+ return tmpl.safe_substitute(vals)
+
+ # block = {
+ # "chef": {
+ # # "install_type": "packages",
+ # "install_type": "omnibus",
+ # "omnibus_url": "https://www.opscode.com/chef/install.sh",
+ # "node_name": node_id,
+ # "validation_name": "chef-validator",
+ # "validation_key": CHEF_VALIDATION_KEY,
+ # "server_url": chef_api.url
+ # }
+ # }
+ # return "#cloud-config\n" + yaml.dump(block)
class ProvisionerContextClient(object):
View
4 epu/test/test_chef_proto.py
@@ -49,14 +49,14 @@
example_dt = {
'mappings': {
site['name']: {
- 'iaas_image': 'ami-7539b41c', # ubuntu
+ 'iaas_image': 'ami-c30360aa', # ubuntu
# 'iaas_image': 'ami-54cf5c3d', # amazon linux
'iaas_allocation': 't1.micro',
}
},
'contextualization': {
'method': 'chef',
- 'run_list': ["recipe[apache2]", "recipe[chef-client::config]"],
+ 'run_list': ["recipe[phantom_handlers]", "recipe[apache2]"],
'attributes': {}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.