ansible 的常用模块操作

ansible 的常用模块操作

文章目录

一. 常用模块

模块类别模块
文件模块copy:将本地文件复制到受管主机
file:设置文件的权限和其他属性
lineinfile:确保特定行是否在文件中
synchronize:使用rsync同步内容
软件包模块package:使用操作系统本机的自动检测软件包管理器管理软件包
yum:使用yum管理软件包
apt:使用APT管理软件包
dnf:使用dnf管理软件包
gem:管理Ruby gem
pip:从PyPI管理Python软件包
系统模块firewalld:使用firewalld管理防火墙
reboot:重启计算机
service:管理服务
user:添加、删除和管理用户帐户
Net Tools模块get_url:通过HTTP、HTTPS或FTP下载文件
nmcli:管理网络
uri:与Web服务交互

二. Ansible命令行选项

配置文件指令命令行选项
inventory-i
remote_user-u
become–become,-b
become_method–become-method
become_user–become-user
become_ask_pass–ask-become-pass、-K

三. 运行临时命令

  • 使用临时命令可以快速执行单个Ansible任务,不需要将它保存下来供以后再次运行
  • 是简单的在线操作,无需编写playbook即可运行
  • 临时命令对快速测试和更改很有用

1. 使用临时命令通过模块来执行任务

1.1. ansible 常用模块,raw,command,shell的区别
  • shell模块调用的/bin/sh指令执行
  • command模块不是调用的shell的指令,所以没有bash的环境变量
  • raw很多地方和shell类似,更多的地方建议使用shell和command模块。但是如果是使用老版本python,需要用到raw,又或者是客户端是路由器,因为没有安装python模块,那就需要使用raw模块了
  • 没有幂等性
1.2 幂等性
  • 幂等性指的是多次操作,结果是一致的
  • 使用-o选项以单行格式显示Ansible临时命令的输出
  • raw,command,shell 没有幂等性,其他模块大部分都是幂等的,可以自动进行更改跟踪

临时命令 ad-hoc

2. 本机清单和环境
2.1 清单文件
httpd 是创建的
[root@SYL2 ~]# cd /opt/httpd/
[root@SYL2 httpd]# vim inventory
[root@SYL2 httpd]# cat inventory 
[webservers]
SYL3 ansible_user=root ansible_password=run123456
[root@SYL2 httpd]# cat inventory |grep checking
[root@SYL2 httpd]# cat ansible.cfg |grep checking
# uncomment this to disable SSH key host checking
host_key_checking = False
# host key checking setting above.
[root@SYL2 httpd]# 
[root@SYL2 httpd]# vim ansible.cfg 
[root@SYL2 httpd]# cat ansible.cfg |grep /opt/httpd/inventory
inventory      =/opt/httpd/inventory
[root@SYL2 httpd]# 


识别域名
[root@SYL2 httpd]# vim /etc/hosts
[root@SYL2 httpd]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.232.128 SYL3
[root@SYL2 httpd]# 
2.2 环境
控制节点(控制主机)
ip 192.168.232.129
域名 SYL2
版本 CentOS Stream release 8

受管节点(受管主机)
ip 192.168.232.128
域名 SYL3
版本 Red Hat Enterprise Linux release 8.5
2.3 查看帮助文档命令
[root@SYL2 httpd]# ansible-doc ping 
3. ping
3.1 用于检查指定节点机器是否连通
[root@SYL2 httpd]# ansible all -m ping
SYL3 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "ping": "pong"
}
[root@SYL2 httpd]# 
4. command
4.1 command模块用于在远程主机上执行命令,ansible默认就是使用command模块。不支持管道符,不支持重定向
1.查看版本
[root@SYL2 httpd]# ansible all -m command -a 'cat /etc/redhat-release'
SYL3 | CHANGED | rc=0 >>
Red Hat Enterprise Linux release 8.5 (Ootpa)

