Ansible is a free, open-source configuration and automation tool developed for Unix-like systems. It is written in Python and is similar to Chef and Puppet. but there is a difference and advantage that we do not need to install any client in the node. It uses SSH to communicate with nodes. In this article, we will install and configure Ansible on CentOS7 and try to manage the two nodes. Ansible server & ndash; ansible. linuxtech
Ansible is a free, open-source configuration and automation tool developed for Unix-like systems. It is written in Python and is similar to Chef and Puppet. but there is a difference and advantage that we do not need to install any client in the node. It uses SSH to communicate with nodes.
In this article, we will install and configure Ansible on CentOS7 and try to manage the two nodes.
Ansible server-ansible.linuxtechi.com (192.168.1.15)
Node-192.168.1.9, 192.168.1.10
Step 1: Set the EPEL repository
The Ansible repository is not in the yum repository by default, so we need to use the following command to enable the epel repository.
[Root @ ansible ~] # Rpm-iUvhhttp: // dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
Step 2: Use yum to install Ansible
[Root @ ansible ~] # Yum installansible
After the installation is complete, check the ansible version:
[Root @ ansible ~] # Ansible -- version
Step 3: Set the SSH key for Node Authentication
Generate a key on the Ansible server and copy the public key to the node.
Root @ ansible ~] # Ssh-keygen
Use the ssh-copy-id command to copy the Ansible public key to the node.
Step 4: define a node list for Ansible
File/etc/ansible/hosts maintains the list of servers in Ansible.
[Root @ ansible ~] # Vi/etc/ansible/hosts
[Test-servers]
192.168.1.9
192.168.1.10
Save and exit the file.
Step 5: try to run the command on the Ansible server
Use ping to check the connectivity of the 'test-servers' or ansible node.
[Root @ ansible ~] # Ansible-mping 'test-servers'
Execute shell commands
1: Check the running time (uptime) of the Ansible node)
[Root @ ansible ~] # Ansible-mcommand-a "uptime" 'test-servers'
2: Check the kernel version of the node.
[Root @ ansible ~] # Ansible-mcommand-a "uname-r" 'test-servers'
3: Add users to nodes
[Root @ ansible ~] # Ansible-mcommand-a "useradd mark" 'test-servers'
[Root @ ansible ~] # Ansible-mcommand-a "grep mark/etc/passwd" 'test-servers'
4: Redirect output to file
[Root @ ansible ~] # Ansible-mcommand-a "df-Th" 'test-servers'>/tmp/command-output.txt
Receive free Brothers IT education original linux O & M engineers video/detailed linux tutorial, details consulting official website Customer Service: http://www.lampbrother.net/linux/
Or hook up Q2430675018.
Welcome to the linux chat group 478068715.