08-28-2020, 07:21 AM
########################################### Ubuntu ########################################
---
- hosts: host2
sudo: yes
vars:
http_port: 80
remote_user: root
tasks:
- name: update
apt: update_cache=yes
- name: install apache2
apt: name=apache2 state=present
- name: restart apache2
service: name=apache2 state=restarted
- debug: msg="apache has been installed"
...
########################################### Centos #########################################
---
- hosts: hostname(node or client name)
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
...
###########################################################################################
---
- hosts: host2
sudo: yes
vars:
http_port: 80
remote_user: root
tasks:
- name: update
apt: update_cache=yes
- name: install apache2
apt: name=apache2 state=present
- name: restart apache2
service: name=apache2 state=restarted
- debug: msg="apache has been installed"
...
########################################### Centos #########################################
---
- hosts: hostname(node or client name)
vars:
http_port: 80
max_clients: 200
remote_user: root
tasks:
- name: ensure apache is at the latest version
yum: pkg=httpd state=latest
notify:
- restart apache
- name: ensure apache is running (and enable it at boot)
service: name=httpd state=started enabled=yes
handlers:
- name: restart apache
service: name=httpd state=restarted
...
###########################################################################################