2.查看目录
[root@SYL2 httpd]# ansible all -m command -a 'ls /tmp'
SYL3 | CHANGED | rc=0 >>
ansible_command_payload_9silzmua
vmware-root_1004-2957649132
vmware-root_1010-2957124853
vmware-root_1014-2965448048
[root@SYL2 httpd]# 

[root@SYL2 httpd]# ansible all -m command -a 'ls /tmp' -o
SYL3 | CHANGED | rc=0 | (stdout) aaaa\nansible_command_payload_isdmq8ja\nmuc\nvmware-root_1004-2957649132\nvmware-root_1010-2957124853\nvmware-root_1014-2965448048
[root@SYL2 httpd]# 

3.创建文件
[root@SYL2 httpd]# ansible all -m command -a 'touch /tmp/aaaa'
[WARNING]: Consider using the file module with state=touch rather than running
'touch'.  If you need to use command because file is insufficient you can add
'warn: false' to this command task or set 'command_warnings=False' in
ansible.cfg to get rid of this message.
SYL3 | CHANGED | rc=0 >>

[root@SYL2 httpd]# 
在受管主机查看
[root@SYL3 ~]# ls /tmp/
aaaa                         vmware-root_1010-2957124853
vmware-root_1004-2957649132  vmware-root_1014-2965448048
[root@SYL3 ~]#         
4.2 不支持管道符,不支持重定向
重定向
[root@SYL2 httpd]# ansible all -m command -a 'echo aaa > /tmp/muc '
SYL3 | CHANGED | rc=0 >>
aaa > /tmp/muc
[root@SYL2 httpd]# 

[root@SYL3 ~]# ls /tmp/
aaaa                         vmware-root_1010-2957124853
vmware-root_1004-2957649132  vmware-root_1014-2965448048


管道符
[root@SYL2 httpd]# ansible all -m command -a 'ps -ef|grep sleep' 
SYL3 | FAILED | rc=1 >>
error: unsupported SysV option

Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1).non-zero return code
[root@SYL2 httpd]# 
5. raw
5.1 raw模块用于在远程主机上执行命令,其支持管道符与重定向
重定向

[root@SYL2 httpd]# ansible all -m raw -a 'echo 1223 > /tmp/muc'SYL3 | CHANGED | rc=0 >>
Shared connection to syl3 closed.

[root@SYL2 httpd]# ansible all -m raw -a 'echo 666 >> /tmp/muc'
SYL3 | CHANGED | rc=0 >>
Shared connection to syl3 closed.

[root@SYL2 httpd]# 

[root@SYL3 ~]# ls /tmp/
aaaa  vmware-root_1004-2957649132  vmware-root_1014-2965448048
muc   vmware-root_1010-2957124853
[root@SYL3 ~]# ls /tmp/muc 
/tmp/muc
[root@SYL3 ~]# cat /tmp/muc 
1223
[root@SYL3 ~]# cat /tmp/muc 
1223
666
[root@SYL3 ~]# 


管道符
[root@SYL2 httpd]# ansible all -m raw -a 'ps -ef|grep sleep'SYL3 | CHANGED | rc=0 >>
root      724913    1670  0 15:16 pts/0    00:00:00 sleep 500
root      724940    1669  0 15:16 ?        00:00:00 bash -c export LANG="en_US";export LANGUAGE="en_US";export LC_ALL="en_US";free;echo finalshell_separator;uptime;echo finalshell_separator;cat /proc/net/dev;echo finalshell_separator;df;echo finalshell_separator;sleep 1;free;echo finalshell_separator;uptime;echo finalshell_separator;cat /proc/net/dev;echo finalshell_separator;df;echo finalshell_separator;
root      724957  724940  0 15:16 ?        00:00:00 sleep 1
root      724999  720210  0 15:16 pts/2    00:00:00 bash -c ps -ef|grep sleep
root      725019  724999  0 15:16 pts/2    00:00:00 grep sleep
Shared connection to syl3 closed.

[root@SYL2 httpd]#

[root@SYL3 ~]# sleep 500
6.shell
6.1 shell模块用于在受控机上执行受控机上的脚本,亦可直接在受控机上执行命令。
6.2 shell模块亦支持管道与重定向
[root@SYL2 httpd]# ansible all -m shell -a 'set'

