Installing Apache in Remote hosts Using Ansible Playbook.
- Category : Linux Helpline (Easy Guide)
- Posted on : Jan 02, 2019
- Views : 1,662
- By : Marcus J.
Ansible is an open source automation tool. Which is very simple to setup and yet powerful.It can help you with task automation,configuration management,application deployment.
Ansible is available for free and runs on Linux, Mac or BSD. Aside from the free offering, Ansible also has an enterprise product called Ansible Tower.
First testing.
After installing ansible and added few hosts to the inventory file, normally /etc/ansible/hosts you can check connection between them using ping.A connection will be made with ssh keys and you can also specify a username and password.
[root@ansible playbooks]# ansible all -m ping
10.0.0.209 | SUCCESS => {
"changed": false,
"ping": "pong"
}
10.0.0.206 | SUCCESS => {
"changed": false,
"ping": "pong"
}
[root@ansible playbooks]#
Here “all” keyword is for all of the hosts in your inventory.
Playbook.
The real strength of Ansible lies in its playbooks. Playbooks are written in YAML
ansible-playbook [options] playbook.yml [playbook2 ...]
1.Creating playbook for installing httpd.
# cat httpd..
---
- hosts: apache
tasks:
name: install httpd*
yum: name=httpd state=latest
2. Run the newly created playbook.
#ansible-playbook httpd.yaml
Which shows,
PLAY [apache] ****************************************************************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************************************************************
ok: [10.0.0.206]
ok: [10.0.0.209]
TASK [install httpd*] ********************************************************************************************************************************************************************************
changed: [10.0.0.206]
changed: [10.0.0.209]
PLAY RECAP *******************************************************************************************************************************************************************************************
10.0.0.206 : ok=2 changed=1 unreachable=0 failed=0
10.0.0.209 : ok=2 changed=1 unreachable=0 failed=0
If you visit your secondary server’s hostname or IP address in your browser, you should now get apache default page
Categories
Subscribe Now
10,000 successful online businessmen like to have our content directly delivered to their inbox. Subscribe to our newsletter!Archive Calendar
Sat | Sun | Mon | Tue | Wed | Thu | Fri |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Recent Articles
-
Posted on : Jul 25
-
Posted on : Jul 07
-
Posted on : Apr 07
-
Posted on : Mar 19
Optimized my.cnf configuration for MySQL 8 (on cPanel/WHM servers)
Tags
- layer 7
- tweak
- kill
- process
- sql
- Knowledge
- vpn
- seo vpn
- wireguard
- webmail
- ddos mitigation
- attack
- ddos
- DMARC
- server load
- Development
- nginx
- php-fpm
- cheap vpn
- Hosting Security
- xampp
- Plesk
- cpulimit
- VPS Hosting
- smtp
- smtp relay
- exim
- Comparison
- cpu
- WHM
- mariadb
- encryption
- sysstat
- optimize
- Link Building
- apache
- centos
- Small Business
- VPS
- Error
- SSD Hosting
- Networking
- optimization
- DNS
- mysql
- ubuntu
- Linux