问题描述
---
- name: Adding the host server
hosts: localhost
vars_prompt:
- name: "Server"
prompt: "Server IP"
private: no
- name: "User"
prompt: "Username"
default: "Ubuntu"
private: no
- name: "Passwd"
prompt: "Password"
private: yes
encrypt: "sha512_crypt"
- name: "IdFile"
prompt: "Identity file path(~/.ssh/id_rsa.pub)"
private: no
when: Passwd is undefined
- name: "cmd"
prompt: "Which command you want to run 1.ls -l 2.Top 3.uptime."
private: |-
no
tasks:
- name: Add host server
add_host:
name: "{{ Server }}"
ansible_ssh_user: "{{ User }}"
ansible_ssh_private_key_file: "{{ IdFile }}"
when: IdFile is defined
- name: Add host server
add_host:
name: "{{ Server }}"
ansible_ssh_user: "{{ User }}"
ansible_ssh_pass: "{{ Passwd }}"
when: Passwd is defined
- name: check OS name
shell: uname -a
delegate_to: "{{ Server }}"
- hosts: "{{ Server }}"
#below are for testing only.
tasks:
- name: Execute a command using the shell module
become: true
#become_user: root
shell: uname -a
- name: check OS name
shell: uname -a
delegate_to: "{{ Server }}"
这是以下错误: 致命的:[本地主机]:不可更改! => {“更改”:false,“ msg”:“身份验证失败。”,“无法访问”:true}
有人可以检查一下上面的代码并提出更改建议吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)