Install and use the automation tools in CentOS 7 Ansible

Source: Internet
Author: User

Ansible is a free and open source configuration and Automation tool developed for UNIX-like systems. It's written in Python, similar to chef and puppet, but there's a difference and the advantage is that we don't need to install any clients in the node. It uses SSH to communicate with the node.

In this article we will install and configure ansible on CentOS7, and try to manage two nodes.

Ansible Server –ansible.linuxtechi.com (192.168.1.15)

Node –192.168.1.9, 192.168.1.10

First step: Set up the Epel warehouse

Ansible The warehouse is not in the Yum repository by default, so we need to enable the Epel warehouse using the following command.

[Email protected] ~]# rpm-iuvhhttp://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

Step two: Install Ansible with Yum

[email protected] ~]# Yum installansible

After the installation is complete, check the ansible version:

[Email protected] ~]# ansible--version

Step three: Set up SSH keys for node authentication

Generate the key on the Ansible server and copy the public key into the node.

[Email protected] ~]# Ssh-keygen

Use the Ssh-copy-id command to replicate the Ansible public key into the node.

Fourth step: Define a list of nodes for Ansible

File/etc/ansible/hosts maintains a list of servers in Ansible.

[Email protected] ~]# vi/etc/ansible/hosts

[Test-servers]

192.168.1.9

192.168.1.10

Save and exit the file.

Fifth step: Try running the command on the ansible server

Use ping to check the connectivity of the ' test-servers ' or ansible nodes.

[Email protected] ~]# ansible-mping ' test-servers '

Execute shell command

1 : Check the run time of the Ansible node (uptime)

[Email protected] ~]# ansible-mcommand-a "uptime" ' test-servers '

2 : Check the kernel version of the node

[Email protected] ~]# ansible-mcommand-a "uname-r" ' test-servers '

3 : Add User to Node

[Email protected] ~]# ansible-mcommand-a "useradd mark" ' Test-servers '

[[email protected] ~]# ansible-mcommand-a "grep mark/etc/passwd" ' Test-servers '

4 : Redirect output to file

[Email protected] ~]# ansible-mcommand-a "df-th" ' test-servers ' >/tmp/command-output.txt

Free pick up Brother Lian IT Education Original Linux Maintenance Engineer video/Detailed Linux tutorials, details of the website customer service: http://www.lampbrother.net/linux/

or hooking up with Q2430675018.

Welcome to the Linux Communication Group 478068715


Installing and using automation tools in CentOS 7 Ansible

Related Article

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.