gpt4 book ai didi

ubuntu - 为什么社区通用电报ansible会出现这个问题?

转载 作者:行者123 更新时间:2023-12-04 19:24:38 34 4
gpt4 key购买 nike

我想配置 ansible playbook,放置一些代码来启动服务并向电报发送通知,但我收到了这个错误。我认为这不是打字错误,而是社区通用电报有一些错误。在此之前我已经运行了相同的过程但没有错误。现在我尝试重新安装新服务器并执行相同的过程,但出现此错误。

 ERROR! couldn't resolve module/action 'community.general.telegram'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/etc/ansible/playbook/start.yml': line 10, column 6, but maybe elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: send notify to telegram
^ here
开始.yml
---
- name: testing playbook
hosts: server
tasks:
- name: start apache service
service:
name: apache2
state: started

- name: send notify to telegram
community.general.telegram:
token: 'telegram token'
api_args:
chat_id: telegramid
parse_mode: "markdown"
text: "Apache Web service has been started!"
disable_web_page_preview: True
disable_notification: True
安装流程
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list
sudo apt install dirmngr -y
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
sudo apt update
sudo apt install -y ansible
sudo ansible-galaxy collection install community.general
Ansible 版本
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0]
sudo ansible-galaxy collection install community.general
Process install dependency map
Starting collection install process
Skipping 'community.general' as it is already installed

最佳答案

根据documentation您需要添加 collection关键词
但也来自 2.9 版本模块的文档 telegram你可以在没有收集的情况下做到这一点。
所以,要么使用:

collections:
- community.general
或者
   - name: send notify to telegram
telegram:
token: 'telegram token'
api_args:
chat_id: telegramid
parse_mode: "markdown"
text: "Apache Web service has been started!"
disable_web_page_preview: True
disable_notification: True
它应该工作。

关于ubuntu - 为什么社区通用电报ansible会出现这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72283066/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com