【问题标题】:Ansible playbook passwordAnsible 剧本密码
【发布时间】:2022-06-10 19:01:22
【问题描述】:

新的 ansible 用户

这是我的剧本。

---
- name: Creating Local User Account on RHEL Systems.
  hosts: hapansible05
  become: true

  vars:
    passwd: WSXcde1234


  tasks:
  - name: Creating Local User
    user:
      name: svc_cldscp
      password:  "{{ passwd | password_hash('sha512') }}"
      comment: svc_cldscp-ServiceAcct
      shell: /bin/bash

在 RHEL 服务器上不断收到此消息

[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

PLAY [Creating Local User Account on RHEL Systems.] ********************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************
ok: [hapansible05]

TASK [Creating Local User] ***********************************************************************************************************************************
****fatal: [hapansible05]: FAILED! => {"changed": false, "msg": "usermod: user 'svc_cldscp' does not exist in /etc/passwd\n", "name": "svc_cldscp", "rc": 6}******

PLAY RECAP *************************************************************************************************************************************************
hapansible05               : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

【问题讨论】:

  • 您的密码不是问题,而是用户不存在

标签: ansible


【解决方案1】:

通过user 模块创建和配置本地用户的working practice 示例,带有Hashing and encrypting strings and passwords 的过滤器

  vars:
  
    pwd: "WSXcde1234"

  tasks:

  - name: Create and configure user in local system
    user:
      name: "svc_cldscp"
      password: "{{ pwd | password_hash('sha512') }}"
      system: false          # Defaults to no
      createhome: true       # Defaults to yes
      uid: '1234'            # 
      group: '1234'          # Need to exist before
      shell: /bin/bash       # Defaults to /bin/bash
      comment: "Service Account"
      state: present

【讨论】:

    猜你喜欢
    • 2020-05-08
    • 1970-01-01
    • 2022-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-24
    相关资源
    最近更新 更多