创建简单脚本,受管
[root@SYL3 ~]# mkdir /scripts
[root@SYL3 ~]# vim /scripts/test.sh
[root@SYL3 ~]# cat /scripts/test.sh
#!/bin/bash

nohup sleep 7000 &
[root@SYL3 ~]# 

主控
[root@SYL2 httpd]# ansible all -m shell -a '/bin/bash /scripts/test.sh'
SYL3 | CHANGED | rc=0 >>

[root@SYL2 httpd]# ansible all -m shell -a 'ps -ef|grep sleep
'SYL3 | CHANGED | rc=0 >>
root      899244       1  0 16:40 ?        00:00:00 sleep 7000
root      899927    1669  0 16:41 ?        00:00:00 bash -c export LANG="en_US";export LANGUAGE="en_US";export LC_ALL="en_US";free;echo finalshell_separator;uptime;echo finalshell_separator;cat /proc/net/dev;echo finalshell_separator;df;echo finalshell_separator;sleep 1;free;echo finalshell_separator;uptime;echo finalshell_separator;cat /proc/net/dev;echo finalshell_separator;df;echo finalshell_separator;
root      899944  899927  0 16:41 ?        00:00:00 sleep 1
root      900033  899134  0 16:41 pts/2    00:00:00 /bin/sh -c /usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1653468077.5401285-1002951-32489098133078/AnsiballZ_command.py && sleep 0
root      900053  900052  0 16:41 pts/2    00:00:00 /bin/sh -c ps -ef|grep sleep
root      900055  900053  0 16:41 pts/2    00:00:00 grep sleep
[root@SYL2 httpd]# 

杀掉进程
[root@SYL2 httpd]# ansible all -m shell -a 'kill -9 899244'SYL3 | CHANGED | rc=0 >>

[root@SYL2 httpd]# ansible all -m shell -a 'ps -ef|grep sleep'
SYL3 | CHANGED | rc=0 >>
root      904415    1669  0 16:43 ?        00:00:00 bash -c export LANG="en_US";export LANGUAGE="en_US";export LC_ALL="en_US";free;echo finalshell_separator;uptime;echo finalshell_separator;cat /proc/net/dev;echo finalshell_separator;df;echo finalshell_separator;sleep 1;free;echo finalshell_separator;uptime;echo finalshell_separator;cat /proc/net/dev;echo finalshell_separator;df;echo finalshell_separator;
root      904432  904415  0 16:43 ?        00:00:00 sleep 1
root      904521  903987  0 16:43 pts/2    00:00:00 /bin/sh -c /usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1653468201.1694856-1007768-108871760899245/AnsiballZ_command.py && sleep 0
root      904541  904540  0 16:43 pts/2    00:00:00 /bin/sh -c ps -ef|grep sleep
root      904543  904541  0 16:43 pts/2    00:00:00 grep sleep
[root@SYL2 httpd]# 

删除文件
[root@SYL2 httpd]# ansible all -m shell -a 'rm -rf /etc/yum.repos.d/*'
SYL3 | CHANGED | rc=0 >>

[root@SYL2 httpd]# 

[root@SYL3 ~]# cd /etc/yum.repos.d/
[root@SYL3 yum.repos.d]# ls
redhat.repo
[root@SYL3 yum.repos.d]# ls
[root@SYL3 yum.repos.d]# 

7. script
7.1 script模块用于在受控机上执行主控机上的脚本
[root@ansible ~]# ll /etc/ansible/scripts/
总用量 4
-rw-r--r--. 1 root root 61 98 18:59 a.sh
[root@ansible ~]# ansible 172.16.103.129 -m script -a '/etc/ansible/scripts/a.sh &>/tmp/a'
172.16.103.129 | SUCCESS => {
    "changed": true,
    "rc": 0,
    "stderr": "Shared connection to 172.16.103.129 closed.\r\n",
    "stderr_lines": [
        "Shared connection to 172.16.103.129 closed."
    ],
    "stdout": "",
    "stdout_lines": []
}


