Part 4: Install Apache using Ansible Playbook + configure repo


Setup target Server

Ssh-copy-id 192.168.0.X if required

hostnamectl set-hostname <hostname>

Setup Ansible Server for repo

  • mount /dev/cdrom /mnt/
  • cd /mnt/
  • cd Packages/
  • rpm -ivh vsftpd-3.0.2-22.el7.x86_64.rpm
  • ls -ld /var/ftp/pub/
  • rpm -qf /var/ftp/pub/
  • cd mnt/
  • cp -rvf /mnt/* /var/ftp/pub/.
  • cd /etc/yum.repos.d/
  • mkdir backup
  • cp *.repo /etc/yum.repos.d/backup/
  • rm *.repo
  • vi rhel.repo
  • yum clean all
  • yum list all
  • service vsftpd restart
  • yum list all
  • firewall-cmd –permanent –zone=public –add-service=ftp


Create rhel.repo


name=RHEL Repo





Create playbook to install apache

  • cd /etc/ansible/
  • Update Ansible hosts
  • vi installTier03-playbook.yml
  • ansible-playbook -v installTier03-playbook.yml



– hosts: Tier03

user: root


– name: Copy repo file

copy: src=/etc/yum.repos.d/rhel.repo dest=/etc/yum.repos.d/rhel.repo

– name: Install httpd

action: yum name=httpd state=installed

– name: copy html

copy: src=/root/files/index.html dest=/var/www/html/index.html

– name: start apache


name: httpd

state: restarted



Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s