Home News How to Install and config Ansible on CentOS 7.

How to Install and config Ansible on CentOS 7.

by Roger Lund

In preparation for my lab and openstack testing. I wanted to look at implementing a automation tool. I decided on ansible, as I haven’t used it, and I like a challenge. 🙂

What is ansible?

I turn to Wikipedia.

Ansible (software)

From Wikipedia, the free encyclopedia

 

Ansible, a free-software platform for configuring and managing computers, combines multi-node software deployment, ad hoc task execution, and configuration management.[fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][1] It manages nodes (which must have Python 2.4 or later installed on them) over SSH or over PowerShell.[2] Modules work over JSON and standard output and can be written in any programming language. The system uses YAML to express reusable descriptions of systems.[3]

Michael DeHaan, the author of the provisioning server application Cobbler and co-author of the Func framework for remote administration, developed the platform.[4] It is included as part of the Fedora distribution of Linux, owned by Red Hat Inc., and is also available for Red Hat Enterprise Linux, CentOS, and Scientific Linux via Extra Packages for Enterprise Linux (EPEL) as well as for other operating systems.[5] Ansible, Inc commercially supports and sponsors Ansible[6] On 16 October, 2015, Red Hat Inc. announced that it had signed a definitive agreement to acquire Ansible, Inc.[7][8]

The name “Ansible” references the fictional instantaneous hyperspace communication system (featured in Orson Scott Card‘s Ender’s Game,[9] and originally invented by Ursula K. Le Guin for her 1966 novel Rocannon’s World).”

 

 

After some research on how to install Ansible on Centos 7, I found this write up quite detailed.

 

Ansible is a free & open source Configuration and automation tool for UNIX like operating system. It is written in python and similar to Chef or Puppet but there is one difference and advantage of Ansible is that we don’t need to install any agent on the nodes. It uses SSH for making communication to its nodes.

In this article we will install and configure Ansible in CentOS 7 and will try to manage its two nodes.”

http://www.linuxtechi.com/install-and-use-ansible-in-centos-7/

 

So lets do it!

 

#1 will be putty term 1, #2 will be putty term 2.

 

  • First I like nano, #1 yum install nano -y
  • Connect with putty to the host #1
  • #1 rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
  • #1 yum install ansible -y
  • #1 ansible –version
  • #1 ssh-keygen

ssh gen

  • #1 ssh-copy-id -i root@ipaddress , then type yes, and type the password for root.

copyssh

  • #1 nano /etc/ansible/hosts
  • add this at the bottom. I am calling this openstack servers.

[openstackservers]

192.168.50.200

192.168.50.201

192.168.50.202

192.168.50.203

192.168.50.204

192.168.50.205

192.168.50.206

 

  • alt x to save, y enter.
  • #1 cat /etc/ansible/hosts

openstackservers

 

  • #1 ansible -m ping 'openstackservers'
  • pingpong

 

  • Sweet. Now let’s have some fun. First I like to watch my work. Lets logs our progress in a new putty session. once your connected lets create some new directories.
  • #2 mkdir /anisble/
  • #2 mkdir /anisble/logs
  • now lets go back to the first putty session. and do the following.
  • #1 anisble -m command -a “who” ‘openstackservers’ >> /anisble/logs.log
  • then lets go back to term 2
  • #2 tail -f /anisble/logs.log
  • This will allow us to see the results on term #2 without losing our commands on term #1. lets check for updates.
  • #1 anisble -m command -a “update -y” ‘openstackservers’ >> /anisble/logs.log
  • in term #2 you will see the following.

updates

 

We are all done! See future posts about way’s to use anisble.

 

Roger Lund[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

You may also like