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
[RHELRepo]
name=RHEL Repo
baseurl=ftp://192.168.0.109/pub
enable=1
gpgcheck=0
Create playbook to install apache
- cd /etc/ansible/
- Update Ansible hosts
- vi installTier03-playbook.yml
- ansible-playbook -v installTier03-playbook.yml
Playbook
—
– hosts: Tier03
user: root
tasks:
– 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
service:
name: httpd
state: restarted