Prompt Title: Create Ansible flavor folder.

Created 1 year ago
Votes 0
Views 117 times
0

Prompt Detail:

I apologize for the confusion earlier. Here's the modified script that should work with the folder structure you provided:

bash
#!/bin/bash # Check if Python is installed if command -v python3 &>/dev/null; then echo "Python is already installed." else echo "Python is not installed. Installing Python..." # Update package manager and install Python if command -v apt-get &>/dev/null; then sudo apt-get update sudo apt-get install -y python3 elif command -v yum &>/dev/null; then sudo yum update sudo yum install -y python3 else echo "Error: Package manager not found. Please install Python manually." exit 1 fi echo "Python installation completed." fi # Check if Ansible is installed if [ ! -x "$(command -v ansible)" ]; then echo "Ansible not found, installing..." sudo apt update sudo apt install software-properties-common sudo apt-add-repository --yes --update ppa:ansible/ansible sudo apt install ansible else echo "Ansible already installed" fi sudo locale-gen en_IN.UTF-8 export LANG=en_IN.UTF-8 # Define variables playbook="" flavor="minimal" # Extract command line arguments while [[ $# -gt 0 ]]; do case "$1" in -f|--flavor) flavor="$2" shift 2 ;; *) # Accept any argument, assuming it is a valid playbook name playbook="$1" shift ;; esac done # Set playbook file path based on flavor and playbook name if [ "$flavor" == "central_orchestrator" ]; then playbook_file="./flavors/central_orchestrator/playbooks/$playbook.yml" elif [ "$flavor" == "minimal" ]; then playbook_file="./playbooks/$playbook.yml" else echo "Error: Invalid flavor '$flavor'. Please choose 'minimal' or 'central_orchestrator'." exit 1 fi # Check if playbook file exists if [ ! -f "$playbook_file" ]; then echo "Error: Playbook '$playbook_file' not found." exit 1 fi # Run the Ansible playbook ansible-playbook -i inventory/inventory.yml -v "$playbook_file" -K -k

To run this script, you can specify the playbook and flavor using the -p/--playbook and -f/--flavor options, respectively. For example:

bash
./deploy_ems.sh -p single_node_ems_deployment -f central_orchestrator

This will run the single_node_ems_deployment playbook using the central_orchestrator flavor. If you don't specify a flavor, it will default to minimal.

avatar
nags
Shared 3 prompts
Created 1 year ago

Leave a Comment