//查看受控机上的/tmp/a文件内容
[root@ansible ~]# ansible 172.16.103.129 -m shell -a 'cat /tmp/a'
172.16.103.129 | SUCCESS | rc=0 >>
root:x:0:0:root:/root:/bin/bash
....此处省略N行
jerry:x:1000:1000::/home/jerry:/bin/bash

//由此可见确是在受控机上执行了主控机上的脚本,且输出记录到了受控机上。因为此处 \
//的jerry用户是在受控机上才有的用户
8. template
8.1 template模块用于生成一个模板,并可将其传输至远程主机上,有传文件的功能
[root@SYL2 httpd]# cd /etc/yum.repos.d/
[root@SYL2 yum.repos.d]# ls
CentOS-Base.repo  CentOS-SIG-ansible-29.repo
[root@SYL2 yum.repos.d]# cd /opt/httpd/
[root@SYL2 httpd]# ls
 ansible.cfg   inventory 
[root@SYL2 httpd]# vim ansible.cfg 
[root@SYL2 httpd]# cat ansible.cfg |grep command_warnings
command_warnings = False //将注释取消,会把警告取消
[root@SYL2 httpd]# 

[root@SYL2 httpd]# ansible all -m template -a 'src=/etc/yum.repos.d/CentOS-Base.repo dest=/etc/yum.repos.d/CentOS-Base.repo owner=root group=root mode=0644'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "checksum": "8bbf30b2d80c3b97292ca7b32f33ef494269a5b8",
    "dest": "/etc/yum.repos.d/CentOS-Base.repo",
    "gid": 0,
    "group": "root",
    "md5sum": "ed031c350da2532e6a8d09a4d9b05278",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:system_conf_t:s0",
    "size": 1653,
    "src": "/root/.ansible/tmp/ansible-tmp-1653470010.8950334-1083231-220201675160083/source",
    "state": "file",
    "uid": 0
}
[root@SYL2 httpd]# 

src=源地址
dest=目标地址
owner=所有者
group=组
mode=权限

[root@SYL3 yum.repos.d]# ls
[root@SYL3 yum.repos.d]# ls
CentOS-Base.repo
[root@SYL3 yum.repos.d]# 
9. yum/dnf
9.1 yum模块用于在指定节点机器上通过yum管理软件,其支持的参数主要有两个
  • name:要管理的包名
  • state:要进行的操作
9.2 state常用的值:
  • latest:安装软件
  • installed:安装软件
  • present:安装软件
  • removed:卸载软件
  • absent:卸载软件
在受控机上查询看vsftpd软件是否安装
[root@SYL3 ~]# rpm -qa|grep vsftpd
[root@SYL3 ~]# 

在主控主机上使用yum模块在受控机上安装vsftp
[root@SYL2 httpd]# ansible all -m dnf -a 'name=vsftpd state=present'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "msg": "",
    "rc": 0,
    "results": [
        "Installed: vsftpd-3.0.3-34.el8.x86_64"
    ]
}
[root@SYL2 httpd]# 

查看受控机上是否安装了vsftpd
[root@SYL3 ~]# rpm -qa|grep vsftpd
vsftpd-3.0.3-34.el8.x86_64
[root@SYL3 ~]# 

卸载
[root@SYL2 httpd]# ansible all -m dnf -a 'name=vsftpd state=absent'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "msg": "",
    "rc": 0,
    "results": [
        "Removed: vsftpd-3.0.3-34.el8.x86_64"
    ]
}
[root@SYL2 httpd]# 

[root@SYL3 ~]# rpm -qa|grep vsftpd
vsftpd-3.0.3-34.el8.x86_64
[root@SYL3 ~]# rpm -qa|grep vsftpd
[root@SYL3 ~]# 

