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 offline mode for skipping requirements installation #1319

Merged
merged 1 commit into from Feb 8, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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