0

当我使用 vagrant 使用分子 testig 进行 ansible 代码测试时,出现以下错误(/bin/sh: nslookup: command not found )

TASK [Query nslookup own domain] ***********************************************
fatal: [ vagrant01 ]: FAILED! => {"changed": true, "cmd": "nslookup `hostname --fqdn`", "delta": "0:00:00.012528", "end": "2021-10-21 13:42:40.197574", "msg": "non-zero return code", "rc": 127, "start": "2021-10-21 13:42:40.185046", "stderr": "/bin/sh: nslookup: command not found", "stderr_lines": ["/bin/sh: nslookup: command not found"], "stdout": "", "stdout_lines": []}
PLAY RECAP 
4

1 回答 1

0

所以好像nslookup没有安装

您可以添加一个任务来安装必要的工具

- name: Install nslookup
  apt:
    name: dnsutils
    state: present

如果您使用的是红帽发行版,则需要以下软件包

- name: Install nslookup
  yum:
    name: bind-utils
    state: present

或者,如果您想分发任何小酒馆,您可以同时添加

- name: Install nslookup for ubuntu
  apt:
    name: dnsutils
    state: present
  when: ansible_os_family == 'Debian'

- name: Install nslookup for redhat family
  yum:
    name: bind-utils
    state: present
  when: ansible_os_family == 'RedHat'

于 2021-10-22T08:48:15.357 回答