bootstrap-vz/plugins/chef/tasks.py
2014-04-01 01:19:40 +00:00

40 lines
1 KiB
Python

from base import Task
from common import phases
from common.tasks import apt
import os
class CheckAssetsPath(Task):
description = 'Checking whether the assets path exist'
phase = phases.preparation
@classmethod
def run(cls, info):
from common.exceptions import TaskError
assets = info.manifest.plugins['chef']['assets']
if not os.path.exists(assets):
msg = 'The assets directory {assets} does not exist.'.format(assets=assets)
raise TaskError(msg)
if not os.path.isdir(assets):
msg = 'The assets path {assets} does not point to a directory.'.format(assets=assets)
raise TaskError(msg)
class AddPackages(Task):
description = 'Add chef package'
phase = phases.preparation
predecessors = [apt.AddDefaultSources]
@classmethod
def run(cls, info):
info.packages.add('chef')
class CopyChefAssets(Task):
description = 'Copying chef assets'
phase = phases.system_modification
@classmethod
def run(cls, info):
from common.tools import copy_tree
copy_tree(info.manifest.plugins['chef']['assets'], os.path.join(info.root, 'etc/chef'))