默认就有,添加sudo比较方便,,详细查看ansible-doc lineinfile
vi 1.yml
---
- hosts: xq
vars:
user: xq_zhengmingyi
password: "xxxx"
remote_user: root
tasks:
- name: Add user {{ user }}
user: name={{user}} password={{ password }}
- name: Config /etc/sudoers
lineinfile: dest=/etc/sudoers state=present line='{{item}}' validate='visudo -cf %s'
with_items:
- "{{ user }} ALL=(ALL) ALL"
比较方便
阅读(2488) | 评论(0) | 转发(0) |