首页 > 解决方案 > [警告]:模块 snow_record 未在:/usr/share/my_modules:/usr/lib/python2.7/site-packages/ansible/modules

问题描述

当我在剧本中使用 snow_record 时,我得到以下错误。请帮忙。

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
tasks:
- name: calling variable which has user/pass
  include_vars: /ansible/pass.yml

- name: read from snow
  snow_record_find:
     username: "{{ snow_username }}"
     password: "{{ snow_password }}"
     instance: mycompany
     state: present
     table: incident
     query:
       assignment_group: unix-support
     return_fields:
        - number
  register: host_list
# ansible-doc snow_record

[WARNING]: module snow_record not found in: /usr/share/my_modules:/usr/lib/python2.7/site-packages/ansible/modules

ansible 2.4.2.0
  config file = /home/m0156751/ansible/ansible.cfg
  configured module search path = [u'/usr/share/my_modules']
  ansible python module location - /usr/lib/python2.7/site-packages/ansible
  executable location - /usr/bin/ansible
  python version = 2.7.5 (default, Aug 13 2020, 02:51:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

标签: ansible

解决方案


您正在使用旧版本的 ansible (2.4.2),其中服务现在模块不存在 ( https://docs.ansible.com/ansible/2.4/list_of_all_modules.html )。

您需要升级到 2.5 才能获得该snow_record模块。

但是对于snow_record_find你需要升级到2.9。

从那时起,该模块是 servicenow 集合的一部分:https ://galaxy.ansible.com/servicenow/servicenow

除了拥有正确版本的 ansible 之外,这个特定的模块还有一些要求(https://docs.ansible.com/ansible/2.9/modules/snow_record_find_module.html#requirements):您需要pysnow在模块执行的目标主机。您可以在使用 service now 模块之前的任务中通过pippackage(如果 pysnow 作为系统包提供)模块来执行此操作。


推荐阅读