英文:
EERROR! conflicting action statements: user, update_password
问题
我决定写一个简单的脚本,但出了点问题,希望能得到你的帮助。
---
- name: 重置root密码,禁用用户
hosts: all
become: yes
become_user: root
vars:
vault_ansible_production_root_password: 123456
tasks:
- name: 重置root密码
user:
name: root
password: "{{vault_ansible_production_root_password}}"
update_password: always
- name: 禁用用户账户
user:
name: "*"
state: absent
uid: ">=1000"
remove: yes
错误!冲突的操作语句:user,update_password
错误出现在'/etc/an_script/work.yml'文件的第8行,第7列,但实际的语法问题可能在文件的其他位置。
有问题的行看起来是:
tasks:
- name: 重置root密码
^ 这里
PS
我刚刚开始,希望不要扔太多西红柿)))
英文:
I decided to write a simple script, but something went wrong, I hope for your help.
---
- name: Reset root password, disable users
hosts: all
become: yes
become_user: root
vars:
vault_ansible_production_root_password: 123456
tasks:
- name: Reset root password
user:
name: root
password: "{{vault_ansible_production_root_password}}"
update_password: always
- name: Disable user accounts
user:
name: "*"
state: absent
uid: ">=1000"
remove: yes
ERROR! conflicting action statements: user, update_password
The error appears to be in '/etc/an_script/work.yml': line 8, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: Reset root password
^ here
PS
I'm just starting, please don't throw too many tomatoes )))
答案1
得分: 0
缩进有误。
你的当前代码中,“user”和“update_password”位于相同的级别:Ansible 不知道调用哪个插件:冲突的语句。
请尝试这样做:
tasks:
- name: 重置 root 密码
user:
name: root
password: "{{vault_ansible_production_root_password}}"
update_password: always
请参阅文档,该模块的参数应该在模块的下一级:https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html
英文:
Indentation's wrong.
With your current code, "user" and "update_password" are at the same level: Ansible doesn't know which one is the plugin to call: conflicting statement
Try this instead:
tasks:
- name: Reset root password
user:
name: root
password: "{{vault_ansible_production_root_password}}"
update_password: always
See docs, params of that module should be one level down: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论