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
@ -67,8 +67,6 @@ def ensure_ansible_collections():
|
|||||||
collection_name = parts[0]
|
collection_name = parts[0]
|
||||||
installed_collections.append(collection_name)
|
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
|
# Check which required collections are missing
|
||||||
missing_collections = []
|
missing_collections = []
|
||||||
for collection in required_collections:
|
for collection in required_collections:
|
||||||
@ -167,15 +165,6 @@ def main():
|
|||||||
hostname = os.uname().nodename
|
hostname = os.uname().nodename
|
||||||
username = os.environ.get("USER", os.environ.get("USERNAME", "user"))
|
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
|
# Ensure required collections are installed
|
||||||
if not ensure_ansible_collections():
|
if not ensure_ansible_collections():
|
||||||
printfe("red", "Failed to ensure required Ansible collections are installed")
|
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