Install and use the automation tools in CentOS 7 Ansible

Source: Internet
Author: User

Ansible is a free, 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 CentOS 7 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

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

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

Step two: Install Ansible with Yum

[email protected] ~]# Yum install ansible

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-m ping ' test-servers '

Execute shell command

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

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

2 : Check the kernel version of the node

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

3 : Add user to Node

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

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

4 : Redirect output to file

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

Free pick up brother even it education original Linux OPS engineer video/Detailed Linux tutorials, details Inquiry official website customer Service: http://www.itxdl.cn/linux/

or hooking up with Q2430675018.

Welcome to the Linux Communication Group 478068715

Install and use the 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.