3
私のプレイブックには、ロールに渡されたヴァールが含まれています。私はそれを実行すると、私は[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 }}"
...
log-rotation/defaults/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 -%}
}
任意の助けもいただければ幸いです!
お返事ありがとうございます!私が変数に変数を投げ込む前に、プレイブックが機能していればそれはまったく意味があります。 logrotateテンプレートタスクを繰り返し実行する複数のサービスを定義する最良の方法は何でしょうか? –
set_fact inside with_itemsはあなたが望むことをする必要があります – nitzmahone
@MarcWKoserではMattが提案したものを使用できますが、あなたの役割を変更して、logrotate設定を作成したいサービスの名前のリストを渡すことをお勧めします。私が見ることができるように、ファイルのパスを除いてすべてが同じで、サービスの名前から構築できます。 –