Getting this error: ERROR! 'openssl_certificate' is not a valid attribute for a Play

Getting this error: ERROR! 'openssl_certificate' is not a valid attribute for a Play

所以我正在尝试 运行 一个小剧本来测试此处记录的 openssl_certificate 模块:https://docs.ansible.com/ansible/2.7/modules/openssl_certificate_module.html

我的剧本:

---
- name: play to run opensll verification
  hosts: localhost

  tasks:
- name: Running OpenSSL Module.
  openssl_certificate:
    path: "bleh.crt"
    provider: assertonly
    valid_in: "{{ (20*3600*24) | int }}"
  register: VALIDATION_OUTPUT
  ignore_errors: true

基本上我想看看证书在给定的时间范围内是否有效。然而,当我 运行

ansible-playbook openssl_test.yml

我得到:

ERROR! 'openssl_certificate' is not a valid attribute for a Play

The error appears to be in '/path/to/my/yaml/openssl_test.yml': line 6, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
- name: Running OpenSSL Module.
  ^ here

我在这里做错了什么?肯定是小东西。

你的缩进有误。复制yaml数据时,如果使用vim编辑器保留缩进,则可以使用:set paste

---
- name: play to run opensll verification
  hosts: localhost

  tasks:
  - name: Running OpenSSL Module.
    openssl_certificate:
      path: "bleh.crt"
      provider: assertonly
      valid_in: "{{ (20*3600*24) | int }}"
    register: VALIDATION_OUTPUT
    ignore_errors: true