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

Update installation guidance and silence typechecking #62

Merged
merged 2 commits into from
Feb 15, 2024
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
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,17 @@ Boardwalk.

### Installation

We recommend installing `boardwalk` in a [`pipx`](https://pipx.pypa.io/stable/)
environment, to ensure that your system or user pip packages are not affected by
Boardwalk's dependencies. Refer to `pipx`'s documentation for how to install it,
and then execute the following commands:
```sh
python3 -m pip install git+ssh://[email protected]/Backblaze/boardwalk.git
# Optionally appending @<git reference> allows for installing specific commits,
# Boardwalk depends on `ansible` in order to run.
pipx install ansible>=6.5.0
# Inject Boardwalk into the environment so it can use Ansible. Optionally,
# appending an @<git reference> allows for installing specific commits,
# branches, or tags.
pipx inject ansible git+ssh://[email protected]/Backblaze/boardwalk.git
```

__Note__:
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ansible >=6.5.0
ansible-runner >=2.3.0
click >=8.1.3
cryptography >=38.0.3
Expand Down
1 change: 1 addition & 0 deletions src/boardwalk/ansible.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This file has utilities for working with Ansible
"""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions src/boardwalk/app_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Common application exception classes
"""

import logging
import typing

Expand Down
1 change: 1 addition & 0 deletions src/boardwalk/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This is the main file for handling the CLI
"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions src/boardwalk/cli_catch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
catch and release CLI subcommands
"""

import logging

import click
Expand Down
1 change: 1 addition & 0 deletions src/boardwalk/cli_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
init CLI subcommand
"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions src/boardwalk/cli_login.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
login CLI subcommand
"""

import asyncio

import click
Expand Down
1 change: 1 addition & 0 deletions src/boardwalk/cli_run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
run and check CLI subcommands
"""

from __future__ import annotations

import concurrent.futures
Expand Down
1 change: 1 addition & 0 deletions src/boardwalk/cli_workspace.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
workspace CLI subcommand group
"""

import logging

import click
Expand Down
9 changes: 7 additions & 2 deletions src/boardwalk/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This file contains everything about what host data is stored and what can be
done to hosts
"""

from __future__ import annotations

import getpass
Expand Down Expand Up @@ -29,8 +30,12 @@ class Host(BaseModel, extra=Extra.forbid):
name: str
meta: dict[str, str | int | bool] = {}
remote_mutex_path: str = "/opt/boardwalk.mutex"
remote_alert_msg: str = "ALERT: Boardwalk is running a workflow against this host. Services may be interrupted"
remote_alert_string_formatted: str = f"$(tput -T xterm bold)$(tput -T xterm setaf 1)'{remote_alert_msg}'$(tput -T xterm sgr0)"
remote_alert_msg: str = (
"ALERT: Boardwalk is running a workflow against this host. Services may be interrupted"
)
remote_alert_string_formatted: str = (
f"$(tput -T xterm bold)$(tput -T xterm setaf 1)'{remote_alert_msg}'$(tput -T xterm sgr0)"
)
remote_alert_motd: str = f"#!/bin/sh\necho {remote_alert_string_formatted}"
remote_alert_motd_path: str = "/etc/update-motd.d/99-boardwalk-alert"
remote_alert_wall_cmd: str = f"wall {remote_alert_string_formatted}"
Expand Down
3 changes: 2 additions & 1 deletion src/boardwalk/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This file has all of the classes and functions that are used in a
Boardwalkfile.py
"""

from __future__ import annotations

import os
Expand Down Expand Up @@ -136,7 +137,7 @@ def _required_options(self) -> tuple[str]:
req_options = self.required_options()
if isinstance(self.required_options(), str):
req_options: tuple[str] = (
req_options, # pyright: ignore [reportGeneralTypeIssues]
req_options, # pyright: ignore [reportGeneralTypeIssues, reportAssignmentType]
)
return req_options

Expand Down
1 change: 1 addition & 0 deletions src/boardwalk/state.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This file holds the state model
"""

from pydantic import BaseModel, Extra

from boardwalk.host import Host
Expand Down
1 change: 1 addition & 0 deletions src/boardwalkd/broadcast.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Code for handling server broadcasts
"""

import json
import logging

Expand Down
1 change: 1 addition & 0 deletions src/boardwalkd/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This file contains the boardwalkd CLI code
"""

import asyncio
import logging
import re
Expand Down
1 change: 1 addition & 0 deletions src/boardwalkd/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This file defines objects that are passed between worker clients and the server,
and contains functions to support clients using the server
"""

import asyncio
import concurrent.futures
import json
Expand Down
1 change: 1 addition & 0 deletions src/boardwalkd/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This file contains the main HTTP server code
"""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions src/boardwalkd/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This file defines models and helpers to support data that's persisted to a local
state and survives service restarts
"""

from collections import deque
from datetime import datetime
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions typings/ansible_runner/config/doc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class DocConfig(BaseConfig):
ansible-doc -t role -l -j <collection_name>
"""
...

def prepare_role_argspec_command(
self, role_name, collection_name, playbook_dir
): # -> None:
Expand Down
5 changes: 5 additions & 0 deletions typings/ansible_runner/config/runner.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,20 @@ class RunnerConfig(BaseConfig):
and setting early ANSIBLE_ environment variables.
"""
...

def prepare_inventory(self): # -> None:
"""
Prepares the inventory default under ``private_data_dir`` if it's not overridden by the constructor.
"""
...

def prepare_env(self): # -> None:
"""
Manages reading environment metadata files under ``private_data_dir`` and merging/updating
with existing values so the :py:class:`ansible_runner.runner.Runner` object can read and use them easily
"""
...

def prepare_command(self): ...
def generate_ansible_command(self): # -> list[Unknown | str]:
"""
Expand All @@ -91,11 +94,13 @@ class RunnerConfig(BaseConfig):
:py:class:`ansible_runner.runner.Runner` object to start the process
"""
...

def build_process_isolation_temp_dir(self): # -> str:
"""
Create a temporary directory for process isolation to use.
"""
...

def wrap_args_for_sandbox(self, args): # -> list[Unknown | str | Any]:
"""
Wrap existing command line with bwrap to restrict access to:
Expand Down
1 change: 1 addition & 0 deletions typings/ansible_runner/interface.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This type stub file was generated by pyright and manually modified
"""

import typing

from runner import Runner
Expand Down
3 changes: 3 additions & 0 deletions typings/ansible_runner/loader.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ArtifactLoader:
ConfigurationError: If the file cannot be loaded
"""
...

def abspath(self, path): # -> str:
"""
Transform the path to an absolute path
Expand All @@ -43,6 +44,7 @@ class ArtifactLoader:
string: The absolute path to the file
"""
...

def isfile(self, path): # -> bool:
"""
Check if the path is a file
Expand All @@ -53,6 +55,7 @@ class ArtifactLoader:
:returns: boolean
"""
...

def load_file(
self, path, objtype=..., encoding=...
): # -> Any | bytes | str | None:
Expand Down
12 changes: 12 additions & 0 deletions typings/ansible_runner/runner.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This type stub file was generated by pyright and then manually improved
"""

from typing import Any, Iterable, TypedDict

logger = ...
Expand Down Expand Up @@ -39,31 +40,36 @@ class Runner:
status_handler=...,
) -> None:
self.rc: int | None = None

