小编miw*_*iwa的帖子

在ansible中为linux用户设置幂等密码

在尝试使用模块管理用户密码时,user每次执行 playbook 时都会收到密码更改通知,并且此行为不依赖于 ansible 版本(在所有主要 2.0 - 2.5 上测试)、目标发行版(在稳定的 CentOS 上测试, Debian 和 Ubuntu)或update_password选项。

- name: This is in vault in real playbook of course
  set_fact:
    testuser_password : '123456'

- name: Manage test user
  user:
    name: testuser
    uid: 1001
    state: present
    password: "{{ testuser_password |password_hash('sha512')}}"
Run Code Online (Sandbox Code Playgroud)

名为“管理测试用户”的任务始终标记为已更改。为了避免这种情况,我使用了这种奇怪的结构

- name: This is in vault in real playbook of course
  set_fact:
    testuser_password : '123456'

- name: Check if user exists
  shell: "getent shadow testuser | awk -F: '{ print …
Run Code Online (Sandbox Code Playgroud)

ansible

4
推荐指数
1
解决办法
2796
查看次数

标签 统计

ansible ×1