Missing interpreter line for builtin modules

I’m trying to include a playbook, and getting this error:

Using module file /opt/ansible_env/lib64/python3.9/site-packages/ansible/modules/import_playbook.py
fatal: [w2k19]: FAILED! => {
    "msg": "module (ansible.builtin.import_playbook) is missing interpreter line"
}

That’s strange. Can you provide some more info, like output from ansible-playbook --version and the yaml generating this message? Also, you say “trying to include” but the msg says “builtin.import_playbook”. Include vs. import. ?

1 Like

I’m doing this from molecule converge
I’ve simplified it a lot to try and eliminate possible red herrings

- name: Converge windows
  hosts: windows
  tasks:
    - name: Print ansible_winrm_operation_timeout_sec parameters
      ansible.builtin.debug:
        var: ansible_winrm_operation_timeout_sec
    - name: Print ansible_winrm_read_timeout_sec parameters
      ansible.builtin.debug:
        var: ansible_winrm_read_timeout_sec
    - name: Include the test playbook that does nothing.
      ansible.builtin.import_playbook:
        name: ../../djl_test.yml
>ansible-playbook --version
ansible-playbook [core 2.15.9]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/ansible_env/lib64/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/ansible_env/bin/ansible-playbook
  python version = 3.9.16 (main, Sep 12 2023, 00:00:00) [GCC 11.3.1 20221121 (Red Hat 11.3.1-4)] (/opt/ansible_env/bin/python3)
  jinja version = 3.1.3
  libyaml = True

import_playbook is not a task. It is a top-level playbook directive and cannot be part of a play or other task list.

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_playbook_module.html#examples

It also does not take a parameter called name, just a string with the playbook filename.

- name: Converge windows
  hosts: windows
  tasks:
    - name: Print ansible_winrm_operation_timeout_sec parameters
      ansible.builtin.debug:
        var: ansible_winrm_operation_timeout_sec
    - name: Print ansible_winrm_read_timeout_sec parameters
      ansible.builtin.debug:
        var: ansible_winrm_read_timeout_sec

- name: Include the test playbook that does nothing.
  ansible.builtin.import_playbook: ../../djl_test.yml
5 Likes

Thanks for the information @flowerysong
:: Edited :: I can see how you changed the code there to move the import to the top level of the yaml. Thanks for the guidance!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.