简体   繁体   English

Ansible:错误! 任务中未检测到任何操作

[英]Ansible: Error! No action detected in task

I am receiving the following error message: 我收到以下错误消息:

fatal: [127.0.0.1]: FAILED! 致命的:[127.0.0.1]:失败! => {"failed": true, "reason": "ERROR! no action detected in task\\n\\nThe error appears to have been in '/etc/ansible/roles/user-manage/tasks/add-users.yml': line 8, column 4, but may\\nbe elsewhere in the file depending on the exact syntax problem.\\n\\nThe offending line appears to be:\\n\\n\\n - name: Add multiple users\\n ^ here\\n"} => {“失败”:true,“原因”:“ ERROR!在任务中未检测到任何操作\\ n \\ n错误似乎出在'/etc/ansible/roles/user-manage/tasks/add-users.yml中':第8行第4列,但可能会\\ n根据确切的语法问题而在文件的其他位置。\\ n \\ n出现问题的行似乎是:\\ n \\ n \\ n-名称:在此处添加多个用户\\ n ^ \\ n“}

Here is my playbook that it is complaining about: 这是我在抱怨的剧本:

 - name: Add new group if it doesn't exist already
   group:
    name: "{{ item }}"
   with_items:
    - "{{ group_add }}"
   when: group_add is defined

 - name: Add multiple users
   users:
    name: "{{ item.users_name }}"
    comment: "{{item.users_comment }}"
    uid: "{{ item.users_uid }}"
    group: "{{ item.users_group }}"
    groups: "{{ item.users_groups }}"
    shell: "{{ item.users_shell }}"
    state: "{{ item.users_state }}"
    append: yes
   with_items:
     - "{{ users_add }}"

 - name: Add SSH key for user
   authorized_key:
    user: "{{ item.name }}"
    key: "{{ lookup('file', '/etc/ansible/files/keys/{{ item.users_name }}.pub') }}"
   with_items:
    - "{{ users_add }}"

This was just working last night. 这只是昨晚的工作。 I'm unsure of what is causing this. 我不确定是什么原因造成的。 Any ideas? 有任何想法吗?

There is no users module. 没有users模块。 The correct name is user . 正确的名称是user Remove the s and it will work. 删除s ,它将起作用。

I was having the same error on the first line (also the name line) of a playbook. 我在剧本的第一行(也是名称行)中遇到了相同的错误。 It turned out that I was using an older version of Ansible that was not compatible with some of the newer modules called in my playbook. 原来,我使用的是旧版本的Ansible,该版本与我的剧本中调用的某些较新模块不兼容。 Once I updated Ansible to the most current version, my playbook ran no problem. 将Ansible更新为最新版本后,我的剧本就没有问题了。 Hopefully this helps someone else. 希望这可以帮助其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM