正如https://github.com/ansible/ansible/issues/7742
中所述如何在不指定--ask-sudo-pass
的情况下自动提示sudo密码?
答案 0 :(得分:5)
您可以使用vars_prompt并提示ansible_become_pass来解决此问题! (ansible_sudo_pass
用于较旧的ansible版本)
vars_prompt:
- name: "ansible_become_pass"
prompt: "Sudo password"
private: yes
答案 1 :(得分:0)
只需按照以下方式运行命令
1.ansible-playbook main.yml-要求成为
OR
它将自动要求远程主机的sudo密码
答案 2 :(得分:0)
以@ g-roggemans解决方案为基础,我能够在Debian 10(Ansible 2.9.9)上使用此解决方案:
using UnityEngine;
public class Script2 : MonoBehaviour
{
public GameObject Sprite;
void Start()
{
Generate();
}
public void Generate()
{
float width = Sprite.transform.lossyScale.x;
float height = Sprite.transform.lossyScale.y;
for (int y = 0; y <= 100; y += 10)
{
for (int x = 0; x <= 100; y += 10)
{
GameObject Square = Sprite;
Instantiate(Square, new Vector2(x * width, y * height), Quaternion.identity);
}
}
}
}
然后,我可以按以下方式运行我的剧本: ansible-playbook update_debian.yml 。关键是要添加:
---
- name: Sample Playbook: Patch Debian/Ubuntu based servers
gather_facts: false
hosts: group1, group2, group3
vars_prompt:
- name: "ansible_become_pass"
prompt: "Sudo password"
private: yes
become: yes
become_user: root
tasks:
- name: Update and upgrade apt packages
apt:
upgrade: yes
update_cache: yes
cache_valid_time: 86400 #one day in seconds