From 7357c00ab1839f9b1678d02dc37069a23f0c3f93 Mon Sep 17 00:00:00 2001 From: badra001 Date: Fri, 30 Jan 2026 08:23:30 -0500 Subject: [PATCH] initial --- .../create-ansible.sh | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 local-app/python-tools/build-ansible-distribution/create-ansible.sh diff --git a/local-app/python-tools/build-ansible-distribution/create-ansible.sh b/local-app/python-tools/build-ansible-distribution/create-ansible.sh new file mode 100755 index 00000000..85fc88dd --- /dev/null +++ b/local-app/python-tools/build-ansible-distribution/create-ansible.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +VERSION="1.0.0" +THIS=$(basename $0 .sh) + +# Define the target directory +if [ -z "$1" ] +then + APP_DIR="/apps/ansible" +else + APP_DIR="$1" +fi + +PYTHON_VERSION="3.13" # Can be changed to 3.12 or latest + +# 0. export environment variables needed +export SSL_CERT_FILE=/etc/pki/tls/certs/ca-bundle.crt +export UV_PYTHON_INSTALL_DIR=/apps/uv/share +export UV_LINK_MODE=copy +export UV_NATIVE_TLS=true + +# 1. Create and enter the directory +mkdir -p "$APP_DIR" +chown $(whoami):$(whoami) "$APP_DIR" +cd "$APP_DIR" + +# 2. Initialize the uv project +uv init --no-workspace --app + +# 3. Create the pyproject.toml with Ansible dependencies +cat < pyproject.toml +[project] +name = "ansible-distribution" +version = "1.0.0" +description = "Self-contained Ansible distribution" +readme = "README.md" +requires-python = ">=3.12" +dependencies = [ + "ansible>=10.0.0", + "ansible-lint", + "jmespath", + "netaddr", + "dnspython>=2.8.0", +] + +[tool.uv] +# This ensures the venv is created within the project folder +dev-dependencies = [] + +[[tool.uv.index]] +name = "pypi" +url = "https://nexus.it.census.gov:8443/repository/DataScience-Group/simple" +EOF + +# 4. Create the venv and install dependencies +# Use --python to specify 3.12, 3.13, etc. +uv venv --python "$PYTHON_VERSION" +source .venv/bin/activate + +# 5. Sync the environment +uv sync + +# 6. Create a convenient entry point symlink +mkdir -p bin +ln -sf "$APP_DIR/.venv/bin/ansible" "$APP_DIR/bin/ansible" +ln -sf "$APP_DIR/.venv/bin/ansible-playbook" "$APP_DIR/bin/ansible-playbook" + +echo "------------------------------------------------" +echo "Ansible distribution created at $APP_DIR" +echo "Python version: $(python --version)" +echo "To use: source $APP_DIR/.venv/bin/activate" +echo "------------------------------------------------"