我必须使用Ansible模块来编辑/ etc/ssh/sshd_config文件 - 每次创建新用户时我都想在这两行中追加它:
AllowUsers root osadmin <new_user>
AllowGroups root staff <new_group>
Run Code Online (Sandbox Code Playgroud)
此时我正在使用shell模块执行sed命令,但如果可能的话,我想使用lineinfile
- shell: "sed -i '/^Allow/ s/$/ {{ user_name }}/' /etc/ssh/sshd_config"
Run Code Online (Sandbox Code Playgroud)
任何建议都将得到真诚的感谢.