forked from AntoDevOps-Github/Devops-Clarification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcentos_ansible
112 lines (85 loc) · 1.96 KB
/
centos_ansible
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
Control machine
***************
useradd ansible
passwd ansible
visudo
ansible ALL=(ALL) NOPASSWD: ALL
su - ansible
172.31.20.136 hari03042.mylabserver.com hari03042
172.31.24.115 hari03043.mylabserver.com hari03043
sudo yum install epel-release
sudo yum install ansible
ansible --version
sudo vi /etc/ansible/ansible.cfg
ssh-keygen -t rsa
ls -lah
cd .ssh
ls -ltr
ip a
sudo vi /etc/hosts
ssh-copy-id hari03041
ssh-copy-id hari03042
ssh-copy-id hari03043
ssh-copy-id hari03044
cat /etc/ansible/ansible.cfg | grep -v '#'
sudo vi /etc/ansible/hosts // create a group and give only IP
sudo touch /var/log/ansible.log
sudo chown ansible:ansible /var/log/ansible.log
ls -ld /var/log/ansible.log
ansible -m ping all
Client System
*****
useradd ansible
passwd ansible
visudo
su - ansible
ip a
uname -n
sudo vi /etc/hosts
cd .ssh
ls -ltr
cat authorized_keys
***************************** Ansible Server
mkdir playbook
vi first.yml
- hosts: web
user: ansible
sudo: yes
connection: ssh
gather_facts: no
tasks:
- name: Copy from the files directory test file
action: copy src=/home/ansible/files/test4.txt dest=/home/ansible/test4.txt owner=ansible group=ansible mode=0655 backup=yes
vi tree.yml
- hosts: web
user: ansible
sudo: yes
connection: ssh
tasks:
- name: Install tree software
action: package name=tree state=latest
tree
vi webserver.yml
- hosts: web
user: ansible
sudo: yes
connection: ssh
gather_facts: no
tasks:
- name: Install Apache Web Server
action: yum name=httpd state=installed
- name: Restart HTTPD
action: service name=httpd state=restarted
systemctl status httpd
ansible -m ping all
ansible-playbook first.yml
ansible-playbook tree.yml
ansible-playbook webserver.yml
- hosts: web
user: ansible
sudo: yes
connection: ssh
gather_facts: no
tasks:
- name: Copy from the files directory test file
action: copy src=/home/ansible/playbook/multi-module/webapp/target/webapp.war dest=/opt/tomcat/webapps