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



我的剧本包含传递给角色的变量。当我运行它,我得到[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
...

角色如下:

日志轮换/任务/main.yml

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

日志轮换/违约/main.yml

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

日志轮换/模板/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变量也没有定义。

相关内容

  • 没有找到相关文章

最新更新