10. copy
10.1 copy模块用于复制文件至远程受控机。
[root@SYL2 httpd]# ansible all -m copy -a 'content="xixi\nhello 123\n888\n" dest=/tmp/mu'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "checksum": "c08e2c0d13a0b9fece8ce4a88669dd3db3d9f9e0",
    "dest": "/tmp/mu",
    "gid": 0,
    "group": "root",
    "md5sum": "56c91232eeacaa96c53eca66dbd095ba",
    "mode": "0644",
    "owner": "root",
    "secontext": "unconfined_u:object_r:admin_home_t:s0",
    "size": 19,
    "src": "/root/.ansible/tmp/ansible-tmp-1653470766.7468681-1112136-157273447777451/source",
    "state": "file",
    "uid": 0
}
[root@SYL2 httpd]# 

[root@SYL3 ~]# cd /tmp/
[root@SYL3 tmp]# ls
aaaa  muc                          vmware-root_1010-2957124853
mu    vmware-root_1004-2957649132  vmware-root_1014-2965448048
[root@SYL3 tmp]# cat mu
xixi
hello 123
888
[root@SYL3 tmp]# 

[root@SYL2 httpd]# ansible all -m copy -a 'src=inventory dest=/tmp/abc owner=root group=root mode=0644'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "checksum": "0dbc13c68f309ce2dfc62b3d4fd55684f0a6d5c3",
    "dest": "/tmp/abc/inventory",
    "gid": 0,
    "group": "root",
    "md5sum": "4b525f0fa149d62259f8b527dc4f2da2",
    "mode": "0644",
    "owner": "root",
    "secontext": "unconfined_u:object_r:admin_home_t:s0",
    "size": 63,
    "src": "/root/.ansible/tmp/ansible-tmp-1653470998.063784-1120985-158802732964238/source",
    "state": "file",
    "uid": 0
}
[root@SYL2 httpd]#

[root@SYL3 ~]# cd /tmp/abc
[root@SYL3 abc]# ls
[root@SYL3 abc]# ls
inventory
[root@SYL3 abc]# ll
total 4
-rw-r--r--. 1 root root 63 May 25 17:29 inventory
[root@SYL3 abc]# 
11. group
11.1 group模块用于在受控机上添加或删除组
[root@SYL2 httpd]# ansible all -m group -a 'name=tom state=present'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "gid": 1000,
    "name": "tom",
    "state": "present",
    "system": false
}
[root@SYL2 httpd]# ansible all -m group -a 'name=tom state=present gid=1500'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "gid": 1500,
    "name": "tom",
    "state": "present",
    "system": false
}
[root@SYL2 httpd]#

[root@SYL3 ~]# id tom
id: 'tom': no such user
[root@SYL3 ~]# grep tom /etc/group
tom:x:1500:
[root@SYL3 ~]# 
12. user
12.1 user模块用于管理受控机的用户帐号
system = yes 系统组
name = apache 名字
state = present 
create_home = no 家目录
shell= /sbin/nologin 登录shell 

[root@SYL2 httpd]# ansible all -m user -a 'name=apache state=present system=yes create_home=no shell=/sbin/nologin'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "comment": "",
    "create_home": false,
    "group": 992,
    "home": "/home/apache",
    "name": "apache",
    "shell": "/sbin/nologin",
    "state": "present",
    "system": true,
    "uid": 995
}
[root@SYL2 httpd]# 

[root@SYL3 ~]# id apache
uid=995(apache) gid=992(apache) groups=992(apache)
[root@SYL3 ~]# grep apache /etc/passwd
apache:x:995:992::/home/apache:/sbin/nologin
12.2 user设置密码
  • 为用户模块生成加密密码
    ansible all -i localhost, -m debug -a "msg={{ 'mypassword' | password_hash('sha512', 'mysecretsalt') }}"
    
[root@SYL2 httpd]# ansible all -m user -a 'name=tom state=present'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "comment": "",
    "create_home": true,
    "group": 1000,
    "home": "/home/tom",
    "name": "tom",
    "shell": "/bin/bash",
    "state": "present",
    "system": false,
    "uid": 1000
}

