【问题标题】:Getting this error: ERROR! 'openssl_certificate' is not a valid attribute for a Play收到此错误:错误! “openssl_certificate”不是 Play 的有效属性
【发布时间】:2021-01-08 22:52:27
【问题描述】:

所以我正在尝试运行一个小剧本来测试此处记录的 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

我在这里做错了什么?我敢肯定这是小事。

【问题讨论】:

  • 你的缩进错误;它应该在tasks: 下,但您将其作为顶级列表项,而剧本中的顶级项是 Plays

标签: ssl ansible yaml ssl-certificate


【解决方案1】:

你的缩进是错误的。复制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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-09
    • 1970-01-01
    • 1970-01-01
    • 2017-12-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-10
    • 1970-01-01
    相关资源
    最近更新 更多