Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verbosity argument #2933

Merged
merged 1 commit into from
Oct 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ MOLECULE_DEPENDENCY_NAME Dependency type name, usually 'galaxy'
MOLECULE_DRIVER_NAME Name of the molecule scenario driver
MOLECULE_PROVISIONER_NAME Name of the provisioner tool (usually 'ansible')
MOLECULE_SCENARIO_NAME Name of the scenario
MOLECULE_VERBOSITY Determine Ansible verbosity level.
MOLECULE_VERIFIER_NAME Name of the verifier tool (usually 'ansible')
MOLECULE_VERIFIER_TEST_DIRECTORY ?
================================ ===========================================================
Expand Down
1 change: 1 addition & 0 deletions lib/molecule/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

LOG = logger.get_logger(__name__)
MOLECULE_DEBUG = boolean(os.environ.get("MOLECULE_DEBUG", "False"))
MOLECULE_VERBOSITY = int(os.environ.get("MOLECULE_VERBOSITY", 0))
MOLECULE_DIRECTORY = "molecule"
MOLECULE_FILE = "molecule.yml"
MOLECULE_KEEP_STRING = "MOLECULE_"
Expand Down
17 changes: 14 additions & 3 deletions lib/molecule/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
"""Molecule Shell Module."""

import os
import sys
from functools import lru_cache

Expand All @@ -31,7 +31,7 @@
from molecule import command
from molecule.api import drivers
from molecule.command.base import click_group_ex
from molecule.config import MOLECULE_DEBUG, ansible_version
from molecule.config import MOLECULE_DEBUG, MOLECULE_VERBOSITY, ansible_version
from molecule.util import lookup_config_file

click_completion.init()
Expand Down Expand Up @@ -62,6 +62,13 @@ def _version_string() -> str:
default=MOLECULE_DEBUG,
help="Enable or disable debug mode. Default is disabled.",
)
@click.option(
"-v",
"--verbose",
count=True,
default=MOLECULE_VERBOSITY,
help="Increase Ansible verbosity level. Default is 0.",
)
@click.option(
"--base-config",
"-c",
Expand All @@ -85,7 +92,7 @@ def _version_string() -> str:
prog_name="molecule", version=molecule.__version__, message=_version_string()
) # type: ignore
@click.pass_context
def main(ctx, debug, base_config, env_file): # pragma: no cover
def main(ctx, debug, verbose, base_config, env_file): # pragma: no cover
"""
Molecule aids in the development and testing of Ansible roles.

Expand All @@ -96,9 +103,13 @@ def main(ctx, debug, base_config, env_file): # pragma: no cover
ctx.obj = {}
ctx.obj["args"] = {}
ctx.obj["args"]["debug"] = debug
ctx.obj["args"]["verbose"] = verbose
ctx.obj["args"]["base_config"] = base_config
ctx.obj["args"]["env_file"] = env_file

if verbose:
os.environ["ANSIBLE_VERBOSITY"] = str(verbose)


# runtime environment checks to avoid delayed failures
if sys.version_info[0] > 2:
Expand Down