Install and deploy Ansible in Linux

Source: Internet
Author: User
Tags saltstack

Install and deploy Ansible in Linux

Introduction
Ansible is a batch Deployment Tool. Currently, most of the three open source centralized management tools used by O & M personnel are puppet, saltstack, and ansible. Each has its own advantages and disadvantages, both saltstack and ansible are developed in python. Ansible actually provides only one framework. It can only work based on many other python modules. Therefore, you need to install many other dependent packages when installing ansible.

One of the advantages is that users can develop their own modules and use them in it. The second advantage is that you do not need to install the agent on the client. when updating the agent, you only need to perform an update on the operating machine. The third advantage is that batch task execution can be written as scripts without being distributed to remote execution.


Body
Note: It is strongly recommended that you upgrade python to version 2.6 or later. Otherwise, an error may occur during running or some features may not exist, and an error may be reported during compilation and installation of other packages due to compatibility issues.

(1) python2.7 Installation
Https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
# Tar xvzf Python-2.7.8.tgz
# Cd Python-2.7.8
#./Configure -- prefix =/usr/local
# Make
# Make install


# Copy the python header file to the standard directory to avoid missing the required header file when compiling ansible
# Cd/usr/local/include/python2.7
# Cp-a./*/usr/local/include/


# Back up the old version of python and link the new version of python with symbols
# Cd/usr/bin
# Mv python. old
# Ln-s/usr/local/bin/python2.7/usr/local/bin/python
# Rm-f/usr/bin/python & cp/usr/local/bin/python2.7/usr/bin/python


# Modify the yum script to point it to the old version of python, so that it cannot run
# Vim/usr/bin/yum
#! /Usr/bin/python --> #! /Usr/bin/python2.4


(2) install the setuptools Module
Https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz
# Tar xvzf setuptools-7.0.tar.gz
# Cd setuptools-7.0
# Python setup. py install
After setuptools is installed, you can use the easy_install tool to install the following python module. However, my computer is a virtual machine and the configuration is too low, so it is basically impossible to install it, so I had to download the package one by one and then install it.
(3) install the pycrypto Module
Https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz
# Tar xvzf pycrypto-2.6.1.tar.gz
# Cd pycrypto-2.6.1
# Python setup. py install


(4) install the PyYAML Module
Http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
# Tar xvzf yaml-0.1.5.tar.gz
# Cd yaml-0.1.5
#./Configure -- prefix =/usr/local
# Make -- jobs = 'grep processor/proc/cpuinfo | wc-l'
# Make install


Https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz
# Tar xvzf PyYAML-3.11.tar.gz
# Cd PyYAML-3.11
# Python setup. py install


(5) Jinja2 module Installation
Https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.9.3.tar.gz
# Tar xvzf MarkupSafe-0.9.3.tar.gz
# Cd MarkupSafe-0.9.3
# Python setup. py install


Https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
# Tar xvzf Jinja2-2.7.3.tar.gz
# Cd Jinja2-2.7.3
# Python setup. py install


(6) paramiko module Installation
Https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.11.tar.gz
# Tar xvzf ecdsa-0.11.tar.gz
# Cd ecdsa-0.11
# Python setup. py install


Https://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.1.tar.gz
# Tar xvzf paramiko-1.15.1.tar.gz
# Cd paramiko-1.15.1
# Python setup. py install


(7) simplejson module Installation
Https://pypi.python.org/packages/source/s/simplejson/simplejson-3.6.5.tar.gz
# Tar xvzf simplejson-3.6.5.tar.gz
# Cd simplejson-3.6.5
# Python setup. py install


(8) ansible Installation
Https://github.com/ansible/ansible/archive/v1.7.2.tar.gz
# Tar xvzf ansible-1.7.2.tar.gz
# Cd ansible-1.7.2
# Python setup. py install


(9) SSH key-free login settings
# Generate a public/private key
# Ssh-keygen-t rsa-p''
# Write a trusted file (distribute/root/. ssh/id_rsa_storm1.pub to other servers and execute the following command on all servers ):
# Cat/root/. ssh/id_rsa_storm1.pub>/root/. ssh/authorized_keys
# Chmod 600/root/. ssh/authorized_keys


(10) copy and generate the ansible configuration file
A configuration file/etc/ansible. cfg
# Mkdir-p/etc/ansible
# Ansible-1.7.2/examples/ansible. cfg/etc/ansible/
B configuration file/etc/ansible/hosts
# Vim/etc/ansible/hosts
[Test]
192.168.110.20
192.168.110.30


Test
# Ansible test-m command-a 'uptime'
# Used to test the running status of a remote host
# Ansible test-m ping
See all parameters
Ansible-doc-l

Functions and usage of Ansible and Docker

Ansible batch build LAMP Environment

Ansible: a configuration management and IT automation tool

Ansible details: click here
Ansible: click here

This article permanently updates the link address:

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.