# 20190605

ansible重點:

{% embed url="<https://blog.51cto.com/11886307/2385720>" %}

![](/files/-LgaBBMouaC1Y3ujGFa5)

![](/files/-Lgaa4R1LPfUEDpLKTGf)

![](/files/-LgaaCUjyFpwTS3Fexkl)

\*先確保 sshd有啟動

\[監控端]:

```
# yum install epel-release
# yum install ansible -y
# vim /etc/ansible/hosts
```

![](/files/-LgaZrBVPvelXsTLyn6b)

```
# ansible app1 -m command -a "ls /tmp"
```

![](/files/-Lga_9fqdjq_Xlb0Fvaw)

```
# ansible app1 -m command -a "ls /root"
```

![](/files/-Lga_YthLYNFDH5Vh0SF)

```
# ansible app1 -m command -a "ls /root" -v
# ansible app1 -m command -a "ls /root" -vv
# ansible app1 -m command -a "ls /root" -vvv
```

![](/files/-LgaaPPuMQ3MHryWB3gs)

![](/files/-Lgaan0EgKhKI7ZHYcYl)

![](/files/-Lgaar4AOS6nr-70cYwM)

```
# ansible all --list-hosts
```

![](/files/-Lgab--sz1MY5U6CdRWY)

```
# ansible all -m shell -a "ls /root/a*"
```

![](/files/-LgabBHSnpqHIFjvywmt)

```
# ansible app1 -m script -a a.sh
```

![](/files/-LgabNA-8b_q28Mil2v9)

\[被控端]

![](/files/-LgabghqQvfAvvKmShXx)

\[監控端]

```
# ansible app1 -m copy -a "src=/root/mya.txt dest=/root/myb.txt backup=yes"
```

![](/files/-Lgabr5L_skvBYCUCYxH)

\[被控端]

![](/files/-Lgac5I7PsGAd-dx9IPv)

\[監控端]

```
# ansible app1 -m copy -a "src=/root/mya.txt dest=/root/myb.txt backup=yes mode=600 owner=user"
```

![](/files/-LgacR-mDQQDZdY7sXKC)

\[被控端]

![](/files/-LgacW02dMao23kliylL)

\[監控端]

```
# ansible app1 -m fetch -a "src=/etc/passwd dest=/tmp"
```

![](/files/-LgadIwzeOeV-ZiRv_z3)

![](/files/-Lgad-BFFVRcVtTkT4KX)

```
# ansible app1 -m file -a "path=/root/aa owner=user mode=600"
```

![](/files/-LgbIvcpuvHhEPRTYU7N)

\[被控端]

![](/files/-LgbJA2tk3IZ_Oe5R_Lt)

\[監控端]

```
# ansible app1 -a command -a "rpm -q v"
```

![](/files/-LgbJOtTIrM4HYx3RHDR)

```
# ansible app1 -m command -a "rpm -q vsftpd"
# ansible app1 -m yum -a "name=vsftpd state=absent"
```

![](/files/-LgbNBVVFh7R_Rnn7ZIx)

```
# ansible app1 -m command -a "rpm -q vsftpd"
# ansible app1 -m yum -a "name=vsftpd"
```

![](/files/-LgbQFgsu_oLJbqGl8XR)

```
# ansible app1 -m command -a "rpm -q vsftpd"
```

![](/files/-LgbQquK3vfdmqjm6DWa)

```
# ansible app1 -m command -a "systemctl status httpd"
# ansible app1 -m service -a "name=httpd state=started"
# ansible app1 -m service -a "name=httpd state=stoped"
# ansible app1 -m service -a "name=httpd state=restarted"
# ansible app1 -m service -a "name=httpd state=reloaded"
```

![](/files/-LgbR7b0j8WLM_i9P-JK)

![](/files/-LgbhwTUf9MiF_bl3yWN)

![](/files/-Lgbi3gXEZ8un92JPSXm)

![](/files/-LgbiFDA_yaBM0TpGsEr)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cf337188.gitbook.io/01/20190605.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
