在 ubuntu 上安装 ansible

在 ubuntu 上安装 ansible

我正在按照此文档安装 ansible: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-ansible-on-ubuntu-14-04

我尝试将 ansible 添加到我的 ubuntu 存储库列表中,但发生了以下情况:

me@mydev:~/Documents$ sudo apt-add-repository ppa:ansible/ansible
Cannot add PPA: 'ppa:~ansible/ubuntu/ansible'.
ERROR: '~ansible' user or team does not exist.
me@mydev:~/Documents$ 

我也尝试过克隆 repo(按照以下说明操作:http://docs.ansible.com/ansible/intro_installation.html)但结果如下:

me@mydev:~/Documents/ansible$ git clone git://github.com/ansible/ansible.git --recursive
Cloning into 'ansible'...
fatal: unable to connect to github.com:
github.com[0: 192.30.252.131]: errno=Connection timed out

me@mydev:~/Documents/ansible$ ping 192.30.252.131
PING 192.30.252.131 (192.30.252.131) 56(84) bytes of data.
64 bytes from 192.30.252.131: icmp_seq=1 ttl=56 time=23.4 ms
64 bytes from 192.30.252.131: icmp_seq=2 ttl=56 time=23.5 ms
^C
--- 192.30.252.131 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 23.466/23.511/23.557/0.159 ms
me@mydev:~/Documents/ansible$ 

如您所见,我收到连接超时错误。我尝试 ping 服务器,它似乎能够与我的盒子通信。不知道我还能尝试什么。

谢谢。

编辑1

我使用了代理。我运行了此命令来识别我的代理服务器:

me@mydev:~/Documents/ansible$ export http_proxy=http://10.20.30.40:8080

然后进行测试,我运行:

sudo apt-get update

并且运行良好。

答案1

我将-E开关添加到命令中sudo,它起作用了。尝试:

sudo -E apt-add-repository ppa:ansible/ansible

这会移动(或复制)您的环境变量,包括http_proxysudo 上下文。

答案2

要么是启动板出了问题,要么是连接出了问题。它毫无问题地添加了:

$sudo apt-add-repository ppa:ansible/ansible
[sudo] password for rinzwind: 
 Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.

http://ansible.com/
 More info: https://launchpad.net/~ansible/+archive/ubuntu/ansible
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmpjhg3_1oq/secring.gpg' created
gpg: keyring `/tmp/tmpjhg3_1oq/pubring.gpg' created
gpg: requesting key 7BB9C367 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpjhg3_1oq/trustdb.gpg: trustdb created
gpg: key 7BB9C367: public key "Launchpad PPA for Ansible, Inc." imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

答案3

我遇到了同样的问题,以下方法对我有用。

# Make sure the source list directory exists
sudo mkdir -p /etc/apt/sources.list.d

# Adde the Ansible sources.
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu wily main" | sudo tee -a /etc/apt/sources.list.d/ansible.list
echo "deb-src http://ppa.launchpad.net/ansible/ansible/ubuntu wily main" | sudo tee -a /etc/apt/sources.list.d/ansible.list

# Install Ansible
sudo apt-get update
sudo apt-get install ansible

如果你使用的是其他版本,则可能需要更改wily以匹配。请查看Ansible Launchpad 页面为了那个原因。

答案4

您的代理和防火墙可能不允许您通过 SSH 连接。

您可以尝试 HTTPS,这是防火墙和代理最常用的协议:

git clone https://github.com/ansible/ansible.git --recursive 

相关内容