forked from Sonal0409/Ansible-jenkins-Demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook1.yml
More file actions
25 lines (25 loc) · 774 Bytes
/
playbook1.yml
File metadata and controls
25 lines (25 loc) · 774 Bytes
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
---
- name: Handlers in Ansible
hosts: webserver
become: true
become_user: root
tasks:
- name: execute a command on hostserver
command: hostname -s
notify: Print a message for command Execution
- name: Install package httpd
package: name=httpd state=present
- name: Start httpd service
service: name=httpd state=started
- name: Deploy an HTML file on the host server
copy: src=index.html dest=/var/www/html
notify:
- Print Deployment status
- Restart httpd service
handlers:
- name: Print a message for command Execution
debug: msg="Command executed successfully"
- name: Print Deployment status
debug: msg="Deployment done successfully"
- name: Restart httpd service
service: name=httpd state=restarted