-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathAnsible_0824
More file actions
98 lines (98 loc) · 1.81 KB
/
Ansible_0824
File metadata and controls
98 lines (98 loc) · 1.81 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
[amit@slave tmp]$ cat a.yml
---
- hosts: webservers
become: true
become_user: root
tasks:
- name: install some package
yum:
name: httpd1
state: present
ignore_errors: true
register: task_a_result
tags:
- amit
- edureka
- name: start the service
service:
name: httpd
state: started
when: task_a_result.rc==0
register: service_execution
tags:
- service
- edureka
- name: show status
debug:
var: service_execution.state
[amit@slave tmp]$ cat b.yml
---
- hosts: webservers
become: true
become_user: root
tasks:
- name: copy the script
copy:
src: /tmp/a.sh
dest: /tmp/
- name: execute the script
command: sh /tmp/a.sh
[amit@slave tmp]$ cat c.yml
---
- hosts: webservers
become: true
become_user: root
tasks:
- name: replace the content
replace:
dest: /tmp/b.txt
regexp: 'thursday'
replace: 'friday'
[amit@slave tmp]$ cat d.yml
---
- hosts: webservers
become: true
become_user: root
tasks:
- name: apply latest updates
yum:
name: '*'
state: latest
[amit@slave tmp]$ cat e.yml
---
- hosts: webservers
become: true
become_user: root
vars:
src_path: /tmp/index.html
dest_path: /var/www/html
tasks:
- name: install package
yum:
name: httpd
state: present
- name: start the service
service:
name: httpd
state: started
- name: copy my web page file
copy:
src: "{{src_path}}"
dest: "{{dest_path}}"
notify: restart httpd
handlers:
- name: restart httpd
service:
name: httpd
state: restarted
[amit@slave tmp]$ cat f.yml
---
- hosts: webservers
become: true
become_user: root
vars:
jenkins_admin_username: edureka
jenkins_admin_password: edureka
roles:
- geerlingguy.java
- geerlingguy.jenkins