admin管理员组

文章数量:1122826

When executing a playbook with the ansible collection paloaltonetworks.panos I get the error message Missing required library

{“changed”: false, “msg”: “Missing required library 
\\”pan-os-python\\“.”, 'pypi': “, 
'syspath': \["/tmp/ansible_paloaltonetworks.panos. panos_facts_payload_ygajy97b/
ansible_paloaltonetworks.panos.panos_facts_payload.zip”,
 ‘/usr/lib/python312. zip’, ‘/usr/lib/python3.12’, 
‘/usr/lib/python3.12/lib-dynload’, 
‘/home/user/Test/.venvTest/lib/python3.12/site-packages’\]}

The required package pan-os-python is installed in the virtual python environment according to pip list:

pip list | grep pan
pan-os-python 1.8.0
pan-python 0.17.0
panos-upgrade-assurance 0.3.0

In the playbook I also refer to the python interpreter of the virtual environment:

vars:
ansible_python_interpreter: /home/user/Test/.venvTest/bin/python3.12

The system used is a Linux ubuntu 22.04

The playbook was executed normally via the CLI:

ansible-playbook /home/user/Test/FirewallManagement/panos/get.system.info/panos.get.system.info.yml

The script should return basic information about a firewall but fails due to the package not being found

the playbook runs locally:

# ansible-playbook /home/user/Test/FirewallManagement/panos/get.system.info/panos.get.system.info.yml
---
- name: Gather system info
  hosts: "{{ host }}"
  connection: local
  collections:
    - paloaltonetworks.panos
  vars:
    ansible_python_interpreter: /home/user/Test/.venvTest/bin/python3.12
  vars_prompt:
    - name: host
      prompt: Device/Devicegroup
      private: no

  tasks:
    - name: Gather facts for device
      paloaltonetworks.panos.panos_facts:
        provider: "{{ provider }}"
    - name: Display information
      ansible.builtin.debug:
        msg:
          - "Hostname: {{ ansible_facts['net_hostname'] }}"
          - "Serial: {{ ansible_facts['net_serial'] }}"
          - "Model: {{ ansible_facts['net_model'] }}"
          - "Version: {{ ansible_facts['net_version'] }}"
          - "Uptime: {{ ansible_facts['net_uptime'] }}"
          - "HA Enabled: {{ ansible_facts['net_ha_enabled'] }}"
          - "HA Type: {{ ansible_facts['net_ha_localmode'] }}"
          - "HA Status: {{ ansible_facts['net_ha_localstate'] }}"
          - "Multi-VSYS: {{ ansible_facts['net_multivsys'] }}"
          - "{{ ansible_facts['net_session_usage'] }} out of {{ ansible_facts['net_session_max'] }} sessions in use"
    - name: Save to file
      copy:
        content: 
          - "{{ ansible_facts['net_hostname'] }}"
          - "{{ ansible_facts['net_serial'] }}"
          - "{{ ansible_facts['net_model'] }}"
          - "{{ ansible_facts['net_version'] }}"
          - "{{ ansible_facts['net_uptime'] }}"
          - "{{ ansible_facts['net_ha_enabled'] }}"
          - "{{ ansible_facts['net_ha_localmode'] }}"
          - "{{ ansible_facts['net_ha_localstate'] }}"
          - "{{ ansible_facts['net_multivsys'] }}"
        dest: "/home/user/Test/FirewallManagement/panos/get.system.info/temp/{{ host }}.json"

本文标签: pythonAnsible Playbooks Missing required libraryStack Overflow