0

I am getting "duplicate host callback" error while running molecule tests. Not sure what I am missing as configuration looks good logically and syntactically. Please help.

Configuration:

remi_repos: [
  {name: remi, description: "REMI repository", file_name: "remi-base", priority: "3"},
  {name: php80, description: "REMI PHP 8.0 repository", file_name: "php80-remi", priority: "1"},
  {name: safe, description: "REMI Safe repository", file_name: "remi-safe", priority: "2"},
]


- include_tasks: repo-install.yml
  vars:
    repo_name: "{{  item.name  }}"
    repo_description: "{{ item.description }}"
    repo_file_name: "{{ item.file_name }}"
    repo_priority: "{{ item.priority }}"
  with_items: "{{ remi_repos }}"

-------------------------------
repo-install.yml content:
-------------------------------

- name: Add {{ repo_description }}
  become: true
  ansible.builtin.yum_repository:
    name: "{{ repo_name }}"
    description: "{{ repo_name }} YUM repo"
    file: "{{ repo_file_name }}"
    baseurl: "http://rpms.remirepo.net/enterprise/7/{{ repo_name }}/$basearch/"
    mirrorlist: "http://rpms.remirepo.net/enterprise/7/{{ repo_name }}/httpsmirror"
    priority: "{{ repo_priority }}"
    gpgcheck: true
    gpgkey: http://rpms.remirepo.net/RPM-GPG-KEY-remi

Molecule Test:

- include_tasks: repo-verify.yml
  vars:
    repo_name: "{{ item.name }}"
    repo_description: "{{ item.description }}"
    repo_file_name: "{{ item.file_name }}"
    repo_priority: "{{ item.priority }}"
  with_items: "{{ remi_repos }}"

-------------------------------
repo-verify.yml content:
-------------------------------
---
# This set of tasks helps to verify that linux repos are installed

- name: "Check that the {{ repo_description }} exists"
  stat:
    path: '/etc/yum.repos.d/{{ repo_file_name }}.repo'
  register: repo_installed

- name: "Failed if the {{ repo_name }}" repo not installed"
  assert:
    that:
      - not repo_installed.changed
    fail_msg: "The {{ repo_name }} repo was not installed"
    success_msg: "The {{ repo_name }} repo was installed"

Error Message:

INFO     Running default > verify
Molecule default > verify
INFO     Running Ansible Verifier
[WARNING]: Failure using method (v2_runner_on_failed) in callback plugin
(<ansible.plugins.callback.junit.CallbackModule object at 0x7fef2cf843a0>):
/xxx/nextcloud-
ami/ansible/xxx/molecule/default/test-dependencies.yml:9: Verify:
include_tasks _raw_params=repo-verify.yml: duplicate host callback:
test-molecule
CRITICAL Ansible return code was 2, command was: ['ansible-playbook', '--inventory', '/root/.cache/molecule/xxx/default/inventory', '--skip-tags', 'molecule-notest,notest', '/xxx/molecule/default/verify.yml']
WARNING  An error occurred during the test sequence action: 'verify'. Cleaning up.
Rob Wilkinson
  • 1,131
  • 5
  • 18
  • 34
  • The callbacks are configured in the _ansible.cfg_ file or via shell variables. Which you are not providing in your question. – β.εηοιτ.βε Apr 04 '23 at 21:43
  • @β.εηοιτ.βε: Thanks for your response. Looks like I found the issue. There is an additional double quote in the (- name: "Failed if the {{ repo_name }}" repo not installed"). After removing this the test passed. The error message is confusing. – Rob Wilkinson Apr 04 '23 at 21:55

1 Answers1

0

I found the root cause of the issue. There is an additional double quote in the

 - name: "Failed if the {{ repo_name }}" repo not installed"

After removing this the test passed. The error message was confusing.

Rob Wilkinson
  • 1,131
  • 5
  • 18
  • 34