gpt4 book ai didi

ansible - 如何使用 Ansible 添加没有密码的用户和组?

转载 作者:行者123 更新时间:2023-12-01 21:13:11 24 4
gpt4 key购买 nike

我需要使用 Ansible 脚本添加没有密码的组和用户(nologin 用户)。

我执行以下命令:

$ansible-playbook deploy_nagios_client.yml -i hosts -e hosts=qa1-jetty -v

下面是main.yml

---

# Create Nagios User and Group
- name: Add group "nagios"
group: name=nagios
become: true

- name: Add user "nagios"
user: name=nagios groups=nagios password="" shell=/bin/bash append=yes comment="Nagios nologin User" state=present
become: true

Result

最佳答案

如果您想创建 nologin 用户,您应该将其指定给 shell 参数,如下所示:

  - name: Add user "nagios"  
user:
name: nagios
groups: nagios
shell: /sbin/nologin
create_home: no
append: yes
comment: "Nagios nologin User"
state: present
become: true

关于ansible - 如何使用 Ansible 添加没有密码的用户和组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36290485/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com