[root@SYL2 httpd]# ansible all -i localhost, -m debug -a "msg={{ 'runtt123456$' | password_hash('sha512', 'mysecretsalt') }}"
localhost | SUCCESS => {
    "msg": "$6$mysecretsalt$vpZuRrSSXQHsUTN/WtTE8l7EehFumNsOCEYmNNwjZGStqQdonzDmnClN6oKe6IFD1QwtN1X3FGiogcVrkBaUi."
}
[root@SYL2 httpd]# ansible all -i localhost, -m debug -a "msg={{ 'runtt123456$' | password_hash('sha512', 'mysecretxxxx') }}"
localhost | SUCCESS => {
    "msg": "$6$mysecretxxxx$SqXnjElYDLq3/voY1uCcbjAJ2htcZDDw3dkwcaEKAKIAV7Sqd/wXAQZ/7.DIeFjosHL.Ojm2X4dHPuFAJ0FSk/"
}
[root@SYL2 httpd]# ansible all -m user -a 'name=jerry password="$6$mysecretxxxx$SqXnjElYDLq3/voY1uCcbjAJ2htcZDDw3dkwcaEKAKIAV7Sqd/wXAQZ/7.DIeFjosHL.Ojm2X4dHPuFAJ0FSk/" state=present'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "comment": "",
    "create_home": true,
    "group": 1001,
    "home": "/home/jerry",
    "name": "jerry",
    "password": "NOT_LOGGING_PASSWORD",
    "shell": "/bin/bash",
    "state": "present",
    "system": false,
    "uid": 1001
}
[root@SYL2 httpd]#

