首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行ansible剧本时出现的Vague弃用错误

运行ansible剧本时出现的Vague弃用错误
EN

Stack Overflow用户
提问于 2016-08-30 20:35:14
回答 1查看 93关注 0票数 3

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

我现在拥有的是:

代码语言:javascript
复制
---

- 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

代码语言:javascript
复制
---

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

...

log-rotation/defaults/main.yml

代码语言:javascript
复制
---

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

...

log-rotation/templates/logrotate.d.j2

代码语言:javascript
复制
# {{ 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 -%}
}

任何帮助都将不胜感激!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-30 20:44:23

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39236646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档