Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jan 30, 2026
1 parent bf8e8a3 commit 7357c00
Showing 1 changed file with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 <<EOF > 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 "------------------------------------------------"

0 comments on commit 7357c00

Please sign in to comment.