so what i tried is , I created another playbook and inside that mentioned serial which works fine with add_host . I am getting expected results but when i tried to add this code in my actual role. (I first test code in temporary playbook , so that i dont mess the role)
But when copy paste the code in my role here obviously structure is different,
main.yml–>zookeeper.yml(task yaml )–> imported playbook(new playbook as serial only works for plays).
code ,
this is zookeeper.yml which is a task list yaml, and not a playbook
- name: Check who is existing zokeeper leader
shell: ‘echo stat | nc localhost “{{hostvars[inventory_hostname].zk_port}}” | grep Mode’
register: zkmode
- name: Set service name as a fact
set_fact:
service_name: “{{ zookeeper_service_name }}”
import_playbook: Restart.yml
now when i run the role i get
ERROR! this task ‘import_playbook’ has extra params, which is only allowed in the following modules: command, include, ansible.legacy.meta, ansible.legacy.set_fact, import_tasks, ansible.legacy.import_role, win_shell, group_by, win_command, ansible.builtin.set_fact, include_vars, ansible.builtin.shell, ansible.builtin.meta, ansible.legacy.group_by, ansible.legacy.win_command, set_fact, import_role, ansible.legacy.command, ansible.legacy.include_tasks, ansible.builtin.import_role, ansible.legacy.raw, meta, include_role, ansible.legacy.win_shell, include_tasks, ansible.builtin.script, add_host, ansible.legacy.add_host, ansible.builtin.include_tasks, script, ansible.builtin.include_vars, ansible.windows.win_command, ansible.builtin.add_host, ansible.legacy.include, ansible.legacy.include_role, ansible.legacy.shell, ansible.builtin.include_role, shell, ansible.legacy.script, ansible.builtin.win_shell, ansible.builtin.win_command, ansible.builtin.command, ansible.builtin.raw, raw, ansible.legacy.import_tasks, ansible.legacy.include_vars, ansible.builtin.group_by, ansible.windows.win_shell, ansible.builtin.include, ansible.builtin.import_tasks
The error appears to be in ‘/Users/sameer_modak/ansibledemo/prometheus/tasks/zookeeper_prometheus.yml’: line 118, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Imporing Restartandcheck yaml
^ here