def event_callback(self, event_data):
"""
Invoked for every Ansible event to collect stdout with the event data and store it for
later use
"""
...

def status_callback(self, status): ...
def run(self): # -> tuple[str | Unknown, int | Unknown]:
"""
Launch the Ansible task configured in self.config (A RunnerConfig object), returns once the
invocation is complete
"""
...

@property
def stdout(self): # -> TextIOWrapper:
"""
Returns an open file handle to the stdout representing the Ansible run
"""
...

@property
def stderr(self): # -> TextIOWrapper:
"""
Returns an open file handle to the stderr representing the Ansible run
"""
...

@property
def events(self) -> Iterable[RunnerEvent]:
"""
Expand Down Expand Up @@ -107,6 +113,7 @@ class Runner:
}
"""
...

@property
def stats(self): # -> dict[str, Any] | None:
"""
Expand All @@ -116,16 +123,19 @@ class Runner:
{'dark': {}, 'failures': {}, 'skipped': {}, 'ok': {u'localhost': 2}, 'processed': {u'localhost': 1}}
"""
...

def host_events(self, host): # -> filter[Any]:
"""
Given a host name, this will return all task events executed on that host
"""
...

def kill_container(self): # -> None:
"""
Internal method to terminate a container being used for job isolation
"""
...

@classmethod
def handle_termination(cls, pid, pidfile=..., is_cancel=...): # -> None:
"""
Expand All @@ -137,11 +147,13 @@ class Runner:
instance's cancel_flag.
"""
...

def get_fact_cache(self, host): # -> Any | dict[Unknown, Unknown]:
"""
Get the entire fact cache only if the fact_cache_type is 'jsonfile'
"""
...

def set_fact_cache(self, host, data): # -> int:
"""
Set the entire fact cache data only if the fact_cache_type is 'jsonfile'
Expand Down
Loading
Loading