Skip to content

Commit

Permalink
Add offline mode for skipping requirements installation (#1319)
Browse files Browse the repository at this point in the history
Fixes: #930
  • Loading branch information
ssbarnea committed Feb 8, 2021
1 parent 87a9b87 commit f574c93
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .ansible-lint
Expand Up @@ -34,3 +34,6 @@ warn_list:
- skip_this_tag
- git-latest
- experimetal # experimental is included in the implicit list

# offline mode disables installation of requirements.yml
offline: false
4 changes: 2 additions & 2 deletions src/ansiblelint/_prerun.py
Expand Up @@ -40,8 +40,8 @@ def check_ansible_presence() -> None:


def prepare_environment() -> None:
"""Make custom modules available if needed."""
if os.path.exists("requirements.yml"):
"""Make dependencies available if needed."""
if not options.offline and os.path.exists("requirements.yml"):

cmd = [
"ansible-galaxy",
Expand Down
8 changes: 8 additions & 0 deletions src/ansiblelint/cli.py
Expand Up @@ -247,6 +247,13 @@ def get_cli_parser() -> argparse.ArgumentParser:
dest='config_file',
help='Specify configuration file to use. ' 'Defaults to ".ansible-lint"',
)
parser.add_argument(
'--offline',
dest='offline',
action='store_const',
const=True,
help='Disable installation of requirements.yml',
)
parser.add_argument(
'--version',
action='store_true',
Expand All @@ -269,6 +276,7 @@ def merge_config(file_config, cli_config: Namespace) -> Namespace:
'quiet',
'use_default_rules',
'progressive',
'offline',
)
# maps lists to their default config values
lists_map = {
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/config.py
Expand Up @@ -49,6 +49,7 @@
mock_modules=[],
mock_roles=[],
loop_var_prefix=None,
offline=False,
)

# Used to store detected tag deprecations
Expand Down

0 comments on commit f574c93

Please sign in to comment.