ansible_host set to another variable fails

Đang mở
#620 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
ansible, python

Hướng nghiên cứu

Reproduce the failure with the shown host_vars/my_host.yml configuration, Python 3.8.6, pytest 6.2.4, testinfra 6.4.0, and Ansible 4.1.0. Start at the Ansible connection backend and determine whether ansible_host is expected to resolve this variable reference; done means either supporting the interpolation with coverage or documenting the confirmed limitation.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Trying to use ansible connection backend, it seems to fail when
ansible_host variable is set to another variable, like so inventories/host_vars/my_host.yml

---
network_interfaces:
  - name: ens3
    address: 10.254.14.18
    netmask: 255.255.255.0
    gateway: 10.254.14.1

ansible_host: "{{ network_interfaces[0]['address'] }}"

when running testinfra this results in:

E           RuntimeError: CommandResult(command=b"sudo /bin/sh -c 'getent ahosts mail.example.com'", exit_status=255, stdout=None, stderr=b"ssh: Could not resolve hostname {{ network_interfaces[0]['address'] }}: Name or service not known\r\n")

A workaround is changing the host inventory file like so, but this is
not ideal:

---
network_interfaces:
  - name: ens3
    address: 10.254.14.18
    netmask: 255.255.255.0
    gateway: 10.254.14.1

ansible_host: 10.254.14.18 

Is this a limitation in testinfra, or am I doing something wrong?

versions using:

Python 3.8.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
plugins: testinfra-6.4.0
ansible == 4.1.0
Ngôn ngữ chính
Python
Star
2.5k
Fork
359
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pytest-dev/pytest-testinfra

Tất cả issue của pytest-dev/pytest-testinfra

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.