-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoles
More file actions
56 lines (42 loc) · 1.24 KB
/
Copy pathRoles
File metadata and controls
56 lines (42 loc) · 1.24 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
--Ansible Roles
Roles in Ansible are next level of abstraction of Ansible playbooks
--Benefits of Ansible Roles
idea of include files and combine them to form clean and resuable abstraction
Easy to maintain/troubleshooting the playbooks
--Structure of Roles
files: contains the regular files those need to copy to target folder
handlers: Event handlers
meta: Role dependencies
templates: similar to files but contains dynamic data
tasks: playbook tasks
vars/group_vars: variable definitions
ansible-galaxy search apache
galaxy.ansible.combine
ansible-galaxy init apache --offline
main.yml
---
# tasks file for apache
- include: install.yml
- include: configure.yml
- include: service.yml
#install.yml
---
name: installing httpd
yum:
name: httpd
state: present
#configure.yml
---
- name: httpd conf
copy: src=httpd.conf dest=/etc/httpd/conf/httpd.conf
notify:
restart apache service
- name: send the file
copy: src=index.html dest=/var/www/html/index.html
# copy the configuration file to files/ folder
cp /etc/httpd/conf/httpd.conf .
# under handlers folder/main.yml
---
# handlers file for apache
- name: restart apache service
service: name=httpd state=restarted