• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Create Ansible Playbook to Install Apache Server

  • 01:02 vim hosts
  • 04:17 vim httpd.yml
  • 04:37 ansible-playbook httpd.yml
6592

To Create Ansible Playbook to Install Apache Server

Apache is a web server that is used on the Internet. It is easy to set up and configure on Linux distributions including Ubuntu and Debian, as it comes in the package repositories and includes a default configuration that works out of the box. This video will cover the installation of an apache server using Ansible.

Installation process:

Create a playbook to isntall apache server on your host machine

[root@localhost ansible]# vim httpd.yml 

snap1

After creating playbook now let’s run this using the following command

[root@localhost ansible]# ansible-playbook httpd.yml 
PLAY [httpd is there] *********************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************
ok: [192.168.6.111]
TASK [ensure httpd is installed] **********************************************************************************************
[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via squash_actions is deprecated. Instead of using a loop 
to supply multiple items and specifying `pkg: ""`, please use `pkg: ['nano', 'httpd']` and remove the loop. This 
feature will be removed from ansible-base in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
changed: [192.168.6.111] => (item=['nano', 'httpd'])

PLAY RECAP ********************************************************************************************************************
192.168.6.111              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
Now I am going to uninstall the httpd from our host machine using the following playbook
[root@localhost ansible]# vim httpd.yml

snap2

And now run this playbook to uninstall the apache from the host machine.

[root@localhost ansible]# ansible-playbook httpd.yml 
PLAY [httpd is there] *********************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************
ok: [192.168.6.111]
TASK [ensure httpd is installed] **********************************************************************************************
[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via squash_actions is deprecated. Instead of using a loop 
to supply multiple items and specifying `pkg: ""`, please use `pkg: ['nano', 'httpd']` and remove the loop. This 
feature will be removed from ansible-base in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
changed: [192.168.6.111] => (item=['nano', 'httpd'])

PLAY RECAP ********************************************************************************************************************
192.168.6.111              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Now in case if you want to install multiple application packages on your host machine using ansible

snap3

Now run this playbook to install apache and nano to install on your host machine

[root@localhost ansible]# ansible-playbook httpd.yml%%

PLAY [httpd is there] *********************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************
ok: [192.168.6.111]
TASK [ensure httpd is installed] **********************************************************************************************
[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via squash_actions is deprecated. Instead of using a loop 
to supply multiple items and specifying `pkg: ""`, please use `pkg: ['nano', 'httpd']` and remove the loop. This 
feature will be removed from ansible-base in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
changed: [192.168.6.111] => (item=['nano', 'httpd'])

PLAY RECAP ********************************************************************************************************************
192.168.6.111              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

With this method installation of apache on ansible host machine comes to an end.

Tags:
ethan
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What is inventory file in ansible?

A

The Ansible inventory file defines the hosts and groups of hosts upon which commands, modules, and tasks in a playbook operate.

Q

How to install multiple application in host machine using ansible?

A

To install multiple application you have to use loop insid the playbook.

Q

How to unistall any application in host machine using ansible

A

you can use status=absent in ansible playbook to uninstall apny application.

Q

How do I see a list of all of the ansible_ variables?

A

To see a list of all of the facts that are available about a machine, you can run the setup module as an ad-hoc action:
ansible -m setup hostname

Q

How do I see all the variables specific to my host?

A

Using this command

ansible -m debug -a "var=hostvars['hostname']" localhost

Related Tutorials in How to Create Ansible Playbook to Install Apache Server

Related Tutorials in How to Create Ansible Playbook to Install Apache Server

How to install Apache from Source Code on CentOS 7
How to install Apache from Source Code on CentOS 7
Oct 21, 2017
How to Completely Remove and Install Apache package on CentOS 7.6
How to Completely Remove and Install Apache package on CentOS 7.6
May 23, 2019
How to install apache jmeter on ubuntu 18.04
How to install apache jmeter on ubuntu 18.04
May 19, 2018
How to Install Pligg - Content Management System
How to Install Pligg - Content Management System
Jul 26, 2016
How to Configure HAproxy Load Balancer with Keepalived in CentOS
How to Configure HAproxy Load Balancer with Keepalived in CentOS
Nov 21, 2016
How to enable the Apache server-status on centos 7
How to enable the Apache server-status on centos 7
Jan 28, 2019
How to Create Ansible Playbook to Install Apache Server
How to Create Ansible Playbook to Install Apache Server
May 12, 2021
How to Configure Reverse Proxy with Apache in CentOS
How to Configure Reverse Proxy with Apache in CentOS
Jan 25, 2017

Related Forums in How to Create Ansible Playbook to Install Apache Server

Related Forums in How to Create Ansible Playbook to Install Apache Server

CentOS
connor class=
How To Completely Remove Apache package On CentOS 7.6
May 14, 2019
Apache
isaac class=
How to disable apache welcome page on Ubuntu
Dec 15, 2018
Apache
rebeccajazz class=
Apache2 : mod_proxy in opensuse
Jan 3, 2018
Apache
elijah class=
What is the difference between httpd and apache
Feb 18, 2017
Ansible
michael class=
How to Fix “Shared connection to x.x.xx closed” Ansible Error
Nov 6, 2021
Apache
logan class=
How to install Apache GUI
Feb 24, 2017
Apache
rolando class=
How to find apache user in opensuse
Sep 23, 2017
Apache
caden class=
how to use php variables in apache
May 12, 2017

Related News in How to Create Ansible Playbook to Install Apache Server

Related News in How to Create Ansible Playbook to Install Apache Server

Attackers take advantage of Apache Struts vulnerabilities
Attackers take advantage of Apache Struts vulnerabilities
Mar 17, 2017
An Apache Web Server Bug That Grants Root Access on  Shared Web Hosts
An Apache Web Server Bug That Grants Root Access on Shared Web Hosts
Apr 10, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaac ?
How to run windows application in linux

I need to run the windows application in my Linux machine, instead of installing from yum repo or any other repos. How to do that..??

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.