dj-wasabi / ansible-telegraf

Installing and configuring Telegraf via Ansible for RedHat/Debian/Ubuntu/Windows/Suse.
MIT License
134 stars 116 forks source link

Unable to run against linux machines (redhat) #159

Closed aram535 closed 9 months ago

aram535 commented 2 years ago

Describe the bug Role seems to think linux machine is an ec2_compute node. It's a VM. I suspect this is some sort of version issue since this playbook/role have worked well in the past and there have been multiple ansible upgrades since. I have checked to see if there are any other dependencies but none are listed.

Installation method/version Ansible host is a RedHat 8 VM, target is a RedHat 8 VM

Installed via ansible-galaxy role install dj-wasabi.telegraf

$ ansible-galaxy role list  dj-wasabi.telegraf
# /home/ansible/.ansible/roles
- dj-wasabi.telegraf, 0.13.2

Ansible:

$ ansible --version 
ansible [core 2.12.2]
  config file = /home/ansible/work/ansible.cfg
  configured module search path = ['/home/ansible/work/library']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
  executable location = /bin/ansible
  python version = 3.8.12 (default, Sep 16 2021, 10:46:05) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 2.10.3
  libyaml = True

Targetted hosts Concerns the following OS(es):

Expected behavior Telegraf is installed and started

Additional context

PLAY [target-server] *******************************************************************************************************************************

TASK [dj-wasabi.telegraf : Install on RedHat] **********************************************************************************************
included: /home/ansible/.ansible/roles/dj-wasabi.telegraf/tasks/RedHat.yml for target-server

TASK [dj-wasabi.telegraf : RedHat | Set name if state == latest] ***************************************************************************
ok: [target-server]

TASK [dj-wasabi.telegraf : Use RHEL 7 packages for Fedora] *********************************************************************************
skipping: [target-server]

TASK [dj-wasabi.telegraf : RedHat | Add yum repository] ************************************************************************************
ok: [target-server]

TASK [dj-wasabi.telegraf : RedHat | Download Telegraf package (online)] ********************************************************************
skipping: [target-server]

TASK [dj-wasabi.telegraf : RedHat | Install Telegraf package] ******************************************************************************
ok: [target-server]

TASK [dj-wasabi.telegraf : Install on Debian] **********************************************************************************************
skipping: [target-server]

TASK [dj-wasabi.telegraf : Install on Suse] ************************************************************************************************
skipping: [target-server]

TASK [dj-wasabi.telegraf : Install on FreeBSD] *********************************************************************************************
skipping: [target-server]

TASK [dj-wasabi.telegraf : Install on MacOS] ***********************************************************************************************
skipping: [target-server]

TASK [dj-wasabi.telegraf : include_tasks] **************************************************************************************************
skipping: [target-server]

TASK [dj-wasabi.telegraf : Configure Telegraf] *********************************************************************************************
fatal: [target-server]: FAILED! => 
  reason: |-
    couldn't resolve module/action 'ec2_metadata_facts'. This often indicates a misspelling, missing collection, or incorrect module path.

    The error appears to be in '/home/ansible/.ansible/roles/dj-wasabi.telegraf/tasks/configure_linux.yml': line 4, column 3, but may
    be elsewhere in the file depending on the exact syntax problem.

    The offending line appears to be:

    - name: Retrieve ec2 facts
      ^ here

PLAY RECAP *********************************************************************************************************************************
target-server                      : ok=4    changed=0    unreachable=0    failed=1    skipped=7    rescued=0    ignored=0  

Collection of target works fine:

$ ansible -m setup target-server 

PLAY [Ansible Ad-Hoc] **********************************************************************************************************************

TASK [setup] *******************************************************************************************************************************
ok: [target-server]

PLAY RECAP *********************************************************************************************************************************
target-server                      : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  

List of collections installed:

$ ansible-galaxy collection list 

# /home/ansible/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
ansible.posix     1.2.0  
ansible.windows   1.10.0 
community.crypto  2.5.0  
community.docker  2.7.0  
community.general 5.4.0  
daparm commented 1 year ago

Hi,

there is a dependency to amazon.aws.ec2_metadata_facts. To get rid of that error, you need to add the aws collection:

ansible-galaxy collection install amazon.aws

https://docs.ansible.com/ansible/latest/collections/amazon/aws/ec2_metadata_facts_module.html

dj-wasabi commented 9 months ago

Solution is provided, will close the issue.