1.ansible Missing sudo password
1.1尝试使用该选项-kK
。它将提示输入密码。
$ ansible-playbook mail.yml -kK
SSH password:
BECOME password[defaults to SSH password]:
- -k,--ask-pass:询问连接密码
- -K,--ask-become-pass:询问特权升级密码
1.2 You can specificy the sudo password when running the Ansible playbook:
ansible-playbook playbook.yml -i inventory.ini --extra-vars "ansible_sudo_pass=yourPassword"
1.3将此添加到您的/ etc / sudoers文件
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
username-u-want-to-allow ALL=(ALL) NOPASSWD: ALL
2. ansible出现Failed to connect to the host via ssh
2.1 公钥验证出现问题一般检查selinux是否关闭,还有就是authorized_keys权限是否为600
3.报错
Permissions 0755 for '/root/ansible/cers/devops_id_rs' are too open.\r\nIt is required that your private key files are NOT accessible by others.\r\nThis private key will be ignored
Keys need to be only readable by you:
chmod 400 ~/.ssh/id_rsa
If Keys need to be read-writable by you:
chmod 600 ~/.ssh/id_rsa
https://stackoverflow.com/questions/9270734/ssh-permissions-are-too-open-error
4.Failed to connect to the host via ssh: Host key verification failed
In your ansible config file /var/lib/jenkins/workspace/FPipeline/ansible.cfg
add below line and test it again.
[defaults]
host_key_checking = False
5.