Automated Operational Dimension Tool ansible installation configuration steps

Source: Internet
Author: User
Tags gmp ssh ibm developerworks

First, Introduction


Ansible is a configuration management and application Deployment tool that functions like the current Industry configuration management tool Chef,puppet,saltstack. Ansible is developed through the Python language. The Ansible platform, created by Michael DeHaan, is also the author of a well-known software cobbler and Func. The first version of Ansible was released in February 2012. Ansible defaults to managing the machine through the SSH protocol, so ansible does not need to install the client program on the server. All you need to do is install Ansible on a single server, and after Ansible is installed, you can manage to control other servers. You do not need to configure the database for it, and Ansible does not start or remain running in a daemons manner. Ansible can achieve the following goals:

Automating Deployment applications
Automated Management configuration
Continuous delivery of automation
Automated (AWS) cloud service management.
According to Ansible official information, the current users of Ansible: Evernote, Rackspace, NASA, Atlassian, Twitter and so on.

Note: The above introductions are from IBM Developerworks China.

Second, the installation of ansible

1, yum source installation

Take CentOS as an example, the default in the source is not ansible, but in Fedora Epel Source has ansible, after configuration Epel source, you can directly install through the Yum. Here 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, the Apt-get installation can be done by increasing the PPA source, 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, the source code installation

Source code installation needs python2.6 above version, its dependent module Paramiko, Pyyaml, JINJA2, Httplib2, Simplejson, Pycrypto module, the above module can be installed through the PIP or Easy_install, However, this part of the reference is the source code installation, mainly for the situation can not be on the extranet, through the PyPI site to search the above package, downloaded through the Python setup.py install to install.

Finally through the GitHub or PyPI download Ansible source package, through the Python setup.py install installation can. Because of the relatively simple installation process, here skip, mainly describes the installation, you may encounter problems.

A, when installing Pyyaml, the error is as follows:

# python setup.py Install
Libyaml is not found or a compiler error:forcing--without-libyaml
(if Libyaml is installed correctly, your may need to
Specify the option--include-dirs or uncomment and
Modify the parameter Include_dirs in setup.cfg)
Running Install_lib
Running Install_egg_info
Removing/usr/lib64/python2.6/site-packages/pyyaml-3.11-py2.6.egg-info
Writing/usr/lib64/python2.6/site-packages/pyyaml-3.11-py2.6.egg-info
In a centos6.8 system, it can be resolved by Yum-y install Libyaml package, or by providing the package from an ISO file and installing it through RPM-IVH.

b, after installation ansible is, the error is as follows:

[Root@361way.com ansible-1.9.1]# Ansible-h
Traceback (most recent call last):
File "/usr/local/src/ansible-devel/bin/ansible", line <module>
From Ansible.runner import runner
File "/usr/local/src/ansible-devel/lib/ansible/runner/__init__.py", line <module>
From Crypto.random import atfork
File "/usr/lib64/python2.6/site-packages/crypto/random/__init__.py", line <module>
From Crypto.random import _userfriendlyrng
File "/usr/lib64/python2.6/site-packages/crypto/random/_userfriendlyrng.py", line <module>
From Crypto.Random.Fortuna import Fortunaaccumulator
File "/usr/lib64/python2.6/site-packages/crypto/random/fortuna/fortunaaccumulator.py", line <module>
Import Fortunagenerator
File "/usr/lib64/python2.6/site-packages/crypto/random/fortuna/fortunagenerator.py", line <module>
From Crypto.Util.number import Ceil_shift, exact_log2, Exact_div
File "/usr/lib64/python2.6/site-packages/crypto/util/number.py", line <module>
If _fastmath is not-None and not _fastmath. Have_decl_mpz_powm_sec:
Attributeerror: ' have_decl_mpz_powm_sec ' of ' module ' object has no attribute
Import Paramiko package, the error is as follows:

