-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathAravind
More file actions
140 lines (118 loc) · 2.9 KB
/
Aravind
File metadata and controls
140 lines (118 loc) · 2.9 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
Aravind
Ansible Installation process in Master
===================================================
yum install epel-release -y
yum install ansible -y
ansible --version
cd /etc/ansible (we can see hosts file)
ansible --list-hosts all
vi /etc/ansible/hosts (Add the servers in Inventory/hosts file)
[redhat]
172.31.85.233
[debian]
172.31.94.133
ansible -m ping redhat
ansible -m ping all
<node_name> ansible_host=<pvt_ip> ansible_user =<username> ansible_ssh_private_key_file = <*.pem>
n1 ansible_host=172.31.81.39 ansible_user=ec2-user ansible_ssh_private_key_file=/root/Ansible.pem
n2 ansible_host=172.31.93.28 ansible_user=ec2-user ansible_ssh_private_key_file=/root/Ansible.pem
adhoc commands
----------------------------------
ansible -m command -a "ls" all –b
ansible -m yum -a "pkg=git state=present/absent/latest" -b all
ansible -m service -a "name=httpd state=started" -b all
ansible -m user -a "name=Chris state=present" -b all
playbooks
-------------------------------
vi /etc/ansible/ansible.cfg
interpreter_python=auto_silent
command_warnings=False
---
- hosts: all
become: true
tasks:
- user: name=John
---
- name: Installing package
hosts: all
become: true
tasks:
- name: Installing git package
yum:
name: git
state: installed
---
- name: Creating a file
hosts: all
become: true
tasks:
- name: Creating a file
file:
path: /home/ec2-user/testfile
state: touch
---
- name: Copying a file
hosts: all
become: true
tasks:
- name: Copying a file
copy:
src: /home/ec2-user/index.html
dest: /home/ec2-user/
---
- name: Installing httpd
hosts: all
become: true
tasks:
- name: Installing httpd
yum:
name: httpd
state: installed
- name: Start service httpd
service:
name: httpd
state: started
handlers
---------------------------
---
- name: Installing httpd
hosts: all
become: true
tasks:
- name: Installing httpd
yum:
name: httpd
state:
notify: start httpd service
handlers:
- name: start httpd service
service:
name: httpd
state: started
TOMCAT Installation in test server using linux
---------------------------------------------
yum install java-1.8* -y
download tomcat (wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.56/bin/apache-tomcat-9.0.56.tar.gz)
tar -xvzf apache-tomcat-9.0.56.tar.gz
cd apache-tomcat-9.0.56.tar.gz/bin/
./startup.sh
Tomcat Installation using Playbooks
==================================
---
- name: Setup Tomcat
hosts: node3
become: true
tasks:
- name: Install Java in Redhat
yum:
name: java
state: installed
when: ansible_os_family == "RedHat"
- name: Install Java in Debian
apt:
name: default-jdk
state: present
when: ansible_os_family == "Debian"
- name: Download Tomcat
get_url:
url: https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.56/bin/apache-tomcat-9.0.56.tar.gz