0
私は現在、私の不可能なプレイブックを使ってLetsencrypt証明書を自動取得する可能性を作り出しています。アシスタント - dictに基づいて動作していない状態のループ
私は/etc/letsencrypt/domain.tldディレクトリが存在するかどうかを確認したいのですが、そうでない場合は証明書を取得する必要があります。
---
- name: LETSENCRYPT | Checking for existing certificates
stat:
path: /etc/letsencrypt/live/{{ item.value.server_name }}
register: le_cert_exists
with_dict: "{{ sites }}"
when: item.value.letsencrypt | default(false) | bool
- name: DEBUG | Output result of le cert exists
debug:
var: le_cert_exists
- name: LETSENCRYPT | Output sites that need a new certificate
debug:
msg: Obtain certificate here
var: item.item
with_items: le_cert_exists.results
when: item.stat.exists is defined and not item.stat.exists
これまでのところ、最後の機能を除いて動作しています。最後のタスクは、単にスキップされた取得し続けるか、次のエラーで失敗します。
fatal: [-]: FAILED! => {"msg": "The conditional check 'item.stat.exists is defined and not item.stat.exists' failed. The error was: error while evaluating conditional (item.stat.exists is defined and not item.stat.exists): 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'stat'\n\nThe error appears to have been in '/path/to/main.yml': line 13, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: LETSENCRYPT | Output sites that need a new certificate\n^here\n"}
は、誰もが、これは簡単に行うことができる方法の例を持っていますか?
ディレクトリが存在しない場合は、コマンドを実行するだけです。