From 732455607d2414483ee1d53c248a9f029c3b9333 Mon Sep 17 00:00:00 2001 From: c0de Date: Sun, 21 Jan 2024 12:58:06 -0500 Subject: [PATCH] Initial Commit --- .editorconfig | 16 ++++++++++++++++ .gitignore | 2 ++ .vscode/settings.json | 6 ++++++ license.txt | 28 ++++++++++++++++++++++++++++ logs/.gitkeep | 0 playbooks/inventories/.gitkeep | 0 playbooks/play.sh | 14 ++++++++++++++ playbooks/roles/.gitkeep | 0 readme.md | 25 +++++++++++++++++++++++++ requirements.txt | 10 ++++++++++ 10 files changed, 101 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 license.txt create mode 100644 logs/.gitkeep create mode 100644 playbooks/inventories/.gitkeep create mode 100755 playbooks/play.sh create mode 100644 playbooks/roles/.gitkeep create mode 100644 readme.md create mode 100644 requirements.txt diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b11f5b2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false +indent_size = 2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dfc68cf --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +**/*venv* +**/*.log diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c4af75e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "license.filename": "license", + "license.extension": ".txt", + "license.author": "Code Fox ", + "license.default": "bsd-3-clause" +} diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..f56657e --- /dev/null +++ b/license.txt @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2024, Code Fox + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/logs/.gitkeep b/logs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/playbooks/inventories/.gitkeep b/playbooks/inventories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/playbooks/play.sh b/playbooks/play.sh new file mode 100755 index 0000000..96106ea --- /dev/null +++ b/playbooks/play.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +playbook_name=$1 +inventory_path="./inventories/" +log_path="../logs" +log_file="${log_path}/${playbook_name}.log" + +mkdir -p "${log_path}" + +echo "${playbook_name} started at $(date)" | tee -a "${log_file}" + +{ time ansible-playbook -i "${inventory_path}" "${playbook_name}" ; } 2>&1 | tee -a "${log_file}" + +echo "${playbook_name} finished at $(date)" | tee -a "${log_file}" diff --git a/playbooks/roles/.gitkeep b/playbooks/roles/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..dc42e5b --- /dev/null +++ b/readme.md @@ -0,0 +1,25 @@ +# proxmox-ansible + +Ansible playbooks to manage proxmox in a variety of ways + +## Requirements + +1. Linux (or WSL) or Mac +1. Python 3 + +## Getting Started + +1. Clone this repository: `git clone https://c0de.dev/c0de/proxmox-ansible` +1. Enter this repository: `cd proxmox-ansible` +1. Create a Python virtual environment: `python3 -m venv .venv` +1. Activate the virtual environment: `source .venv/bin/activate` +1. (Optional) Upgrade pip: `pip3 install --upgrade pip` +1. Install requirements: `pip3 install -r requirements.txt` +1. Install Ansible General Community Collection: `ansible-galaxy collection install community.general` + - _Note: This might already be installed._ + +## Running Playbooks + +1. Enter the playbook directory: `cd playbooks` +1. Run `./play.sh .yml` + - The script will record a log of the output, as well as timing information in [logs](./logs) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..50c7658 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +ansible==9.1.0 +ansible-core==2.16.2 +cffi==1.16.0 +cryptography==41.0.7 +Jinja2==3.1.3 +MarkupSafe==2.1.4 +packaging==23.2 +pycparser==2.21 +PyYAML==6.0.1 +resolvelib==1.0.1