- hosts: centos
tasks:
- name: Install Httpd
package: name=httpd state=installed
become: yes
- name: Copy httpd Configuration
copy: src=index.html dest=/var/www/html/index.html
notify: Restart httpd
become: yes
- name: Ensure httpd is running
service: name=httpd state=started
become: yes
handlers:
- name: Restart httpd
service: name=httpd state=restarted
- hosts: ubuntu
tasks:
- name: Install apache2
package: name=apache2 state=latest
become: yes
- name: Copy apache2 Configuration
copy: src=index.html dest=/var/www/html/index.html
notify: Restart apache2
become: yes
- name: Ensure apache2 is running
service: name=apache2 state=started
become: yes
handlers:
- name: Restart apache2
service: name=apache2 state=restarted
- hosts: centos
tasks:
- name: "Install httpd"
yum: name=httpd
become: yes
become_user: root
- name: "Started httpd"
systemd:
name: httpd
state: started
enabled: yes
become: yes
become_user: root
- name: "Copy html on Centos"
copy:
src: /practice/1/1.2/index.html
dest: /var/www/html/index.html
become: yes
become_user: root
- hosts: ubuntu
tasks:
- name:
apt:
name: apache2
become: yes
become_user: root
- name: "Started apache2"
systemd:
name: apache2
state: started
enabled: yes
become: yes
become_user: root
- name: "Copy html on Ubuntu"
copy:
src: /practice/1/1.2/index.html
dest: /var/www/html/index.html
become: yes
become_user: root
- name: Installing httpd
hosts: all
vars:
package_name:
Ubuntu: apache2
CentOS: httpd
tasks:
- name: install httpd package
package: name={{ package_name[ansible_distribution] }}
become: yes
become_user: root
- name: start httpd
systemd: name={{ package_name[ansible_distribution] }} state=started
become: yes
become_user: root
- name: Copying custom page
hosts: all
tasks:
- name: copy template
template:
src: ./index.html
dest: /var/www/html/index.html
become: yes
become_user: root
- hosts: centos
become: yes
tasks:
- name: Install httpd for CentOS
yum: name=httpd state=present
- name: Copying index file
copy: src=./index.html dest=/var/www/html/index.html
mode: 0755
- name: Start httpd and enabled it
service: name=httpd state=started enabled=yes
- hosts: ubuntu
become: yes
tasks:
- name: Install Apache Web Server for Debian
apt: name=apache2 state=present
- name: Copying index file
copy: src=./index.html dest=/var/www/html/index.html
mode: 0755
- name: Start Apache and Enable it on every boot
service: name=apache2 state=started enabled=yes