How to install Apache using Ansible
Use the powerful ansible tool to install Apache on your local machine or you can install on any remote server as well.
1. Install Ansible Modules
[root@dev02 ~]# yum install ansible*
Oracle Linux 8 EPEL Packages for Development (x86_64) 1.5 kB/s | 2.5 kB 00:01
Oracle Linux 8 Gluster Appstream (x86_64) 1.9 kB/s | 2.7 kB 00:01
Oracle Linux 8 Application Stream (x86_64) 2.1 kB/s | 2.9 kB 00:01
Oracle Linux 8 Application Stream (x86_64) 1.2 MB/s | 20 MB 00:16
Oracle Linux 8 BaseOS Latest (x86_64) 1.9 kB/s | 2.7 kB 00:01
Oracle Linux 8 BaseOS Latest (x86_64) 1.9 MB/s | 19 MB 00:10
Oracle Linux 8 Development Packages (x86_64) 0.0 B/s | 0 B 00:18
Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64) 0.0 B/s | 0 B 00:12
Failed to synchronize cache for repo 'ol8_developer', ignoring this repo.
Failed to synchronize cache for repo 'ol8_UEKR6', ignoring this repo.
Dependencies resolved.
==================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================
Installing:
ansible-doc noarch 2.9.5-1.el8 ol8_developer_EPEL 12 M
ansible noarch 2.9.5-1.el8 ol8_developer_EPEL 17 M
ansible-freeipa noarch 0.1.8-3.el8 ol8_appstream 182 k
Installing dependencies:
sshpass x86_64 1.06-9.el8 ol8_developer_EPEL 28 k
python3-babel noarch 2.5.1-5.el8 ol8_appstream 4.8 M
python3-jinja2 noarch 2.10.1-2.el8_0 ol8_appstream 538 k
python3-jmespath noarch 0.9.0-11.el8 ol8_appstream 45 k
python3-markupsafe x86_64 0.23-19.el8 ol8_appstream 39 k
Transaction Summary
==================================================================================================================================================================================================
Install 8 Packages
Total download size: 34 M
Installed size: 455 M
Is this ok [y/N]: y
Downloading Packages:
(1/8): sshpass-1.06-9.el8.x86_64.rpm 4.7 kB/s | 28 kB 00:06
(2/8): python3-babel-2.5.1-5.el8.noarch.rpm 203 kB/s | 4.8 MB 00:24
(3/8): python3-jinja2-2.10.1-2.el8_0.noarch.rpm 70 kB/s | 538 kB 00:07
(4/8): ansible-freeipa-0.1.8-3.el8.noarch.rpm 24 kB/s | 182 kB 00:07
(5/8): python3-jmespath-0.9.0-11.el8.noarch.rpm 14 kB/s | 45 kB 00:03
(6/8): python3-markupsafe-0.23-19.el8.x86_64.rpm 75 kB/s | 39 kB 00:00
(7/8): ansible-doc-2.9.5-1.el8.noarch.rpm 147 kB/s | 12 MB 01:20
(8/8): ansible-2.9.5-1.el8.noarch.rpm 165 kB/s | 17 MB 01:47
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 329 kB/s | 34 MB 01:47
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : python3-jmespath-0.9.0-11.el8.noarch 1/8
Installing : python3-markupsafe-0.23-19.el8.x86_64 2/8
Installing : python3-babel-2.5.1-5.el8.noarch 3/8
Installing : python3-jinja2-2.10.1-2.el8_0.noarch 4/8
Installing : sshpass-1.06-9.el8.x86_64 5/8
Installing : ansible-2.9.5-1.el8.noarch 6/8
Installing : ansible-freeipa-0.1.8-3.el8.noarch 7/8
Installing : ansible-doc-2.9.5-1.el8.noarch 8/8
Running scriptlet: ansible-doc-2.9.5-1.el8.noarch 8/8
Verifying : ansible-doc-2.9.5-1.el8.noarch 1/8
Verifying : sshpass-1.06-9.el8.x86_64 2/8
Verifying : ansible-2.9.5-1.el8.noarch 3/8
Verifying : python3-babel-2.5.1-5.el8.noarch 4/8
Verifying : python3-jinja2-2.10.1-2.el8_0.noarch 5/8
Verifying : ansible-freeipa-0.1.8-3.el8.noarch 6/8
Verifying : python3-jmespath-0.9.0-11.el8.noarch 7/8
Verifying : python3-markupsafe-0.23-19.el8.x86_64 8/8
Installed:
ansible-doc-2.9.5-1.el8.noarch ansible-2.9.5-1.el8.noarch ansible-freeipa-0.1.8-3.el8.noarch sshpass-1.06-9.el8.x86_64 python3-babel-2.5.1-5.el8.noarch
python3-jinja2-2.10.1-2.el8_0.noarch python3-jmespath-0.9.0-11.el8.noarch python3-markupsafe-0.23-19.el8.x86_64
Complete!
[root@dev02 ~]# which ansible
/usr/bin/ansible
Use the powerful ansible tool to install Apache on your local machine or you can install on any remote server as well.
1. Install Ansible Modules
[root@dev02 ~]# yum install ansible*
Oracle Linux 8 EPEL Packages for Development (x86_64) 1.5 kB/s | 2.5 kB 00:01
Oracle Linux 8 Gluster Appstream (x86_64) 1.9 kB/s | 2.7 kB 00:01
Oracle Linux 8 Application Stream (x86_64) 2.1 kB/s | 2.9 kB 00:01
Oracle Linux 8 Application Stream (x86_64) 1.2 MB/s | 20 MB 00:16
Oracle Linux 8 BaseOS Latest (x86_64) 1.9 kB/s | 2.7 kB 00:01
Oracle Linux 8 BaseOS Latest (x86_64) 1.9 MB/s | 19 MB 00:10
Oracle Linux 8 Development Packages (x86_64) 0.0 B/s | 0 B 00:18
Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64) 0.0 B/s | 0 B 00:12
Failed to synchronize cache for repo 'ol8_developer', ignoring this repo.
Failed to synchronize cache for repo 'ol8_UEKR6', ignoring this repo.
Dependencies resolved.
==================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================
Installing:
ansible-doc noarch 2.9.5-1.el8 ol8_developer_EPEL 12 M
ansible noarch 2.9.5-1.el8 ol8_developer_EPEL 17 M
ansible-freeipa noarch 0.1.8-3.el8 ol8_appstream 182 k
Installing dependencies:
sshpass x86_64 1.06-9.el8 ol8_developer_EPEL 28 k
python3-babel noarch 2.5.1-5.el8 ol8_appstream 4.8 M
python3-jinja2 noarch 2.10.1-2.el8_0 ol8_appstream 538 k
python3-jmespath noarch 0.9.0-11.el8 ol8_appstream 45 k
python3-markupsafe x86_64 0.23-19.el8 ol8_appstream 39 k
Transaction Summary
==================================================================================================================================================================================================
Install 8 Packages
Total download size: 34 M
Installed size: 455 M
Is this ok [y/N]: y
Downloading Packages:
(1/8): sshpass-1.06-9.el8.x86_64.rpm 4.7 kB/s | 28 kB 00:06
(2/8): python3-babel-2.5.1-5.el8.noarch.rpm 203 kB/s | 4.8 MB 00:24
(3/8): python3-jinja2-2.10.1-2.el8_0.noarch.rpm 70 kB/s | 538 kB 00:07
(4/8): ansible-freeipa-0.1.8-3.el8.noarch.rpm 24 kB/s | 182 kB 00:07
(5/8): python3-jmespath-0.9.0-11.el8.noarch.rpm 14 kB/s | 45 kB 00:03
(6/8): python3-markupsafe-0.23-19.el8.x86_64.rpm 75 kB/s | 39 kB 00:00
(7/8): ansible-doc-2.9.5-1.el8.noarch.rpm 147 kB/s | 12 MB 01:20
(8/8): ansible-2.9.5-1.el8.noarch.rpm 165 kB/s | 17 MB 01:47
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 329 kB/s | 34 MB 01:47
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : python3-jmespath-0.9.0-11.el8.noarch 1/8
Installing : python3-markupsafe-0.23-19.el8.x86_64 2/8
Installing : python3-babel-2.5.1-5.el8.noarch 3/8
Installing : python3-jinja2-2.10.1-2.el8_0.noarch 4/8
Installing : sshpass-1.06-9.el8.x86_64 5/8
Installing : ansible-2.9.5-1.el8.noarch 6/8
Installing : ansible-freeipa-0.1.8-3.el8.noarch 7/8
Installing : ansible-doc-2.9.5-1.el8.noarch 8/8
Running scriptlet: ansible-doc-2.9.5-1.el8.noarch 8/8
Verifying : ansible-doc-2.9.5-1.el8.noarch 1/8
Verifying : sshpass-1.06-9.el8.x86_64 2/8
Verifying : ansible-2.9.5-1.el8.noarch 3/8
Verifying : python3-babel-2.5.1-5.el8.noarch 4/8
Verifying : python3-jinja2-2.10.1-2.el8_0.noarch 5/8
Verifying : ansible-freeipa-0.1.8-3.el8.noarch 6/8
Verifying : python3-jmespath-0.9.0-11.el8.noarch 7/8
Verifying : python3-markupsafe-0.23-19.el8.x86_64 8/8
Installed:
ansible-doc-2.9.5-1.el8.noarch ansible-2.9.5-1.el8.noarch ansible-freeipa-0.1.8-3.el8.noarch sshpass-1.06-9.el8.x86_64 python3-babel-2.5.1-5.el8.noarch
python3-jinja2-2.10.1-2.el8_0.noarch python3-jmespath-0.9.0-11.el8.noarch python3-markupsafe-0.23-19.el8.x86_64
Complete!
[root@dev02 ~]# which ansible
/usr/bin/ansible
2. Install Apache web Server using Ansible
[root@dev02 ansible]# ansible localhost -m yum -a "name=httpd state=latest"
localhost | CHANGED => {
"ansible_facts": {
"pkg_mgr": "dnf"
},
"changed": true,
"msg": "",
"rc": 0,
"results": [
"Installed: apr-util-1.6.1-6.el8.x86_64",
"Installed: httpd-filesystem-2.4.37-21.0.1.module+el8.2.0+5576+c083ffcb.noarch",
"Installed: apr-1.6.3-9.el8.x86_64",
"Installed: httpd-2.4.37-21.0.1.module+el8.2.0+5576+c083ffcb.x86_64",
"Installed: httpd-tools-2.4.37-21.0.1.module+el8.2.0+5576+c083ffcb.x86_64",
"Installed: mod_http2-1.11.3-3.module+el8.2.0+5576+c083ffcb.x86_64"
]
}
[root@dev02 ansible]#
[root@dev02 ansible]# which httpd
/usr/sbin/httpd
3. Just try to ping any server using ansible
[root@dev02 ansible]# ansible localhost -m ping
localhost | SUCCESS => {
"changed": false,
"ping": "pong"
}
[root@dev02 ansible]#