运行 ansible 剧本时出现模糊弃用错误

Vague deprecation error when running ansible playbook

我的剧本包含传递给角色的变量。当我 运行 它时,我得到 [DEPRECATION WARNING]: Skipping task due to undefined Error, in the future this will be a fatal error..

这是我拥有的:

---

- hosts: hadoopL0X
  become: yes
  become_method: sudo

  vars:
    logrotate_scripts:
      - name: "{{ item  }}"
        with_items:
          - zookeeper
          - sa
        path: "/var/log{{ item }}/{{ item }}.log "
        options:
          - daily
          - rotate 3
          - missingok
          - compress
          - notifempty
  roles:
    - log-rotation

...

角色是这样的:

log-rotation/tasks/main.yml

---

- name: Setup logrotate.d scripts
  template:
    src: logrotate.d.j2
    dest: "{{ logrotate_conf_dir }}{{ item }}"
  with_items: "{{ logrotate_scripts }}"

...

log-rotation/defaults/main.yml

---

logrotate_conf_dir: "/etc/logrotate.d/"
logrotate_scripts: []

...

log-rotation/templates/logrotate.d.j2

# {{ ansible_managed }}

"{{ item.path }}" {
  {% if item.options is defined -%}
  {% for option in item.options -%}
  {{ option }}
  {% endfor -%}
  {% endif %}
  {%- if item.scripts is defined -%}
  {%- for name, script in item.scripts.iteritems() -%}
  {{ name }}
    {{ script }}
  endscript
  {% endfor -%}
  {% endif -%}
}

如有任何帮助,我们将不胜感激!

with_items 只能用于任务,不能在定义变量时使用,因此 item 未定义。看起来 service 变量也没有定义。