In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to install Ansible under Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install Ansible under Linux.
1. Yum source installation
Take centos as an example. By default, there is no ansible in the source, but there is ansible in the fedora epel source. After configuring the epel source, you can install it directly through yum. Take centos6.8 as an example:
# yum install http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm# yum install ansible2, apt-get installation
In ubuntu and its derivative versions, you can install apt-get by adding ppa sources as follows:
$sudo apt-get install software-properties-common$ sudo apt-add-repository ppa:ansible/ansible$ sudo apt-get update$ sudo apt-get install ansible3, source code installation source code installation requires python2.6 or above, which depends on modules such as paramiko, PyYAML, Jinja2, httplib2, simplejson and pycrypto. The above modules can be installed through pip or easy_install. However, since this section refers to source code installation, it is mainly aimed at the case that the external network cannot be accessed. You can search for the above packages through the pypi site, download them and install them via python setup.py install.
Finally, download the ansible source code package on github or pypi and install it through python setup.py install. As the installation process is relatively simple, I will skip it here and mainly introduce the problems that may be encountered after installation.
A. When installing PyYAML, the error is as follows:
# python setup.py installlibyaml is not found or a compiler error: forcing-- without-libyaml (if libyaml is installed correctly, you may need tospecify the option-- include-dirs or uncomment andmodify the parameter include_dirs in setup.cfg) running install_librunning install_egg_infoRemoving / usr/lib64/python2.6/site-packages/PyYAML-3.11-py2.6.egg-infoWriting / usr/lib64/python2.6/site-packages/PyYAML-3.11-py2.6.egg-info in centos6.8 system It can be solved through the yum-y install libyaml package, or it can be provided from the ISO file and installed through rpm-ivh.
B. After installing ansible, the error is as follows:
[root@361way.com ansible-1.9.1] # ansible- hTraceback (most recent call last): File "/ usr/local/src/ansible-devel/bin/ansible", line 36, infrom ansible.runner import RunnerFile "/ usr/local/src/ansible-devel/lib/ansible/runner/__init__.py", line 62, infrom Crypto.Random import atforkFile "/ usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 29 Infrom Crypto.Random import _ UserFriendlyRNGFile "/ usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, infrom Crypto.Random.Fortuna import FortunaAccumulatorFile "/ usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, inimport FortunaGeneratorFile "/ usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 34, infrom Crypto.Util.number import ceil_shift, exact_log2 Exact_divFile "/ usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, inif _ fastmath is not None and not _ fastmath.HAVE_DECL_MPZ_POWM_SEC:AttributeError: 'module' object has no attribute' HAVE_DECL_MPZ_POWM_SEC'import paramiko package The error is as follows:
> import paramikoTraceback (most recent call last): File "", line 1, inFile "/ usr/lib/python2.6/site-packages/paramiko/__init__.py", line 69, infrom transport import randpool, SecurityOptions, TransportFile "/ usr/lib/python2.6/site-packages/paramiko/transport.py", line 32, infrom paramiko import utilFile "/ usr/lib/python2.6/site-packages/paramiko/util.py", line 32 Infrom paramiko.common import * File "/ usr/lib/python2.6/site-packages/paramiko/common.py", line 98, infrom rng import StrongLockingRandomPoolFile "/ usr/lib/python2.6/site-packages/paramiko/rng.py", line 22, infrom Crypto.Util.randpool import RandomPool as _ RandomPoolFile "/ usr/lib64/python2.6/site-packages/Crypto/Util/randpool.py", line 30, inimport Crypto.RandomFile "/ usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 29 Infrom Crypto.Random import _ UserFriendlyRNGFile "/ usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, infrom Crypto.Random.Fortuna import FortunaAccumulatorFile "/ usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, inimport FortunaGeneratorFile "/ usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 34, infrom Crypto.Util.number import ceil_shift, exact_log2 Exact_divFile "/ usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, inif _ fastmath is not None and not _ fastmath.HAVE_DECL_MPZ_POWM_SEC:AttributeError: 'module' object has no attribute' HAVE_DECL_MPZ_POWM_SEC' is searched online Confirm that the GMP version you rely on when installing the pycrypto package is incorrect. You can verify it by following the steps below:
[root@361way.com pycrypto-2.6.1] # python setup.py buildrunning buildrunning build_pyrunning build_extrunning build_configurewarning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath. Solution:
When you open the / usr/lib64/python2.6/site-packages/Crypto/Util/number.py file, you can see the comment on line 56 that requires libgmp to be v5 or above. While the current version of the system is 4.1.4, comment out the following two lines temporarily, and the Ansible executes normally.
If _ fastmath is not None and not _ fastmath.HAVE_DECL_MPZ_POWM_SEC:_warn ("Not using mpz_powm_sec. You should rebuild using libgmp > = 5 to avoid timing attackvulnerability.", PowmInsecureWarning) however, this method is only temporarily resolved, and it is better to upgrade libgmp to a version that meets the requirements.
C. Executive Times error
[root@361way.com src] # ansible test-m raw-a 'uptime'10.212.52.14 | FAILED = > to use the' ssh' connection type with passwords, you must install the sshpass program10.212.52.16 | FAILED = > to use the 'ssh' connection type with passwords, you must install the sshpass program installs the sshpass program. It's not in the default source, so I choose to download and install it directly from the sohu source.
III. Configuration and verification of Ansible
Here, there is an examles package in the source code downloaded on pypi. You can use this sample file as the default configuration, as follows:
[root@361way.com ansible-1.9.1] # mkdir-p / etc/ansible [root@361way.com ansible-1.9.1] # cp-rp examples/* / etc/ansible/ [root@361way.com ansible-1.9.1] # cd / etc/ansible/ after using the default sample configuration file, edit the / etc/ansible/hosts file to verify that ansible is available in the following ways:
[root@361way.com ~] # cat / etc/ansible/ hosts [test] in the configuration above 10.212.52.252 ansible_ssh_user=root ansible_ssh_pass=361way.com10.212.52.14 ansible_ssh_user=root ansible_ssh_pass=abc12310.212.52.16 ansible_ssh_user=root ansible_ssh_pass=91it.org, I have configured a test group. There are three hosts under this group, all of which are verified by root. The passwords of the three are 361way.com, abc123 and 91it.org, respectively.
Note: the following users and password entries are not required. In the case of configuring key authentication, you can operate directly without a password. If you are not using key, you can also ask for a manual password before the operation with the-k parameter in ansible.
[root@361way.com ~] # ansible test-a 'uptime'10.212.52.252 | success | rc=0 > > 18:01pm up 21 days 3:24, 3 users, load average: 0.39,0.38,0.3510.212.52.16 | success | rc=0 > > 18:09pm up 329 days 1:01, 2 users, load average: 0.08,0.03,0.0510.212.52.14 | success | rc=0 > > 18:08pm up 329 days 0:23, 2 users, load average: 0.06,0.06,0.05 to this point I believe you have a deeper understanding of "how to install Ansible under Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.