Getting Started with Ansible


Introduction: Ansible is a configuration management and provisioning tool, similar to Chef, Puppet or Salt.Configuration management systems are designed for controlling large numbers of servers easy for administrators and operations teams. They allow you to control many different systems in an automated way from one central location.

There are many popular configuration management systems available for Linux systems, such as Chef and Puppet, these are often more complex than many people want or need. Ansible is written in Python and uses SSH to execute commands on different machines. Ansible uses YML to describe work.

Install And Configure Ansible on Ubuntu: Run the below command to install and configure ansible on Ubuntu.

sudo yum install ansible

We’ll assume you are using SSH keys for authentication. To set up SSH agent to avoid retyping passwords, you can run the below command.

ssh-keygen
ssh-agent bash
ssh-add ~/.ssh/id_rsa

Configuring Ansible Hosts: Ansible keeps track of all of the servers that it knows about through a “hosts” file. We need to set up this file first before we can begin to communicate with our other computers.Open the file with root privileges like this:

sudo vi /etc/ansible/hosts

You will see a file that has a lot of example configurations, none of which will actually work for us since these hosts are made up. So to start, let’s comment out all of the lines in this file by adding a “#” before each line.

We will keep these examples in the file to help us with configuration if we want to implement more complex scenarios in the future.Once all of the lines are commented out, we can begin adding our actual hosts.

Playbooks: Playbooks are Ansible’s configuration, deployment, and orchestration language. They can describe a policy you want your remote systems to enforce, or a set of steps in a general IT process.

Hello world Example :  First we need to create a helloWorld.yml file which looks like.

- hosts:
  - local
  tasks:
  - name: Hello World
    shell: echo "hello world"

Run Playbook: Run the helloWorld.yml on localhost with the below command.

ansible-playbook helloWorld.yml -i 'local,' --connection=local

Your result looks like.

helloWorldPlaybook

Resources :

Ansible

Thanks !!!


knoldus-advt-sticker


Advertisements
This entry was posted in Scala. Bookmark the permalink.

One Response to Getting Started with Ansible

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s