'Why comunity general telegram ansible got this problem?
I want to configure ansible playbook, put some code for start the service and send notification to the telegram but I got this error. I think this is not typing error but there is something error with the community general telegram. Before this I already run the same process but got no error. Now I try reinstall new server and do the same process and I got this error.
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
start.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
Installation process
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 Version
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
Solution 1:[1]
According to the documentation you need to add collection
keyword
But also from the documentation for 2.9 version of the module telegram you can do it without collection.
So, either use:
collections:
- community.general
or
- 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
It should work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | malpanez |