feat: enhance command execution with error handling and add Ansible task for Docker repository checkout
Some checks failed
Nix Format Check / check-format (push) Failing after 38s
Some checks failed
Nix Format Check / check-format (push) Failing after 38s
This commit is contained in:
@ -5,6 +5,7 @@ import sys
|
|||||||
import subprocess
|
import subprocess
|
||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
|
import shutil
|
||||||
try:
|
try:
|
||||||
import pyfiglet
|
import pyfiglet
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -79,15 +80,20 @@ def logo(continue_after=False):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printfe("red", f"Error displaying logo: {e}")
|
printfe("red", f"Error displaying logo: {e}")
|
||||||
|
|
||||||
def run_command(command, shell=False):
|
def run_command(command, shell=False):
|
||||||
"""Run a shell command and return the result"""
|
"""Run a shell command and return the result"""
|
||||||
try:
|
try:
|
||||||
|
if not shell and not shutil.which(command[0]):
|
||||||
|
return False, f"Command '{command[0]}' not found"
|
||||||
|
|
||||||
result = subprocess.run(command, shell=shell, check=True, text=True,
|
result = subprocess.run(command, shell=shell, check=True, text=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
return True, result.stdout.strip()
|
return True, result.stdout.strip()
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return False, e.stderr.strip()
|
return False, e.stderr.strip()
|
||||||
|
except FileNotFoundError:
|
||||||
|
return False, f"Command '{command[0]}' not found"
|
||||||
|
return False, e.stderr.strip()
|
||||||
|
|
||||||
def ensure_dependencies():
|
def ensure_dependencies():
|
||||||
"""Check and install required dependencies for the dotfiles system"""
|
"""Check and install required dependencies for the dotfiles system"""
|
||||||
|
@ -4,3 +4,12 @@
|
|||||||
- openssh-server
|
- openssh-server
|
||||||
state: present
|
state: present
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
- name: Ensure checkout docker /mnt/services repository
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: "https://git.mvl.sh/vleeuwenmenno/services.git"
|
||||||
|
dest: "/mnt/services"
|
||||||
|
update: true
|
||||||
|
version: "main"
|
||||||
|
register: git_result
|
||||||
|
changed_when: git_result.changed
|
||||||
|
Reference in New Issue
Block a user