Skip to content

Unable to install Prometheus and node exporter using collection from Ansible galaxy #551

Open
@ceseuron

Description

@ceseuron

I'm hitting a brick wall trying to deploy Prometheus with Ansible using the collection from Ansible Galaxy. I constantly get the below error

Debug output of ansible-playbook using -vvvv:

ansible-playbook [core 2.16.3]
  config file = /home/ceseuron/Repos/prometheus-deploy/ansible/ansible.cfg
  configured module search path = ['/home/ceseuron/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/ceseuron/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.12.3 (main, Feb  4 2025, 14:48:35) [GCC 13.3.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
Using /home/ceseuron/Repos/prometheus-deploy/ansible/ansible.cfg as config file
setting up inventory plugins
Loading collection ansible.builtin from 
host_list declined parsing /home/ceseuron/Repos/prometheus-deploy/ansible/inventory/aws_ec2.yml as it did not pass its verify_file() method
script declined parsing /home/ceseuron/Repos/prometheus-deploy/ansible/inventory/aws_ec2.yml as it did not pass its verify_file() method
Loading collection amazon.aws from /home/ceseuron/.ansible/collections/ansible_collections/amazon/aws
Using inventory plugin 'ansible_collections.amazon.aws.plugins.inventory.aws_ec2' to process inventory source '/home/ceseuron/Repos/prometheus-deploy/ansible/inventory/aws_ec2.yml'
Parsed /home/ceseuron/Repos/prometheus-deploy/ansible/inventory/aws_ec2.yml inventory source with auto plugin
Loading collection prometheus.prometheus from /home/ceseuron/.ansible/collections/ansible_collections/prometheus/prometheus
ERROR! couldn't resolve module/action 'prometheus.prometheus.prometheus'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/ceseuron/Repos/prometheus-deploy/ansible/prometheus.yml': line 41, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
    - name: Install Prometheus.
      ^ here

The Ansible play:

- name: Deploy Prometheus and Node Exporter.
  hosts: all
  gather_facts: no
  become: yes
  vars_files:
        - ./vars/default.yml
  vars:
    ansible_ssh_private_key: "{{ hostvars['localhost'].ssh_private_key }}"
    ansible_user: "ubuntu"
  tasks:
    - name: Install Prometheus.
      prometheus.prometheus.prometheus:
        name: prometheus
        version: "{{ prometheus_version }}"
        state: present
        install_dir: "{{ prometheus_install_dir }}"
        config_dir: "{{ prometheus_install_dir }}/config"
        service_state: started
        service_enabled: yes
    - name: Install Node Exporter.
      prometheus.prometheus.node_exporter:
        version:  "{{ prometheus_node_exporter_version }}"
        install_dir: "{{ prometheus_node_exporter_install_dir }}"

This error shouldn't be happening. Debug output clearly shows the collection is being loaded. I've verified, uninstalled, reinstalled, and re-verified the collection but I can't get Ansible to do anything other than complain about the same error.

Ansible version:

ansible [core 2.16.3]
  config file = /home/ceseuron/Repos/prometheus-deploy/ansible/ansible.cfg
  configured module search path = ['/home/ceseuron/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/ceseuron/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.3 (main, Feb  4 2025, 14:48:35) [GCC 13.3.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Output of ansible-galaxy collection list:

# /home/ceseuron/.ansible/collections/ansible_collections
Collection                               Version
---------------------------------------- -------
amazon.aws                               9.3.0  
prometheus.prometheus                    0.25.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions