我是ansible的新手,这是我正在从事的项目。到目前为止,下面的代码是我放在一起的。此代码有效,但是密码未注册,当我使用创建的新用户登录时。它说验证失败。请帮助
---
- hosts: box432
gather_facts: false
vars_prompt:
- name: 'creating user with password'
prompt: 'enter password for user'
private: yes
encrypt: sha512_crypt
confirm: yes
salt_size: 7
tasks:
- pause: prompt="enter user name"
register: user_name
- name: "Print"
debug: msg="{{ user_name }}"
- name: updating user password
become: true
user:
name: "{{ user_name }}"
state: present
groups: stackflow
答案 0 :(得分:0)
首先,name
中的vars_prompt
不是任意注释,而是要设置的变量的名称,因此本节应为:
vars_prompt:
- name: "provided_password"
prompt: "enter password for user"
private: yes
encrypt: sha512_crypt
confirm: yes
salt_size: 7
第二,在您的代码中,您甚至没有尝试使用该变量。您应该在password
参数中提供值:
- name: updating user password
become: true
user:
name: "{{ user_name }}"
password: "{{ provided_password }}"
state: present
groups: stackflow