refactor: remove obsolete pipx task and clean up ensure_ansible_collections function
Some checks failed
Nix Format Check / check-format (push) Failing after 37s
Some checks failed
Nix Format Check / check-format (push) Failing after 37s
This commit is contained in:
parent
bec0970a4a
commit
ceca79f39b
@ -66,9 +66,7 @@ def ensure_ansible_collections():
|
||||
if len(parts) >= 1:
|
||||
collection_name = parts[0]
|
||||
installed_collections.append(collection_name)
|
||||
|
||||
printfe("cyan", f"Found installed collections: {', '.join(installed_collections) if installed_collections else 'none'}")
|
||||
|
||||
|
||||
# Check which required collections are missing
|
||||
missing_collections = []
|
||||
for collection in required_collections:
|
||||
@ -166,16 +164,7 @@ def main():
|
||||
dotfiles_path = os.environ.get("DOTFILES_PATH", os.path.expanduser("~/.dotfiles"))
|
||||
hostname = os.uname().nodename
|
||||
username = os.environ.get("USER", os.environ.get("USERNAME", "user"))
|
||||
|
||||
# Check if ansible is installed
|
||||
status, _ = run_command(["which", "ansible-playbook"], shell=False)
|
||||
if not status:
|
||||
printfe("yellow", "Ansible is not installed, installing it with pipx...")
|
||||
status, output = run_command(["pipx", "install", "--include-deps", "ansible", "ansible-lint"], shell=False)
|
||||
if not status:
|
||||
printfe("red", f"Failed to install Ansible: {output}")
|
||||
return 1
|
||||
|
||||
|
||||
# Ensure required collections are installed
|
||||
if not ensure_ansible_collections():
|
||||
printfe("red", "Failed to ensure required Ansible collections are installed")
|
||||
|
@ -1,24 +0,0 @@
|
||||
- name: List installed pipx packages
|
||||
ansible.builtin.shell: set -o pipefail && pipx list --short | awk '{print $1}'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: installed_pipx_packages
|
||||
changed_when: false
|
||||
|
||||
- name: Define desired pipx packages
|
||||
ansible.builtin.set_fact:
|
||||
desired_pipx_packages:
|
||||
- shyaml
|
||||
|
||||
- name: Install/Upgrade pipx packages
|
||||
community.general.pipx:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
force: true
|
||||
loop: "{{ desired_pipx_packages }}"
|
||||
|
||||
- name: Remove undesired pipx packages
|
||||
community.general.pipx:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
loop: "{{ installed_pipx_packages.stdout_lines | difference(desired_pipx_packages) }}"
|
Loading…
x
Reference in New Issue
Block a user