diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 02eedd2..66da964 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -34,14 +34,15 @@ "installTools": true, "version": "3.11" }, - "ghcr.io/warrenbuckley/codespace-features/sqlite:1": {} + "ghcr.io/warrenbuckley/codespace-features/sqlite:1": {}, + "ghcr.io/hspaans/devcontainer-features/pytest:1": {} }, // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], "forwardPorts": [ 8000 - ] + ], // Uncomment the next line if you want start specific services in your Docker Compose config. // "runServices": [], @@ -50,7 +51,7 @@ // "shutdownAction": "none", // Uncomment the next line to run commands after the container is created. - // "postCreateCommand": "cat /etc/os-release", + "postCreateCommand": "cat /etc/os-release" // Configure tool-specific properties. // "customizations": {}, diff --git a/.vscode/settings.json b/.vscode/settings.json index 534d4ca..b3fa722 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,8 @@ { - "editor.fontFamily": "'MesloLGS NF', 'Droid Sans Mono', 'monospace', monospace" + "editor.fontFamily": "'MesloLGS NF', 'Droid Sans Mono', 'monospace', monospace", + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 509f1f2..19780d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,21 +23,28 @@ RUN apt-get -yq install --no-install-recommends \ tcpdump traceroute iproute2 dnsutils whois mtr iftop iputils-ping wget nmap netcat-traditional \ procps \ htop \ - # Clean up - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* + screen tmux \ + unzip zip \ + jq \ + build-essential \ + software-properties-common \ + tree \ + lsof \ + fish \ + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* # ensure that there is a place to mount the host files RUN mkdir /host -# Set tthe working directory for installations and login +# Set the working directory for installations and login WORKDIR /app # Copy in any/all additional files from our project ADD src/requirements.txt . -# Istall Python basic libraries +# Install Python basic libraries RUN python3 -m pip install --no-cache-dir -r requirements.txt # Setup a user to match the host and reduce the frustration/confusion of file ownership @@ -59,7 +66,7 @@ RUN echo $GIT_VERSION_HASH > GIT_VERSION_HASH.txt USER $USERNAME # Install ZSH, OhMyZSH, themes and plugins -ADD --chown=1000:1000 --chmod=+x src/zsh-in-docker.sh . +COPY --chown=1000:1000 --chmod='0755' src/zsh-in-docker.sh . RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" RUN ./zsh-in-docker.sh \ -p git \ @@ -85,11 +92,11 @@ ADD --chown=1000:1000 src/.p10k.zsh /home/$USERNAME/.p10k.zsh ADD --chown=1000:1000 src/.zshrc /home/$USERNAME/.zshrc ADD --chown=1000:1000 src/.p10k.zsh /home/$USERNAME/.p10k.zsh -ADD --chown=1000:1000 --chmod=+x src/tasks.py . -ADD --chown=1000:1000 --chmod=+x https://private-sw-downloads.s3.amazonaws.com/archfx_broker/preflight/broker_preflight.sh . +ADD --chown=1000:1000 --chmod='0755' src/tasks.py . +ADD --chown=1000:1000 --chmod='0755' https://private-sw-downloads.s3.amazonaws.com/archfx_broker/preflight/broker_preflight.sh . -ADD --chown=1000:1000 --chmod=+x src/test_net.sh . +ADD --chown=1000:1000 --chmod='0755' src/test_net.sh . ADD --chown=1000:1000 src/nodes.list . # Set default command -CMD ["/bin/zsh"] \ No newline at end of file +CMD ["/bin/zsh"] diff --git a/README.md b/README.md index 6a9ac2b..80967a9 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,16 @@ By: Garth Johnson & others The purpose of this container image is to provide tools that can help diagnose issues and ease/simplify development struggles on alien envirnments. -Additionally, this container image can easily used for: +Additionally, this container image can be easily used for: -- devlopment new container prototypes -- debugging container builds and deployments -- educational intents for container development/examples (i.e. workflows and devcontainers) - -You can find more at: +- Development of new container prototypes +- Debugging container builds and deployments +- Educational intents for container development/examples (i.e., workflows and devcontainers) +- Network diagnostics and packet analysis +- Running automated tests in isolated environments +- Benchmarking container performance +- Rapid prototyping of infrastructure setups +- You can find more at: - source: https://github.com/growlf/toolbox/ - release images: @@ -29,7 +32,7 @@ You can find more at: ## Batteries included -### Custom Shell +### Custom Shell Using the `docker-compose.yml` file (included) makes certain tasks easier. For example, opening a self-removing ZShell instance can be done lke so: @@ -41,13 +44,13 @@ Using `tcpdump` can either be done from within a shell of the toolbox container, docker run --rm -it --net=host ghcr.io/growlf/toolbox sudo tcpdump -### Running scripts and commands +### Running scripts and commands You can also run arbitrary commands and scripts directly from the commandline like so: docker compose run --rm -it app1 ./test_net.sh -## Invoke +## Using the Invoke Command This image implements [Python Invoke](https://www.pyinvoke.org/), for managing shell-oriented subprocesses and organizing executable Python code into CLI-invokable tasks. There are a few basic tasks defined as examples already. @@ -86,3 +89,4 @@ Use the `portainer-compose.yml` file and modify to your hearts content. - https://pypi.org/project/portscan/ - https://docs.pyinvoke.org/en/stable/ - https://docker-py.readthedocs.io/en/stable/ + diff --git a/ansible/inventory.yml b/ansible/inventory.yml new file mode 100644 index 0000000..d0efe4b --- /dev/null +++ b/ansible/inventory.yml @@ -0,0 +1,10 @@ +myhosts: + hosts: + localhost: + ansible_host: localhost + server1: + ansible_host: server1 + server2: + ansible_host: server2 + server3: + ansible_host: nexus diff --git a/docker-compose.yml b/compose.yml similarity index 98% rename from docker-compose.yml rename to compose.yml index 306c73e..4066f41 100644 --- a/docker-compose.yml +++ b/compose.yml @@ -1,4 +1,3 @@ -version: '3.8' services: # Building and testing environment diff --git a/portainer-compose.yml b/portainer-compose.yml index 0e3dbfc..e40ed87 100644 --- a/portainer-compose.yml +++ b/portainer-compose.yml @@ -1,15 +1,31 @@ +# version: '3.8' +# services: + +# # Building and testing environment +# app: +# image: portainer/portainer-ce +# stdin_open: true +# tty: true +# command: ["/bin/zsh"] +# volumes: +# - /var/run/docker.sock:/var/run/docker.sock +# network_mode: "host" + version: '3.8' -services: - # Building and testing environment - app: - build: - context: . - dockerfile: Dockerfile - image: ghcr.io/growlf/toolbox:testing - stdin_open: true - tty: true - command: ["/bin/zsh"] +services: + portainer: + image: portainer/portainer-ce + container_name: toolbox_container + ports: + - "9000:9000" + - "8000:8000" volumes: - /var/run/docker.sock:/var/run/docker.sock - network_mode: "host" + - portainer_data:/data # Add this line to persist Portainer + restart: always + +volumes: + portainer_data: + + diff --git a/src/requirements.txt b/src/requirements.txt index 462dfd6..4f3b0df 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -6,3 +6,4 @@ portscan==1.1 pyfiglet==1.0.2 speedtest-cli==2.1.3 urllib3==2.1.0 +ansible==9.2.0 diff --git a/src/test_net.sh b/src/test_net.sh index 13fab3b..452b275 100755 --- a/src/test_net.sh +++ b/src/test_net.sh @@ -23,6 +23,9 @@ if test -t 1; then magenta="$(tput setaf 5)" cyan="$(tput setaf 6)" white="$(tput setaf 7)" + orange="$(tput setaf 208)" + purple="$(tput setaf 135)" + fi fi