ansible 安装


需要安装些什么 

Ansible 默认通过SSH协议管理机器 

安装Ansible之后,不需要启动或运行一个后台进程,或是添加一个数据库,只要一台电脑上安装好,

就可以通过这台电脑管理一组远程的机器。在远程被管理的机器上,不需要安装运行任何软件,因此升级Ansible版本不会有太多问题。

选择哪一个版本?

对管理主机的要求

node2:/root#ansible --version
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/python27/lib/python2.7/site-packages/ansible
  executable location = /usr/local/python27/bin/ansible
  python version = 2.7.3 (default, Mar 30 2017, 20:15:12) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
node2:/root#

对托管节点的要求:

通常我们使用ssh与托管节点通信,默认使用sftp.如果sftp不可用,可以在ansible.cfg配置文件中配置成scp的方式


安装管理主机:

通过 Pip 安装最新发布版本
Ansible可通过 “pip” 安装(安装和管理Python包的工具),若你还没有安装 pip,可执行如下命令安装:

$ sudo easy_install pip
然后安装Ansible:

$ sudo pip install ansible
如果你是在 OS X Mavericks 上安装,编译器可能或告警或报错,可通过如下设置避免这种情况:

$ sudo CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install ansible
使用 virtualenv 的读者可通过 virtualenv 安装 Ansible, 然而我们建议不用这样做,直接在全局安装 Ansible.不要使用 easy_install 直接安装 ansible.


node2:/root#pip -V
pip 9.0.1 from /usr/local/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
node2:/root#


node2:/root#easy_install -U  pip 
Searching for pip
Reading https://pypi.python.org/simple/pip/
Downloading https://files.pythonhosted.org/packages/69/81/52b68d0a4de760a2f1979b0931ba7889202f302072cc7a0d614211bc7579/pip-18.0.tar.gz#sha256=a0e11645ee37c90b40c46d607070c4fd583e2cd46231b1c06e389c5e814eed76




Best match: pip 18.0
Processing pip-18.0.tar.gz
Writing /tmp/easy_install-s6uSZe/pip-18.0/setup.cfg
Running pip-18.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-s6uSZe/pip-18.0/egg-dist-tmp-3teDps
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'appveyor.yml'
warning: no previously-included files found matching 'src/pip/_vendor/six'
warning: no previously-included files found matching 'src/pip/_vendor/six/moves'
warning: no previously-included files matching '*.pyi' found under directory 'src/pip/_vendor'
no previously-included directories found matching '.github'
no previously-included directories found matching 'docs/build'
no previously-included directories found matching 'news'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
no previously-included directories found matching 'tools'
creating /usr/local/python27/lib/python2.7/site-packages/pip-18.0-py2.7.egg
Extracting pip-18.0-py2.7.egg to /usr/local/python27/lib/python2.7/site-packages
Removing pip 9.0.1 from easy-install.pth file
Adding pip 18.0 to easy-install.pth file
Installing pip script to /usr/local/python27/bin
Installing pip2.7 script to /usr/local/python27/bin
Installing pip2 script to /usr/local/python27/bin

Installed /usr/local/python27/lib/python2.7/site-packages/pip-18.0-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip



node2:/root#pip -V
pip 18.0 from /usr/local/python27/lib/python2.7/site-packages/pip-18.0-py2.7.egg/pip (python 2.7)
You have new mail in /var/spool/mail/root



node2:/root#ansible --version
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/python27/lib/python2.7/site-packages/ansible
  executable location = /usr/local/python27/bin/ansible
  python version = 2.7.3 (default, Mar 30 2017, 20:15:12) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
node2:/root#pip install ansible
Requirement already satisfied: ansible in /usr/local/python27/lib/python2.7/site-packages (2.4.2.0)
Requirement already satisfied: jinja2 in /usr/local/python27/lib/python2.7/site-packages (from ansible) (2.10)
Requirement already satisfied: PyYAML in /usr/local/python27/lib/python2.7/site-packages (from ansible) (3.12)
Requirement already satisfied: paramiko in /usr/local/python27/lib/python2.7/site-packages (from ansible) (2.4.0)
Requirement already satisfied: cryptography in /usr/local/python27/lib/python2.7/site-packages (from ansible) (2.1.4)
Requirement already satisfied: setuptools in /usr/local/python27/lib/python2.7/site-packages/setuptools-33.1.1-py2.7.egg (from ansible) (33.1.1)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/python27/lib/python2.7/site-packages (from jinja2->ansible) (1.0)
Requirement already satisfied: pynacl>=1.0.1 in /usr/local/python27/lib/python2.7/site-packages (from paramiko->ansible) (1.2.1)
Requirement already satisfied: pyasn1>=0.1.7 in /usr/local/python27/lib/python2.7/site-packages (from paramiko->ansible) (0.4.2)
Requirement already satisfied: bcrypt>=3.1.3 in /usr/local/python27/lib/python2.7/site-packages (from paramiko->ansible) (3.1.4)
Requirement already satisfied: idna>=2.1 in /usr/local/python27/lib/python2.7/site-packages (from cryptography->ansible) (2.6)
Requirement already satisfied: cffi>=1.7; platform_python_implementation != "PyPy" in /usr/local/python27/lib/python2.7/site-packages (from cryptography->ansible) (1.11.2)
Requirement already satisfied: enum34; python_version < "3" in /usr/local/python27/lib/python2.7/site-packages (from cryptography->ansible) (1.1.6)
Requirement already satisfied: six>=1.4.1 in /usr/local/python27/lib/python2.7/site-packages (from cryptography->ansible) (1.11.0)
Requirement already satisfied: asn1crypto>=0.21.0 in /usr/local/python27/lib/python2.7/site-packages (from cryptography->ansible) (0.24.0)
Requirement already satisfied: ipaddress; python_version < "3" in /usr/local/python27/lib/python2.7/site-packages (from cryptography->ansible) (1.0.19)
Requirement already satisfied: pycparser in /usr/local/python27/lib/python2.7/site-packages (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography->ansible) (2.18)
node2:/root#

















































猜你喜欢

转载自blog.csdn.net/zhaoyangjian724/article/details/81740421