>>> Import Paramiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/paramiko/__init__.py", line-in <module>
From transport import Randpool, securityoptions, transport
File "/usr/lib/python2.6/site-packages/paramiko/transport.py", line <module>
From Paramiko import util
File "/usr/lib/python2.6/site-packages/paramiko/util.py", line <module>
From Paramiko.common Import *
File "/usr/lib/python2.6/site-packages/paramiko/common.py", line, in <module>
From RNG import Stronglockingrandompool
File "/usr/lib/python2.6/site-packages/paramiko/rng.py", line <module>
From Crypto.Util.randpool import Randompool as _randompool
File "/usr/lib64/python2.6/site-packages/crypto/util/randpool.py", line <module>
Import Crypto.random
File "/usr/lib64/python2.6/site-packages/crypto/random/__init__.py", line <module>
From Crypto.random import _userfriendlyrng
File "/usr/lib64/python2.6/site-packages/crypto/random/_userfriendlyrng.py", line <module>
From Crypto.Random.Fortuna import Fortunaaccumulator
File "/usr/lib64/python2.6/site-packages/crypto/random/fortuna/fortunaaccumulator.py", line <module>
Import Fortunagenerator
File "/usr/lib64/python2.6/site-packages/crypto/random/fortuna/fortunagenerator.py", line <module>
From Crypto.Util.number import Ceil_shift, exact_log2, Exact_div
File "/usr/lib64/python2.6/site-packages/crypto/util/number.py", line <module>
If _fastmath is not-None and not _fastmath. Have_decl_mpz_powm_sec:
Attributeerror: ' have_decl_mpz_powm_sec ' of ' module ' object has no attribute
After searching on the Internet to confirm that the GMP version of the Pycrypto package is not correct, it can be verified by the following steps:

[root@361way.com pycrypto-2.6.1]# python setup.py build
Running Build
Running Build_py
Running Build_ext
Running Build_configure
Warning:gmp or Mpir library not found; Not building Crypto.publickey._fastmath.

Workaround:

When you open the/usr/lib64/python2.6/site-packages/crypto/util/number.py file, you can see the annotation instructions on line 56, which requires LIBGMP to be above V5 version. The existing version of the system is 4.1.4, the following two lines are temporarily commented out, ansible normal execution.

If _fastmath is not-None and not _fastmath. Have_decl_mpz_powm_sec:
_warn ("Not using MPZ_POWM_SEC. Should rebuild using LIBGMP >= 5 to avoid timing attack. ", vulnerability)
However, this approach is only temporary, and a better way is to upgrade the LIBGMP to a compliant version.

c. Wrong implementation times

[root@361way.com src]# ansible test-m raw-a ' uptime '
10.212.52.14 | FAILED => to use the ' SSH ' connection type with passwords, and must install the Sshpass program
10.212.52.16 | FAILED => to use the ' SSH ' connection type with passwords, and must install the Sshpass program
Install the Sshpass program. Not in the default source, I choose to download the installation directly from the Sohu source.

Iii. configuration and verification of Ansible

Here to PyPI download the source code has a examles package, you can use the sample file as the default configuration, specifically 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 you use the default sample configuration file, edit the/etc/ansible/hosts file to verify that the 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.com
10.212.52.14 Ansible_ssh_user=root ansible_ssh_pass=abc123
10.212.52.16 Ansible_ssh_user=root ansible_ssh_pass=91it.org
The above configuration, I configured a test group, the group has three hosts, three are using root authentication, the three passwords are 361way.com, abc123, 91it.org.

Note: The following user and password items are not necessary, in the case of configuring key authentication, do not use the password can also be directly operated. If you do not use key, you can also ask for a manual input password before the operation via the-K parameter ansible.

[root@361way.com ~]# ansible test-a ' uptime '
10.212.52.252 | Success | Rc=0 >>
18:01pm up 3:24, 3 users, load average:0.39, 0.38, 0.35
10.212.52.16 | Success | Rc=0 >>
18:09pm up 329 days 1:01, 2 users, load average:0.08, 0.03, 0.05
10.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 that proves the installation is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.