Skip to main content

How to install Apache using Ansible

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


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]#


Comments

  1. Thanks For Sharing Such Great Information, It's Really Nice And Informative.
    DevOps Training
    DevOps Online Training

    ReplyDelete
  2. Thanks for the interesting post, keep continue your good job.



    How to Install Docker on Ubuntu 20.04 Easily

    ReplyDelete

Post a Comment

Popular posts from this blog

Warning Message When Creating A Keystore

  Warning Message When Creating A Keystore When we try to list the contents of the keystore, using the below command, keytool -list -v -keystore adkeystore.dat Enter keystore password: Keystore type: JKS Keystore provider: SUN Your keystore contains 1 entry Alias name: prod_apps002 Creation date: Jan 26, 2012 Entry type: PrivateKeyEntry Certificate chain length: 1 Certificate[1]: Owner: CN=PROD_apps002, OU=apps, O=apps002, C=US Issuer: CN=PROD_apps002, OU=apps, O=apps002, C=US Serial number: 4f208085 Valid from: Thu Jan 26 01:21:57 AST 2012 until: Tue Jan 16 01:21:57 AST 2052 Certificate fingerprints:          MD5:  XX: XX XX XX          SHA1:  XX: XX XX XX          SHA256:  XX: XX XX XX Signature algorithm name: SHA1withDSA Subject Public Key Algorithm: 1024-bit DSA key Version: 3 ******************************************* ******************************************* Warning: The JKS keystore...

CLEARING an ADOP patching session

In some case adop prepare phase fails due to some issues and if you wish to apply any patch in hotpatch mode, it will fail with below errors [STATEMENT] There is already a session which is incomplete. Details are: [STATEMENT]     Session Id: 2 [STATEMENT]     Prepare phase status: R [STATEMENT]     Apply phase status: N [STATEMENT]     Cutover  phase status: N [STATEMENT]     Abort phase status: N [STATEMENT]     Session status: F [ERROR]     Cannot apply hotpatch as another online patching cycle is going on [ERROR]     Unrecoverable error occured. Exiting the current session. [STATEMENT] [START 2019/10/22 16:13:00] Unlocking sessions table [STATEMENT] [END   2019/10/22 16:13:00] Unlocking sessions table [STATEMENT] Log file: /adop_20191022_161221.log [STATEMENT] [START 2019/10/22 16:13:02] Unlocking sessions table [STATEMENT] [E...

XX_XXXXXXX is not a valid responsibility for the current user. Please contact your System Administrator.

  XX_XXXXXXX is not a valid responsibility for the current user. Please contact your System Administrator. Issue : When user logs into EBS, he gets the following Error :  xx_XXXXX  is not a valid responsibility for the current user. Please contact your System Administrator. Solution: 1. Check if the responsibility is end dated.  Extend the end-date if required and try to login again.  2. Check the profile option  Applications Start Page for the user ( User Level). If there is any value defined, remove it and save it. Try to login again and it worked in our case.  Before: After: