forked from RAHAMSHAIK007/febbatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ansible-day-01
83 lines (71 loc) · 2.44 KB
/
ansible-day-01
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
MAIN SERVER (ANSIBLE)
amazon-linux-extras install ansible2 -y
yum install python python-pip python-level openssl -y
vim /etc/ansible/hosts (line 13 edit)
vim /etc/ansible/ansible.cfg (line 14 & 22 edit)
ALL SERVERS:
useradd ansible
passwd ansible
visudo
vim /etc/ssh/sshd_config
systemctl restart sshd
systemctl status sshd
su - ansible
hostname -i
sudo hostnamectl set-hostname (set as per node name)
MAIN SERVER (ANSIBLE)
ssh-keygen
ssh-copy-id ansible@private-ip pf node
ctrl + d
============================================================================
1 hostname -i
2 ssh-keygen
3 ssh-copy-id ansible@172.31.14.202
4 sudo hostnamectl set-hostname mainserver
5 ssh 'ansible@172.31.14.202'
6 ssh-copy-id ansible@172.31.5.56
7* ssh 'ansible@172.31.5.56
8 ssh-copy-id ansible@172.31.4.163
9 ssh 'ansible@172.31.4.163'
10 ssh-copy-id ansible@172.31.11.160
11 ssh 'ansible@172.31.11.160'
12 ansible all --list-hosts
13 ansible dev --list-hosts
14 ansible test --list-hosts
15 ansible all --list-hosts
16 ansible all[0] --list-hosts
17 ansible all[1] --list-hosts
18 ansible all[2] --list-hosts
19 ansible all[-1] --list-hosts
20 ansible all[-2] --list-hosts
21 ansible all --list-hosts
22 ansible all[1:3] --list-hosts
23 cat /etc/ansible/hosts
24 ansible all -a "ls"
25 ansible all -a "touch file1"
26 ansible all -a "ls"
27 ansible all -a "mkdir dir1"
28 ansible all -a "ls"
29 ansible all -a "useradd devops"
30 ansible all -a "sudo useradd devops"
31 ansible all -a "cat /etc/passwd"
32 ansible all -b -a "yum install git -y"
33 ansible all -b -a "git --version"
34 ansible all -b -a "yum remove git -y"
35 ansible all -b -m yum -a "pkg=git state=present"
36 ansible all -b -a "git --version"
37 ansible all -b -m yum -a "pkg=httpd state=present"
38 ansible all -b -m yum -a "pkg=httpd state=absent"
39 ansible all -b -m yum -a "pkg=httpd state=present"
40 ansible all -b -m yum -a "pkg=httpd state=latest"
41 ansible all -b -m yum -a "pkg=httpd state=started"
42 ansible all -b -m yum -a "name=httpd state=started"
43 ansible all -b -m service -a "name=httpd state=started"
44 ll
45 ansible all -b -m user -a "name=siraj"
46 vim raham.txt
47 cat raham.txt
48 ansible all -b -m copy -a "src=raham.txt dest=/tmp"
49 ansible all -a "ls"
50 ansible all -a "ls /tmp"
51 history