In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to deploy automated operation and maintenance tool ansible in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Ansible is a new automatic operation and maintenance tool. Based on Python development, it integrates the advantages of many operation and maintenance tools (puppet, chef, func, fabric), and realizes the functions of batch system configuration, batch program deployment, batch running commands and so on.
Installation of Ansible
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 ansible
2. 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 ansible
3. Source code installation requires python2.6 or above, which depends on modules paramiko, PyYAML, Jinja2, httplib2, simplejson, and pycrypto modules. The above modules can be installed through pip or easy_install. However, since this section refers to source code installation, you can search for the above packages through the pypi site and install them through python setup.py install after downloading.
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
On centos6.8 systems, 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'
The error in import paramiko package 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'
After searching on the Internet, it is confirmed that the wrong version of GMP that the pycrypto package depends on during installation can be verified by the following steps:
[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 approach is only temporary, and a better way is 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
Install the sshpass program. It's not in the default source, so I choose to download and install it directly from the sohu source.
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] 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
In the above configuration, 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.
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
After executing the above instructions, there is a result output, which proves that the installation is successful.
The above is all the contents of the article "how to deploy automatic operation and maintenance tool ansible in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.