HostSEO Blog

Stories and News from IT Industry, Reviews & Tips | Technology Blog

Installing Apache in Remote hosts Using Ansible Playbook.

Ansible is an open source automation tool. Which is very simple to setup and yet powerful.It can help you with task automation,configuration management,application deployment.

Ansible is available for free and runs on Linux, Mac or BSD. Aside from the free offering, Ansible also has an enterprise product called Ansible Tower.

First testing.

After installing ansible and added few hosts to the inventory file, normally /etc/ansible/hosts you can check connection between them using ping.A connection will be made with ssh keys and you can also specify a username and password.

[root@ansible playbooks]# ansible all -m ping | SUCCESS => {
    "changed": false, 
    "ping": "pong"
} | SUCCESS => {
    "changed": false, 
    "ping": "pong"
[root@ansible playbooks]#

Here “all” keyword is for all of the hosts in your inventory.


The real strength of Ansible lies in its playbooks. Playbooks are written in YAML

ansible-playbook [options] playbook.yml [playbook2 ...]

1.Creating playbook for installing httpd.

# cat httpd.. 
- hosts: apache
      name: install httpd*
      yum: name=httpd state=latest

2. Run the newly created playbook.

#ansible-playbook httpd.yaml

Which shows,

PLAY [apache] ****************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************
ok: []
ok: []

TASK [install httpd*] ********************************************************************************************************************************************************************************
changed: []
changed: []

PLAY RECAP *******************************************************************************************************************************************************************************************                 : ok=2    changed=1    unreachable=0    failed=0                : ok=2    changed=1    unreachable=0    failed=0   

If you visit your secondary server’s hostname or IP address in your browser, you should now get apache default page

Subscribe Now

10,000 successful online businessmen like to have our content directly delivered to their inbox. Subscribe to our newsletter!

Archive Calendar


Born in 2004 ... Trusted By Clients n' Experts

SEO Stars

They never made me feel silly for asking questions. Help me understand how to attract more people and improve my search engine ranking.

Read More

Emily Schneller Manager at Sabre Inc
SEO Stars

Took advantage of Hostseo's superb tech support and I must say, it is a very perfect one. It is very fast, servers reliability is incredible.

Read More

Leena Mäkinen Creative producer
SEO Stars

We're operating a worldwide network of servers with high quality standards requirements, we’ve choose hostseo to be our perfect partner.

Read More

Ziff Davis CEO at Mashable
SEO Stars

It’s very comfortable to know I can rely about all technical issues on Hostseo and mostly that my website and emails are safe and secured here.

Read More

Isaac H. Entrepreneur
SEO Stars

With hostseo as a hosting partner we are more flexible and save money due to the better packages with great pricing, free SEO n' free SSL too!

Read More

Madeline E. Internet Professional