Skip to content
Browse files

Add Whyrun option

  • Loading branch information...
1 parent 608a9da commit 75f3e877252dbc37d8d355d86370cb308d2b40fe @tobami committed
Showing with 13 additions and 2 deletions.
  1. +7 −0 fix
  2. +1 −0 littlechef/__init__.py
  3. +5 −2 littlechef/chef.py
View
7 fix
@@ -51,6 +51,10 @@ parser.add_option(
help="Don't save the chef-solo output as a report on the node"
)
parser.add_option(
+ "--why-run", dest="whyrun", action="store_true", default=False,
+ help="Do a configuration Whyrun, where no changes are performed to the node"
+)
+parser.add_option(
"--verbose", dest="verbose", action="store_true", default=False,
help="Output 'processing' statements"
)
@@ -84,6 +88,9 @@ else:
if options.no_report:
littlechef.enable_logs = False
sys.argv.remove('--no-report')
+ if options.whyrun:
+ littlechef.whyrun = True
+ sys.argv.remove('--why-run')
if options.verbose:
littlechef.verbose = True
sys.argv.remove('--verbose')
View
1 littlechef/__init__.py
@@ -25,6 +25,7 @@
verbose = False
enable_logs = True
LOGFILE = '/var/log/chef/solo.log'
+whyrun = False
node_work_path = '/tmp/chef-solo'
cookbook_paths = ['site-cookbooks', 'cookbooks']
View
7 littlechef/chef.py
@@ -25,7 +25,7 @@
from fabric.utils import abort
from fabric.contrib.project import rsync_project
-from littlechef import cookbook_paths
+from littlechef import cookbook_paths, whyrun
from littlechef import lib
from littlechef import solo
from littlechef import LOGFILE, enable_logs as ENABLE_LOGS
@@ -336,7 +336,10 @@ def _configure_node():
with settings(hide('stdout', 'warnings', 'running'), warn_only=True):
sudo("mv {0} {0}.1".format(LOGFILE))
# Build chef-solo command
- cmd = 'chef-solo -l {0} -j /etc/chef/node.json'.format(env.loglevel)
+ cmd = "chef-solo "
+ if whyrun:
+ cmd += "--why-run "
+ cmd += '-l {0} -j /etc/chef/node.json'.format(env.loglevel)
if ENABLE_LOGS:
cmd += ' | tee {0}'.format(LOGFILE)
if env.loglevel == "debug":

0 comments on commit 75f3e87

Please sign in to comment.
Something went wrong with that request. Please try again.