[root@SYL3 ~]# su - tom
[tom@SYL3 ~]$ su - jerry 
Password: 
su: Authentication failure
[tom@SYL3 ~]$ su - jerry 
Password: 
Last failed login: Wed May 25 18:09:55 CST 2022 on pts/0
There were 2 failed login attempts since the last successful login.
[jerry@SYL3 ~]$ 
13. service
13.1 service模块用于管理受控机上的服务。
[root@SYL2 httpd]# ansible all -m service -a 'name=vsftpd enabled=yes state=started'
SYL3 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "enabled": true,
    "name": "vsftpd",
    "state": "started",
    "status": {
        "ActiveEnterTimestampMonotonic": "0",
        "ActiveExitTimestampMonotonic": "0",
        "ActiveState": "inactive",
        "After": "network-online.target basic.target sysinit.target systemd-journald.socket system.slice",
        "AllowIsolate": "no",
        "AllowedCPUs": "",
        "AllowedMemoryNodes": "",
        "AmbientCapabilities": "",
        "AssertResult": "no",
        "AssertTimestampMonotonic": "0",
        "Before": "shutdown.target",
        "BlockIOAccounting": "no",
        "BlockIOWeight": "[not set]",
        "CPUAccounting": "no",
        "CPUAffinity": "",
        "CPUAffinityFromNUMA": "no",
        "CPUQuotaPerSecUSec": "infinity",
        "CPUQuotaPeriodUSec": "infinity",
        "CPUSchedulingPolicy": "0",
        "CPUSchedulingPriority": "0",
        "CPUSchedulingResetOnFork": "no",
        "CPUShares": "[not set]",
        "CPUUsageNSec": "[not set]",
        "CPUWeight": "[not set]",
        "CacheDirectoryMode": "0755",
        "CanFreeze": "yes",
        "CanIsolate": "no",
        "CanReload": "no",
        "CanStart": "yes",
        "CanStop": "yes",
        "CapabilityBoundingSet": "cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock cap_ipc_owner cap_sys_module cap_sys_rawio cap_sys_chroot cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config cap_mknod cap_lease cap_audit_write cap_audit_control cap_setfcap cap_mac_override cap_mac_admin cap_syslog cap_wake_alarm cap_block_suspend cap_audit_read cap_perfmon cap_bpf",
        "CollectMode": "inactive",
        "ConditionResult": "no",
        "ConditionTimestampMonotonic": "0",
        "ConfigurationDirectoryMode": "0755",
        "Conflicts": "shutdown.target",
        "ControlPID": "0",
        "DefaultDependencies": "yes",
        "DefaultMemoryLow": "0",
        "DefaultMemoryMin": "0",
        "Delegate": "no",
        "Description": "Vsftpd ftp daemon",
        "DevicePolicy": "auto",
        "DynamicUser": "no",
        "EffectiveCPUs": "",
        "EffectiveMemoryNodes": "",
        "ExecMainCode": "0",
        "ExecMainExitTimestampMonotonic": "0",
        "ExecMainPID": "0",
        "ExecMainStartTimestampMonotonic": "0",
        "ExecMainStatus": "0",
        "ExecStart": "{ path=/usr/sbin/vsftpd ; argv[]=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }",
        "FailureAction": "none",
        "FileDescriptorStoreMax": "0",
        "FragmentPath": "/usr/lib/systemd/system/vsftpd.service",
        "FreezerState": "running",
        "GID": "[not set]",
        "GuessMainPID": "yes",
        "IOAccounting": "no",
        "IOSchedulingClass": "0",
        "IOSchedulingPriority": "0",
        "IOWeight": "[not set]",
        "IPAccounting": "no",
        "IPEgressBytes": "18446744073709551615",
        "IPEgressPackets": "18446744073709551615",
        "IPIngressBytes": "18446744073709551615",
        "IPIngressPackets": "18446744073709551615",
        "Id": "vsftpd.service",
        "IgnoreOnIsolate": "no",
        "IgnoreSIGPIPE": "yes",
        "InactiveEnterTimestampMonotonic": "0",
        "InactiveExitTimestampMonotonic": "0",
        "JobRunningTimeoutUSec": "infinity",
        "JobTimeoutAction": "none",
        "JobTimeoutUSec": "infinity",
        "KeyringMode": "private",
        "KillMode": "control-group",
        "KillSignal": "15",
        "LimitAS": "infinity",
        "LimitASSoft": "infinity",
        "LimitCORE": "infinity",
        "LimitCORESoft": "0",
        "LimitCPU": "infinity",
        "LimitCPUSoft": "infinity",
        "LimitDATA": "infinity",
        "LimitDATASoft": "infinity",
        "LimitFSIZE": "infinity",
        "LimitFSIZESoft": "infinity",
        "LimitLOCKS": "infinity",
        "LimitLOCKSSoft": "infinity",
        "LimitMEMLOCK": "65536",
        "LimitMEMLOCKSoft": "65536",
        "LimitMSGQUEUE": "819200",
        "LimitMSGQUEUESoft": "819200",
        "LimitNICE": "0",
        "LimitNICESoft": "0",
        "LimitNOFILE": "262144",
        "LimitNOFILESoft": "1024",
        "LimitNPROC": "7010",
        "LimitNPROCSoft": "7010",
        "LimitRSS": "infinity",
        "LimitRSSSoft": "infinity",
        "LimitRTPRIO": "0",
        "LimitRTPRIOSoft": "0",
        "LimitRTTIME": "infinity",
        "LimitRTTIMESoft": "infinity",
        "LimitSIGPENDING": "7010",
        "LimitSIGPENDINGSoft": "7010",
        "LimitSTACK": "infinity",
        "LimitSTACKSoft": "8388608",
        "LoadState": "loaded",
        "LockPersonality": "no",
        "LogLevelMax": "-1",
        "LogRateLimitBurst": "0",
        "LogRateLimitIntervalUSec": "0",
        "LogsDirectoryMode": "0755",
        "MainPID": "0",
        "MemoryAccounting": "yes",
        "MemoryCurrent": "[not set]",
        "MemoryDenyWriteExecute": "no",
        "MemoryHigh": "infinity",
        "MemoryLimit": "infinity",
        "MemoryLow": "0",
        "MemoryMax": "infinity",
        "MemoryMin": "0",
        "MemorySwapMax": "infinity",
        "MountAPIVFS": "no",
        "MountFlags": "",
        "NFileDescriptorStore": "0",
        "NRestarts": "0",
        "NUMAMask": "",
        "NUMAPolicy": "n/a",
        "Names": "vsftpd.service",
        "NeedDaemonReload": "no",
        "Nice": "0",
        "NoNewPrivileges": "no",
        "NonBlocking": "no",
        "NotifyAccess": "none",
        "OOMScoreAdjust": "0",
        "OnFailureJobMode": "replace",
        "PermissionsStartOnly": "no",
        "Perpetual": "no",
        "PrivateDevices": "no",
        "PrivateMounts": "no",
        "PrivateNetwork": "no",
        "PrivateTmp": "no",
        "PrivateUsers": "no",
        "ProtectControlGroups": "no",
        "ProtectHome": "no",
        "ProtectKernelModules": "no",
        "ProtectKernelTunables": "no",
        "ProtectSystem": "no",
        "RefuseManualStart": "no",
        "RefuseManualStop": "no",
        "RemainAfterExit": "no",
        "RemoveIPC": "no",
        "Requires": "system.slice sysinit.target",
        "Restart": "no",
        "RestartUSec": "100ms",
        "RestrictNamespaces": "no",
        "RestrictRealtime": "no",
        "RestrictSUIDSGID": "no",
        "Result": "success",
        "RootDirectoryStartOnly": "no",
        "RuntimeDirectoryMode": "0755",
        "RuntimeDirectoryPreserve": "no",
        "RuntimeMaxUSec": "infinity",
        "SameProcessGroup": "no",
        "SecureBits": "0",
        "SendSIGHUP": "no",
        "SendSIGKILL": "yes",
        "Slice": "system.slice",
        "StandardError": "inherit",
        "StandardInput": "null",
        "StandardInputData": "",
        "StandardOutput": "journal",
        "StartLimitAction": "none",
        "StartLimitBurst": "5",
        "StartLimitIntervalUSec": "10s",
        "StartupBlockIOWeight": "[not set]",
        "StartupCPUShares": "[not set]",
        "StartupCPUWeight": "[not set]",
        "StartupIOWeight": "[not set]",
        "StateChangeTimestampMonotonic": "0",
        "StateDirectoryMode": "0755",
        "StatusErrno": "0",
        "StopWhenUnneeded": "no",
        "SubState": "dead",
        "SuccessAction": "none",
        "SyslogFacility": "3",
        "SyslogLevel": "6",
        "SyslogLevelPrefix": "yes",
        "SyslogPriority": "30",
        "SystemCallErrorNumber": "0",
        "TTYReset": "no",
        "TTYVHangup": "no",
        "TTYVTDisallocate": "no",
        "TasksAccounting": "yes",
        "TasksCurrent": "[not set]",
        "TasksMax": "11216",
        "TimeoutStartUSec": "1min 30s",
        "TimeoutStopUSec": "1min 30s",
        "TimerSlackNSec": "50000",
        "Transient": "no",
        "Type": "forking",
        "UID": "[not set]",
        "UMask": "0022",
        "UnitFilePreset": "disabled",
        "UnitFileState": "disabled",
        "UtmpMode": "init",
        "WatchdogTimestampMonotonic": "0",
        "WatchdogUSec": "0"
    }
}
[root@SYL2 httpd]#

[root@SYL3 ~]# rpm -qa|grep vsftpd
vsftpd-3.0.3-34.el8.x86_64
[root@SYL3 ~]# systemctl status vsftpd
● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; ena>
   Active: active (running) since Wed 2022-05-25 18:15:20 CST;>
  Process: 1094653 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsft>
 Main PID: 1094654 (vsftpd)
    Tasks: 1 (limit: 11216)
   Memory: 584.0K
   CGroup: /system.slice/vsftpd.service
           └─1094654 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

May 25 18:15:20 SYL3 systemd[1]: Starting Vsftpd ftp daemon...
May 25 18:15:20 SYL3 systemd[1]: Started Vsftpd ftp daemon.
[root@SYL3 ~]# 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值