我使用CentOS-2nics-lb-cluster azure模板创build一个包含两个虚拟机的testing环境。 默认的pipe理员用户是用这个blob创build的。
"osProfile": { "computerName": "[concat('vm', copyIndex())]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]" },
天青vms上的sshdconfiguration包含
#RSAAuthentication yes #PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no PasswordAuthentication yes UsePAM yes
这似乎表明启用了PasswordAuthentication和PubkeyAuthentication。
我创build了自己的SSH密钥对,并将公钥复制到了两个azure色的虚拟机,这使我可以进行无密码的SSHlogin。
在我的情况下,我想使用可靠的脚本来安装到两个虚拟机上的数据库和Java应用程序。
包含我的基本库存清单文件
[all] test01vm0 ansible_host=test01.cloudapp.azure.com ansible_port=50000 test01vm1 ansible_host=test01.cloudapp.azure.com ansible_port=50001
在我的'groups_vars / all'文件中
# ssh access ansible_connection: ssh
在我的'ansible.cfg'文件中,我已经定义了'private_key_file'的值
[defaults] private_key_file=/home/pc/.ssh/id_rsa.pem
我有一个简单的任务,调用'成为'function
- name: create initial groups for the oracle user become: yes group: name={{ item }} state=present with_items: - "{{ oracle_group }}" - "{{ oracle_dba_group }}"
我执行的剧本为
ansible-playbook oracle.yml -vvv --step --sudo
在所有情况下
<test01.cloudapp.azure.com> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o Port=50000 -o 'IdentityFile="/home/pc/.ssh/id_rsa.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/home/pc/.ansible/cp/ansible-ssh-%h-%p-%r -tt test01.cloudapp.azure.com '/bin/sh -c '"'"'sudo -H -S -p "[sudo via ansible, key=kxsxqdhkkyuodnkvedsxmtozowbkltws] password: " -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-kxsxqdhkkyuodnkvedsxmtozowbkltws; LANG=en_IE.UTF-8 LC_ALL=en_IE.UTF-8 LC_MESSAGES=en_IE.UTF-8 /usr/bin/python /home/admin/.ansible/tmp/ansible-tmp-1453477752.42-279575317679267/group; rm -rf "/home/admin/.ansible/tmp/ansible-tmp-1453477752.42-279575317679267/" > /dev/null 2>&1'"'"'"'"'"'"'"'"''"'"'' fatal: [test01vm0]: FAILED! => {"failed": true, "msg": "ERROR! Timeout (12s) waiting for privilege escalation prompt: "}
有人可以帮忙,为什么这个“特权升级提示”错误发生? 我是否需要设置“ansible_ssh_user”值?