ansible简介
1.Ansible可以同时管理Redhat系的Linux,Debian系的Linux,以及Windows主机。管理节点只在执行脚本时与远程主机连接,没有特别的同步机制,所以断电等异常一般不会影响ansbile。
2.ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。ansible是基于模块工作的,本身没有批量部署的能力。真正具有批量部署的是ansible所运行的模块,ansible只是提供一种框架。主要包括:
(1)、连接插件connection plugins:负责和被监控端实现通信;
(2)、host inventory:指定操作的主机,是一个配置文件里面定义监控的主机;
(3)、各种模块核心模块、command模块、自定义模块;
(4)、借助于插件完成记录日志邮件等功能;
(5)、playbook:剧本执行多个任务时,非必需可以让节点一次性运行多个任务。
3.ansible的架构:连接其他主机默认使用ssh协议
ansible安装
ansible环境安装部署
管理端:192.168.35.100
被管理端:192.168.35.101
被管理端:192.168.35.102
所有管理端关闭防火墙
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
安装epel源
[[email protected] ~]# yum install -y epel-release
安装ansible服务
[[email protected] ~]# yum install ansible -y
查看ansible版本
[[email protected] ~]# ansible --version
ansible 2.9.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
树状结构展示文件夹
[[email protected] ~]# yum install tree -y //安装tree服务
[[email protected] ~]# tree /etc/ansible/
/etc/ansible/
├── ansible.cfg #ansible的配置文件
├── hosts #ansible的主仓库,用于存储需要管理的远程主机的相关信息
└── roles1 directory, 2 files
配置主机清单
[[email protected] ~]# vim /etc/ansible/hosts
#在25~28行添加
[webserver]
192.168.35.101
[mysql]
192.168.35.102
配置**对验证
[[email protected] ~]# ssh-****** -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): #回车
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): #输入密码abc123
Enter same passphrase again: #再次输入密码abc123
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:45OoRKsFf6MuqeGFWfRdORMW+kVjkCpeULT7fhXgvuQ [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| oo =++ |
| . +.=.. |
| . .o.=... |
| . ...o+ +. . |
| ..o.ooS.. . |
| ++ o o.o o . |
|.o o= + +.o o |
|..++ + ... E |
|.o.o+ .. |
+----[SHA256]-----+
秘钥对传送
[[email protected] ~]# ssh-copy-id [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.35.101 (192.168.35.101)' can't be established.
ECDSA key fingerprint is SHA256:JsLSnAul/dncM/HPvpJWWB09dHLzpIfArHv1fWjQyA8.
ECDSA key fingerprint is MD5:d1:b7:d7:74:c6:4a:2a:7b:fc:33:8c:9c:3a:f2:6e:8a.
Are you sure you want to continue connecting (yes/no)? yes #输入yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password: # 输入要访问主机密码123123Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.[[email protected] ~]# ssh-copy-id [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.35.102 (192.168.35.102)' can't be established.
ECDSA key fingerprint is SHA256:JsLSnAul/dncM/HPvpJWWB09dHLzpIfArHv1fWjQyA8.
ECDSA key fingerprint is MD5:d1:b7:d7:74:c6:4a:2a:7b:fc:33:8c:9c:3a:f2:6e:8a.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.
模块管理
1、command模块
命令格式:ansible [主机] [-m 模块] [-a args]
ansible-doc -l //列出所有已安装的模块 注:按q退出
ansible-doc -s yum //-s列出yum模块描述信息和操作动作
查看对方系统时间
//指定分类执行date
[[email protected] ~]# ansible webserver -m command -a 'date'
Enter passphrase for key '/root/.ssh/id_rsa': #输入密码abc123
192.168.35.101 | CHANGED | rc=0 >>
2020年 01月 26日 星期日 11:58:25 CST[[email protected] ~]# ssh-agent bash #免交互代理
[[email protected] ~]# ssh-add
Enter passphrase for /root/.ssh/id_rsa: #输入密码abc123
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
[[email protected] ~]# ansible webserver -m command -a 'date' #在进行验证,直接就会查看,无需输入密码
192.168.35.101 | CHANGED | rc=0 >>
2020年 01月 26日 星期日 12:00:10 CST[[email protected] ~]# ansible mysql -m command -a 'date'
Enter passphrase for key '/root/.ssh/id_rsa': #输入密码abc123
192.168.35.102 | CHANGED | rc=0 >>
2020年 01月 26日 星期日 12:26:18 CST[[email protected] ~]# ssh-agent bash #免交互代理
[[email protected] ~]# ssh-add
Enter passphrase for /root/.ssh/id_rsa:
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
[[email protected] ~]# ansible mysql -m command -a 'date'
192.168.35.102 | CHANGED | rc=0 >>
2020年 01月 26日 星期日 12:50:33 CST或者:
指定ip执行date
[[email protected] ~]# ansible 192.168.35.101 -m command -a 'date'
Enter passphrase for key '/root/.ssh/id_rsa':
192.168.35.101 | CHANGED | rc=0 >>
2020年 01月 26日 星期日 12:46:00 CST[[email protected] ~]# ansible 192.168.35.102 -m command -a 'date'
Enter passphrase for key '/root/.ssh/id_rsa':
192.168.35.102 | CHANGED | rc=0 >>
2020年 01月 26日 星期日 12:46:10 CST
所有hosts主机执行date命令
[[email protected] ~]# ansible all -m command -a 'date'
192.168.35.102 | CHANGED | rc=0 >>
2020年 01月 26日 星期日 12:53:39 CST192.168.35.101 | CHANGED | rc=0 >>
2020年 01月 26日 星期日 12:53:39 CST
如果不加-m模块,则默认运行command模块
[[email protected] ~]# ansible all -a 'ls /'
192.168.35.102 | CHANGED | rc=0 >>
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var192.168.35.101 | CHANGED | rc=0 >>
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var
2、cron模块
两种状态(state):present表示添加(可以省略),absent表示移除。
查看cron模块信息
[[email protected] ~]# ansible-doc -s cron
创建计划性任务并查看
[[email protected] ~]# ansible webserver -m cron -a 'minute="*/1" job="/bin/echo heihei" name="test cron job"'
192.168.35.101 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"envs": [],
"jobs": [
"test cron job"
]
}
[[email protected] ~]# ansible webserver -a 'crontab -l'
192.168.35.101 | CHANGED | rc=0 >>
#Ansible: test cron job
*/1 * * * * /bin/echo heihei
移除计划任务,假如该计划任务没有取名字,name=None即可
[[email protected] ~]# ansible webserver -m cron -a 'name="test cron job" state=absent'
192.168.35.101 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"envs": [],
"jobs": []
}
[[email protected] ~]# ansible webserver -a 'crontab -l'192.168.35.101 | CHANGED | rc=0 >>
3、user模块
user模块是请求的是useradd, userdel, usermod三个指令
查看user模块信息
[[email protected] ~]# ansible-doc -s user
创建用户test01
[[email protected] ~]# ansible mysql -m user -a 'name="test01"'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 1001,
"home": "/home/test01",
"name": "test01",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1001
}
[[email protected] ~]# ansible mysql -m command -a 'tail /etc/passwd'
192.168.35.102 | CHANGED | rc=0 >>
sssd:x:992:987:User for sssd:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:991:986::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
shan:x:1000:1000:shan:/home/shan:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
test01:x:1001:1001::/home/test01:/bin/bash
删除用户test01
[[email protected] ~]# ansible mysql -m user -a 'name="test01" state=absent'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"force": false,
"name": "test01",
"remove": false,
"state": "absent"
}
[[email protected] ~]# ansible mysql -m command -a 'tail /etc/passwd'
192.168.35.102 | CHANGED | rc=0 >>
setroubleshoot:x:993:988::/var/lib/setroubleshoot:/sbin/nologin
sssd:x:992:987:User for sssd:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:991:986::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
shan:x:1000:1000:shan:/home/shan:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
4、group模块
group模块请求的是groupadd, groupdel, groupmod 三个指令。
查看group模块信息
[[email protected] ~]# ansible-doc -s group
创建组
[[email protected] ~]# ansible mysql -m group -a 'name=mysql gid=306 system=yes'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"gid": 306,
"name": "mysql",
"state": "present",
"system": true
}
[[email protected] ~]# ansible mysql -a 'tail /etc/group'
192.168.35.102 | CHANGED | rc=0 >>
slocate:x:21:
postdrop:x:90:
postfix:x:89:
stapusr:x:156:
stapsys:x:157:
stapdev:x:158:
tcpdump:x:72:
shan:x:1000:
apache:x:48:
mysql:x:306:
创建用户添加到组里面
[[email protected] ~]# ansible mysql -m user -a 'name=test01 uid=306 system=yes group=mysql'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 306,
"home": "/home/test01",
"name": "test01",
"shell": "/bin/bash",
"state": "present",
"system": true,
"uid": 306
}
[[email protected] ~]# ansible mysql -a 'tail /etc/passwd'
192.168.35.102 | CHANGED | rc=0 >>
sssd:x:992:987:User for sssd:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:991:986::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
shan:x:1000:1000:shan:/home/shan:/bin/bash
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
test01:x:306:306::/home/test01:/bin/bash[[email protected] ~]# ansible mysql -a 'id test01'
192.168.35.102 | CHANGED | rc=0 >>
uid=306(test01) gid=306(mysql) 组=306(mysql)
5、copy模块
查看copy模块信息
[[email protected] ~]# ansible-doc -s copy
复制文件
src:源
dest:目标
owner:属主
mode:权限
[[email protected] ~]# ansible mysql -m copy -a 'src=/etc/fstab dest=/opt/fstab.back owner=root mode=640'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"checksum": "779a5cdfc49a154200e8d8f1383714711cbbdf3e",
"dest": "/opt/fstab.back",
"gid": 0,
"group": "root",
"md5sum": "c850cea297d9fb76af5351854f120776",
"mode": "0640",
"owner": "root",
"secontext": "system_u:object_r:usr_t:s0",
"size": 541,
"src": "/root/.ansible/tmp/ansible-tmp-1580017743.15-32004883742223/source",
"state": "file",
"uid": 0
}[[email protected] ~]# ansible mysql -a 'ls -l /opt' #查看
192.168.35.102 | CHANGED | rc=0 >>
总用量 16
-rw-r-----. 1 root root 541 1月 26 13:49 fstab.back
-rw-r--r--. 1 root root 11798 10月 8 10:33 httpd.txt
drwxr-xr-x. 2 root root 6 3月 26 2015 rh[[email protected] ~]# ansible mysql -a 'cat /opt/fstab.back' #查看
192.168.35.102 | CHANGED | rc=0 >>
#
# /etc/fstab
# Created by anaconda on Tue Oct 8 16:42:28 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=9ae2cb5c-bdd9-4ede-b66a-46bf98bb25b6 /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
将hello heihei!写入/opt/fstab.back
[[email protected] ~]# ansible mysql -m copy -a 'content="hello heihei!" dest=/opt/fstab.back'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"checksum": "b783c5c2da963523d21deff007f6e6b97fc625dc",
"dest": "/opt/fstab.back",
"gid": 0,
"group": "root",
"md5sum": "0e7a9bdc00d20b6e3e1b03d836095644",
"mode": "0640",
"owner": "root",
"secontext": "system_u:object_r:usr_t:s0",
"size": 13,
"src": "/root/.ansible/tmp/ansible-tmp-1580018234.45-115774729655214/source",
"state": "file",
"uid": 0
}
[[email protected] ~]# ansible mysql -a 'cat /opt/fstab.back' #查看
192.168.35.102 | CHANGED | rc=0 >>
hello heihei!
6、file模块
查看file模块信息
[[email protected] ~]# ansible-doc -s file
创建用户和组
[[email protected] ~]# ansible mysql -m user -a 'name=mysql system=yes'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 100,
"home": "/home/mysql",
"name": "mysql",
"shell": "/bin/bash",
"state": "present",
"system": true,
"uid": 305
}
[[email protected] ~]# ansible mysql -m group -a 'name=mysql system=yes'
192.168.35.102 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"gid": 306,
"name": "mysql",
"state": "present",
"system": true
}
修改文件的属主属组权限等
[[email protected] ~]# ansible mysql -m file -a 'owner=mysql group=mysql mode=644 path=/opt/fstab.back'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"gid": 306,
"group": "mysql",
"mode": "0644",
"owner": "mysql",
"path": "/opt/fstab.back",
"secontext": "system_u:object_r:usr_t:s0",
"size": 13,
"state": "file",
"uid": 305
}
设置/opt/fstab.link为/opt/fstab.back的链接文件
[[email protected] ~]# ansible mysql -m file -a 'path=/opt/fstab.link src=/opt/fstab.back state=link'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"dest": "/opt/fstab.link",
"gid": 0,
"group": "root",
"mode": "0777",
"owner": "root",
"secontext": "unconfined_u:object_r:usr_t:s0",
"size": 15,
"src": "/opt/fstab.back",
"state": "link",
"uid": 0
}
删除一个文件
[[email protected] ~]# ansible mysql -m file -a "path=/opt/fstab.back state=absent"
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"path": "/opt/fstab.back",
"state": "absent"
}
创建一个文件
[[email protected] ~]# ansible mysql -m file -a "path=/opt/test state=touch"
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"dest": "/opt/test",
"gid": 0,
"group": "root",
"mode": "0644",
"owner": "root",
"secontext": "unconfined_u:object_r:usr_t:s0",
"size": 0,
"state": "file",
"uid": 0
}
7、ping模块
查看ping模块信息
[[email protected] ~]# ansible-doc -s ping
测试被管理主机是否在线
[[email protected] ~]# ansible all -m ping
192.168.35.101 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.35.102 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
8、yum模块
查看yum模块信息
[[email protected] ~]# ansible-doc -s yum
yum安装httpd
[[email protected] ~]# ansible mysql -m yum -a 'name=httpd'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"changes": {
"installed": [
"httpd"
]
},
"msg": "",
"rc": 0,
"results": [
"Loaded plugins: fastestmirror, langpacks\nLoading mirror speeds from cached hostfile\n * base: mirrors.aliyun.com\n * extras: mirrors.cn99.com\n * updates: mirrors.aliyun.com\nResolving Dependencies\n--> Running transaction check\n---> Package httpd.x86_64 0:2.4.6-90.el7.centos will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package Arch Version Repository Size\n================================================================================\nInstalling:\n httpd x86_64 2.4.6-90.el7.centos base 2.7 M\n\nTransaction Summary\n================================================================================\nInstall 1 Package\n\nTotal download size: 2.7 M\nInstalled size: 9.4 M\nDownloading packages:\nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n Installing : httpd-2.4.6-90.el7.centos.x86_64 1/1 \n Verifying : httpd-2.4.6-90.el7.centos.x86_64 1/1 \n\nInstalled:\n httpd.x86_64 0:2.4.6-90.el7.centos \n\nComplete!\n"
]
}
在mysql主机上查看
[[email protected] ~]# rpm -q httpd
httpd-2.4.6-90.el7.centos.x86_64
卸载httpd
ansible mysql -m yum -a 'name=zsh state=absent'
9、service模块
查看service模块信息
[[email protected] ~]# ansible-doc -s service
启动httpd服务
[[email protected] ~]# ansible mysql -m service -a 'enabled=true name=httpd state=started'
192.168.35.102 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"enabled": true,
"name": "httpd",
"state": "started",
"status": {
"ActiveEnterTimestampMonotonic": "0",
"ActiveExitTimestampMonotonic": "0",
"ActiveState": "inactive",
"After": "basic.target system.slice -.mount nss-lookup.target systemd-journald.socket remote-fs.target tmp.mount network.target",
"AllowIsolate": "no",
"AmbientCapabilities": "0",
"AssertResult": "no",
"AssertTimestampMonotonic": "0",
"Before": "shutdown.target",
"BlockIOAccounting": "no",
"BlockIOWeight": "18446744073709551615",
"CPUAccounting": "no",
"CPUQuotaPerSecUSec": "infinity",
"CPUSchedulingPolicy": "0",
"CPUSchedulingPriority": "0",
"CPUSchedulingResetOnFork": "no",
"CPUShares": "18446744073709551615",
"CanIsolate": "no",
"CanReload": "yes",
"CanStart": "yes",
"CanStop": "yes",
"CapabilityBoundingSet": "18446744073709551615",
"ConditionResult": "no",
"ConditionTimestampMonotonic": "0",
"Conflicts": "shutdown.target",
"ControlPID": "0",
"DefaultDependencies": "yes",
"Delegate": "no",
"Description": "The Apache HTTP Server",
"DevicePolicy": "auto",
"Documentation": "man:httpd(8) man:apachectl(8)",
"EnvironmentFile": "/etc/sysconfig/httpd (ignore_errors=no)",
"ExecMainCode": "0",
"ExecMainExitTimestampMonotonic": "0",
"ExecMainPID": "0",
"ExecMainStartTimestampMonotonic": "0",
"ExecMainStatus": "0",
"ExecReload": "{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -k graceful ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }",
"ExecStart": "{ path=/usr/sbin/httpd ; argv[]=/usr/sbin/httpd $OPTIONS -DFOREGROUND ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }",
"ExecStop": "{ path=/bin/kill ; argv[]=/bin/kill -WINCH ${MAINPID} ; 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/httpd.service",
"GuessMainPID": "yes",
"IOScheduling": "0",
"Id": "httpd.service",
"IgnoreOnIsolate": "no",
"IgnoreOnSnapshot": "no",
"IgnoreSIGPIPE": "yes",
"InactiveEnterTimestampMonotonic": "0",
"InactiveExitTimestampMonotonic": "0",
"JobTimeoutAction": "none",
"JobTimeoutUSec": "0",
"KillMode": "control-group",
"KillSignal": "18",
"LimitAS": "18446744073709551615",
"LimitCORE": "18446744073709551615",
"LimitCPU": "18446744073709551615",
"LimitDATA": "18446744073709551615",
"LimitFSIZE": "18446744073709551615",
"LimitLOCKS": "18446744073709551615",
"LimitMEMLOCK": "65536",
"LimitMSGQUEUE": "819200",
"LimitNICE": "0",
"LimitNOFILE": "4096",
"LimitNPROC": "7168",
"LimitRSS": "18446744073709551615",
"LimitRTPRIO": "0",
"LimitRTTIME": "18446744073709551615",
"LimitSIGPENDING": "7168",
"LimitSTACK": "18446744073709551615",
"LoadState": "loaded",
"MainPID": "0",
"MemoryAccounting": "no",
"MemoryCurrent": "18446744073709551615",
"MemoryLimit": "18446744073709551615",
"MountFlags": "0",
"Names": "httpd.service",
"NeedDaemonReload": "no",
"Nice": "0",
"NoNewPrivileges": "no",
"NonBlocking": "no",
"NotifyAccess": "main",
"OOMScoreAdjust": "0",
"OnFailureJobMode": "replace",
"PermissionsStartOnly": "no",
"PrivateDevices": "no",
"PrivateNetwork": "no",
"PrivateTmp": "yes",
"ProtectHome": "no",
"ProtectSystem": "no",
"RefuseManualStart": "no",
"RefuseManualStop": "no",
"RemainAfterExit": "no",
"Requires": "-.mount basic.target",
"RequiresMountsFor": "/var/tmp",
"Restart": "no",
"RestartUSec": "100ms",
"Result": "success",
"RootDirectoryStartOnly": "no",
"RuntimeDirectoryMode": "0755",
"SameProcessGroup": "no",
"SecureBits": "0",
"SendSIGHUP": "no",
"SendSIGKILL": "yes",
"Slice": "system.slice",
"StandardError": "inherit",
"StandardInput": "null",
"StandardOutput": "journal",
"StartLimitAction": "none",
"StartLimitBurst": "5",
"StartLimitInterval": "10000000",
"StartupBlockIOWeight": "18446744073709551615",
"StartupCPUShares": "18446744073709551615",
"StatusErrno": "0",
"StopWhenUnneeded": "no",
"SubState": "dead",
"SyslogLevelPrefix": "yes",
"SyslogPriority": "30",
"SystemCallErrorNumber": "0",
"TTYReset": "no",
"TTYVHangup": "no",
"TTYVTDisallocate": "no",
"TasksAccounting": "no",
"TasksCurrent": "18446744073709551615",
"TasksMax": "18446744073709551615",
"TimeoutStartUSec": "1min 30s",
"TimeoutStopUSec": "1min 30s",
"TimerSlackNSec": "50000",
"Transient": "no",
"Type": "notify",
"UMask": "0022",
"UnitFilePreset": "disabled",
"UnitFileState": "disabled",
"Wants": "system.slice",
"WatchdogTimestampMonotonic": "0",
"WatchdogUSec": "0"
}
}
查看web服务器httpd运行状态
[[email protected] ~]# ansible mysql -a 'systemctl status httpd'192.168.35.102 | CHANGED | rc=0 >>
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2020-01-26 14:27:42 CST; 4s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 11076 (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─11076 /usr/sbin/httpd -DFOREGROUND
├─11080 /usr/sbin/httpd -DFOREGROUND
├─11081 /usr/sbin/httpd -DFOREGROUND
├─11082 /usr/sbin/httpd -DFOREGROUND
├─11083 /usr/sbin/httpd -DFOREGROUND
└─11084 /usr/sbin/httpd -DFOREGROUND1月 26 14:27:42 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
1月 26 14:27:42 localhost.localdomain httpd[11076]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
1月 26 14:27:42 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
在mysql但查看服务是否开启
[[email protected] ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2020-01-26 14:27:42 CST; 2min 25s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 11076 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─11076 /usr/sbin/httpd -DFOREGROUND
├─11080 /usr/sbin/httpd -DFOREGROUND
├─11081 /usr/sbin/httpd -DFOREGROUND
├─11082 /usr/sbin/httpd -DFOREGROUND
├─11083 /usr/sbin/httpd -DFOREGROUND
└─11084 /usr/sbin/httpd -DFOREGROUND1月 26 14:27:42 localhost.localdomain systemd[1]: Starting The Apache HTTP...
1月 26 14:27:42 localhost.localdomain httpd[11076]: AH00558: httpd: Could ...
1月 26 14:27:42 localhost.localdomain systemd[1]: Started The Apache HTTP ...
Hint: Some lines were ellipsized, use -l to show in full.
10、shell模块
查看shell模块信息
[[email protected] ~]# ansible-doc -s shell
创建用户并设置密码
[[email protected] ~]# ansible webserver -m user -a 'name=xiaotian'
192.168.35.101 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"comment": "",
"create_home": true,
"group": 1001,
"home": "/home/xiaotian",
"name": "xiaotian",
"shell": "/bin/bash",
"state": "present",
"system": false,
"uid": 1001
}
[[email protected] ~]# ansible webserver -m shell -a 'echo abc123|passwd --stdin xiaotian'
192.168.35.101 | CHANGED | rc=0 >>
更改用户 xiaotian 的密码 。
passwd:所有的身份验证令牌已经成功更新。
在webserver主机上验证
[[email protected] ~]$ su - xiaotian
密码:
上一次登录:日 1月 26 14:35:05 CST 2020pts/0 上
11、script模块
查看script模块信息
[[email protected] ~]# ansible-doc -s group
循环脚本
[[email protected] ~]# vim test.sh
#!/bin/bash
echo "hello ansible from script"> /opt/script.txt
赋予执行权限
[[email protected] ~]# chmod +x test.sh
执行脚本
[[email protected] ~]# ansible all -m script -a 'test.sh'
192.168.35.101 | CHANGED => {
"changed": true,
"rc": 0,
"stderr": "Shared connection to 192.168.35.101 closed.\r\n",
"stderr_lines": [
"Shared connection to 192.168.35.101 closed."
],
"stdout": "",
"stdout_lines": []
}
192.168.35.102 | CHANGED => {
"changed": true,
"rc": 0,
"stderr": "Shared connection to 192.168.35.102 closed.\r\n",
"stderr_lines": [
"Shared connection to 192.168.35.102 closed."
],
"stdout": "",
"stdout_lines": []
}
在其他主机上进行查看
[[email protected] ~]# cat /opt/script.txt
hello ansible from script
12、setup模块
查看setup模块信息
[[email protected] ~]# ansible-doc -s setup
获取mysql组主机的facts信息
[[email protected] ~]# ansible mysql -m setup
192.168.35.102 | SUCCESS => {
"ansible_facts": {
"ansible_all_ipv4_addresses": [
"192.168.122.1",
"192.168.35.102"
],
"ansible_all_ipv6_addresses": [
"fe80::6ec5:6d7:1b18:466e",
"fe80::2a3:b621:ca01:463e",
"fe80::d4e2:ef9e:6820:145a"
],
"ansible_apparmor": {
"status": "disabled"
},
"ansible_architecture": "x86_64",
"ansible_bios_date": "05/19/2017",
"ansible_bios_version": "6.00",
"ansible_cmdline": {
"BOOT_IMAGE": "/vmlinuz-3.10.0-693.el7.x86_64",
"LANG": "zh_CN.UTF-8",
"crashkernel": "auto",
"quiet": true,
"rd.lvm.lv": "centos/swap",
"rhgb": true,
"ro": true,
"root": "/dev/mapper/centos-root"
},
"ansible_date_time": {
"date": "2020-01-26",
"day": "26",
"epoch": "1580021223",
"hour": "14",
"iso8601": "2020-01-26T06:47:03Z",
"iso8601_basic": "20200126T144703839438",
"iso8601_basic_short": "20200126T144703",
"iso8601_micro": "2020-01-26T06:47:03.839737Z",
"minute": "47",
"month": "01",
"second": "03",
"time": "14:47:03",
"tz": "CST",
"tz_offset": "+0800",
"weekday": "星期日",
"weekday_number": "0",
"weeknumber": "03",
"year": "2020"
},
"ansible_default_ipv4": {
"address": "192.168.35.102",
"alias": "ens33",
"broadcast": "192.168.35.255",
"gateway": "192.168.35.2",
"interface": "ens33",
"macaddress": "00:0c:29:0b:95:af",
"mtu": 1500,
"netmask": "255.255.255.0",
"network": "192.168.35.0",
"type": "ether"
},
"ansible_default_ipv6": {},
"ansible_device_links": {
"ids": {
"dm-0": [
"dm-name-centos-root",
"dm-uuid-LVM-Vd3qo4fjG0zAztPzhE0U2VAOEXyWiE4HQk0rxHACeYC02wdfdsNamtkgn0Miap3j"
],
"dm-1": [
"dm-name-centos-swap",
"dm-uuid-LVM-Vd3qo4fjG0zAztPzhE0U2VAOEXyWiE4HO1ZJUfjvqcCcHS9mfBgEl4vu6YFU3lxN"
],
"dm-2": [
"dm-name-centos-home",
"dm-uuid-LVM-Vd3qo4fjG0zAztPzhE0U2VAOEXyWiE4HGfE5dS0SGHNbmcPvbhfdu8oz5RSH2j8o"
],
"sda2": [
"lvm-pv-uuid-NEk1jn-mf6M-frj0-qulZ-hPtl-Lnjk-36HpFc"
],
"sr0": [
"ata-VMware_Virtual_IDE_CDROM_Drive_10000000000000000001"
]
},
"labels": {
"sr0": [
"CentOS\\x207\\x20x86_64"
]
},
"masters": {
"sda2": [
"dm-0",
"dm-1",
"dm-2"
]
},
"uuids": {
"dm-0": [
"a4ace815-d0e5-4c72-8b37-0d93190f181b"
],
"dm-1": [
"c65c2724-7438-41ee-b5b2-179900702598"
],
"dm-2": [
"fee8d416-f01d-44b7-8e30-3f1b760ff5a3"
],
"sda1": [
"9ae2cb5c-bdd9-4ede-b66a-46bf98bb25b6"
],
"sr0": [
"2017-09-06-10-51-00-00"
]
}
},
"ansible_devices": {
"dm-0": {
"holders": [],
"host": "",
"links": {
"ids": [
"dm-name-centos-root",
"dm-uuid-LVM-Vd3qo4fjG0zAztPzhE0U2VAOEXyWiE4HQk0rxHACeYC02wdfdsNamtkgn0Miap3j"
],
"labels": [],
"masters": [],
"uuids": [
"a4ace815-d0e5-4c72-8b37-0d93190f181b"
]
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "1",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "",
"sectors": "41943040",
"sectorsize": "512",
"size": "20.00 GB",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"dm-1": {
"holders": [],
"host": "",
"links": {
"ids": [
"dm-name-centos-swap",
"dm-uuid-LVM-Vd3qo4fjG0zAztPzhE0U2VAOEXyWiE4HO1ZJUfjvqcCcHS9mfBgEl4vu6YFU3lxN"
],
"labels": [],
"masters": [],
"uuids": [
"c65c2724-7438-41ee-b5b2-179900702598"
]
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "1",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "",
"sectors": "8388608",
"sectorsize": "512",
"size": "4.00 GB",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"dm-2": {
"holders": [],
"host": "",
"links": {
"ids": [
"dm-name-centos-home",
"dm-uuid-LVM-Vd3qo4fjG0zAztPzhE0U2VAOEXyWiE4HGfE5dS0SGHNbmcPvbhfdu8oz5RSH2j8o"
],
"labels": [],
"masters": [],
"uuids": [
"fee8d416-f01d-44b7-8e30-3f1b760ff5a3"
]
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "1",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "",
"sectors": "20963328",
"sectorsize": "512",
"size": "10.00 GB",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"sda": {
"holders": [],
"host": "SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)",
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": []
},
"model": "VMware Virtual S",
"partitions": {
"sda1": {
"holders": [],
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": [
"9ae2cb5c-bdd9-4ede-b66a-46bf98bb25b6"
]
},
"sectors": "12582912",
"sectorsize": 512,
"size": "6.00 GB",
"start": "2048",
"uuid": "9ae2cb5c-bdd9-4ede-b66a-46bf98bb25b6"
},
"sda2": {
"holders": [
"centos-root",
"centos-swap",
"centos-home"
],
"links": {
"ids": [
"lvm-pv-uuid-NEk1jn-mf6M-frj0-qulZ-hPtl-Lnjk-36HpFc"
],
"labels": [],
"masters": [
"dm-0",
"dm-1",
"dm-2"
],
"uuids": []
},
"sectors": "71301120",
"sectorsize": 512,
"size": "34.00 GB",
"start": "12584960",
"uuid": null
}
},
"removable": "0",
"rotational": "1",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "deadline",
"sectors": "83886080",
"sectorsize": "512",
"size": "40.00 GB",
"support_discard": "0",
"vendor": "VMware,",
"virtual": 1
},
"sr0": {
"holders": [],
"host": "IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)",
"links": {
"ids": [
"ata-VMware_Virtual_IDE_CDROM_Drive_10000000000000000001"
],
"labels": [
"CentOS\\x207\\x20x86_64"
],
"masters": [],
"uuids": [
"2017-09-06-10-51-00-00"
]
},
"model": "VMware IDE CDR10",
"partitions": {},
"removable": "1",
"rotational": "1",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "cfq",
"sectors": "8830976",
"sectorsize": "2048",
"size": "4.21 GB",
"support_discard": "0",
"vendor": "NECVMWar",
"virtual": 1
}
},
"ansible_distribution": "CentOS",
"ansible_distribution_file_parsed": true,
"ansible_distribution_file_path": "/etc/redhat-release",
"ansible_distribution_file_variety": "RedHat",
"ansible_distribution_major_version": "7",
"ansible_distribution_release": "Core",
"ansible_distribution_version": "7.4",
"ansible_dns": {
"nameservers": [
"218.2.135.1"
]
},
"ansible_domain": "localdomain",
"ansible_effective_group_id": 0,
"ansible_effective_user_id": 0,
"ansible_ens33": {
"active": true,
"device": "ens33",
"features": {
"busy_poll": "off [fixed]",
"fcoe_mtu": "off [fixed]",
"generic_receive_offload": "on",
"generic_segmentation_offload": "on",
"highdma": "off [fixed]",
"hw_tc_offload": "off [fixed]",
"l2_fwd_offload": "off [fixed]",
"large_receive_offload": "off [fixed]",
"loopback": "off [fixed]",
"netns_local": "off [fixed]",
"ntuple_filters": "off [fixed]",
"receive_hashing": "off [fixed]",
"rx_all": "off",
"rx_checksumming": "off",
"rx_fcs": "off",
"rx_vlan_filter": "on [fixed]",
"rx_vlan_offload": "on",
"rx_vlan_stag_filter": "off [fixed]",
"rx_vlan_stag_hw_parse": "off [fixed]",
"scatter_gather": "on",
"tcp_segmentation_offload": "on",
"tx_checksum_fcoe_crc": "off [fixed]",
"tx_checksum_ip_generic": "on",
"tx_checksum_ipv4": "off [fixed]",
"tx_checksum_ipv6": "off [fixed]",
"tx_checksum_sctp": "off [fixed]",
"tx_checksumming": "on",
"tx_fcoe_segmentation": "off [fixed]",
"tx_gre_csum_segmentation": "off [fixed]",
"tx_gre_segmentation": "off [fixed]",
"tx_gso_partial": "off [fixed]",
"tx_gso_robust": "off [fixed]",
"tx_ipip_segmentation": "off [fixed]",
"tx_lockless": "off [fixed]",
"tx_mpls_segmentation": "off [fixed]",
"tx_nocache_copy": "off",
"tx_scatter_gather": "on",
"tx_scatter_gather_fraglist": "off [fixed]",
"tx_sctp_segmentation": "off [fixed]",
"tx_sit_segmentation": "off [fixed]",
"tx_tcp6_segmentation": "off [fixed]",
"tx_tcp_ecn_segmentation": "off [fixed]",
"tx_tcp_mangleid_segmentation": "off",
"tx_tcp_segmentation": "on",
"tx_udp_tnl_csum_segmentation": "off [fixed]",
"tx_udp_tnl_segmentation": "off [fixed]",
"tx_vlan_offload": "on [fixed]",
"tx_vlan_stag_hw_insert": "off [fixed]",
"udp_fragmentation_offload": "off [fixed]",
"vlan_challenged": "off [fixed]"
},
"hw_timestamp_filters": [],
"ipv4": {
"address": "192.168.35.102",
"broadcast": "192.168.35.255",
"netmask": "255.255.255.0",
"network": "192.168.35.0"
},
"ipv6": [
{
"address": "fe80::6ec5:6d7:1b18:466e",
"prefix": "64",
"scope": "link"
},
{
"address": "fe80::2a3:b621:ca01:463e",
"prefix": "64",
"scope": "link"
},
{
"address": "fe80::d4e2:ef9e:6820:145a",
"prefix": "64",
"scope": "link"
}
],
"macaddress": "00:0c:29:0b:95:af",
"module": "e1000",
"mtu": 1500,
"pciid": "0000:02:01.0",
"promisc": false,
"speed": 1000,
"timestamping": [
"tx_software",
"rx_software",
"software"
],
"type": "ether"
},
"ansible_env": {
"HOME": "/root",
"LANG": "zh_CN.UTF-8",
"LESSOPEN": "||/usr/bin/lesspipe.sh %s",
"LOGNAME": "root",
"LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:",
"MAIL": "/var/mail/root",
"PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin",
"PWD": "/root",
"SELINUX_LEVEL_REQUESTED": "",
"SELINUX_ROLE_REQUESTED": "",
"SELINUX_USE_CURRENT_RANGE": "",
"SHELL": "/bin/bash",
"SHLVL": "2",
"SSH_CLIENT": "192.168.35.100 57834 22",
"SSH_CONNECTION": "192.168.35.100 57834 192.168.35.102 22",
"SSH_TTY": "/dev/pts/2",
"TERM": "xterm",
"USER": "root",
"XDG_DATA_DIRS": "/root/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/",
"XDG_RUNTIME_DIR": "/run/user/0",
"XDG_SESSION_ID": "54",
"_": "/usr/bin/python"
},
"ansible_fibre_channel_wwn": [],
"ansible_fips": false,
"ansible_form_factor": "Other",
"ansible_fqdn": "localhost.localdomain",
"ansible_hostname": "localhost",
"ansible_hostnqn": "",
"ansible_interfaces": [
"lo",
"virbr0",
"virbr0-nic",
"ens33"
],
"ansible_is_chroot": false,
"ansible_iscsi_iqn": "iqn.1994-05.com.redhat:14e59cf19ce4",
"ansible_kernel": "3.10.0-693.el7.x86_64",
"ansible_kernel_version": "#1 SMP Tue Aug 22 21:09:27 UTC 2017",
"ansible_lo": {
"active": true,
"device": "lo",
"features": {
"busy_poll": "off [fixed]",
"fcoe_mtu": "off [fixed]",
"generic_receive_offload": "on",
"generic_segmentation_offload": "on",
"highdma": "on [fixed]",
"hw_tc_offload": "off [fixed]",
"l2_fwd_offload": "off [fixed]",
"large_receive_offload": "off [fixed]",
"loopback": "on [fixed]",
"netns_local": "on [fixed]",
"ntuple_filters": "off [fixed]",
"receive_hashing": "off [fixed]",
"rx_all": "off [fixed]",
"rx_checksumming": "on [fixed]",
"rx_fcs": "off [fixed]",
"rx_vlan_filter": "off [fixed]",
"rx_vlan_offload": "off [fixed]",
"rx_vlan_stag_filter": "off [fixed]",
"rx_vlan_stag_hw_parse": "off [fixed]",
"scatter_gather": "on",
"tcp_segmentation_offload": "on",
"tx_checksum_fcoe_crc": "off [fixed]",
"tx_checksum_ip_generic": "on [fixed]",
"tx_checksum_ipv4": "off [fixed]",
"tx_checksum_ipv6": "off [fixed]",
"tx_checksum_sctp": "on [fixed]",
"tx_checksumming": "on",
"tx_fcoe_segmentation": "off [fixed]",
"tx_gre_csum_segmentation": "off [fixed]",
"tx_gre_segmentation": "off [fixed]",
"tx_gso_partial": "off [fixed]",
"tx_gso_robust": "off [fixed]",
"tx_ipip_segmentation": "off [fixed]",
"tx_lockless": "on [fixed]",
"tx_mpls_segmentation": "off [fixed]",
"tx_nocache_copy": "off [fixed]",
"tx_scatter_gather": "on [fixed]",
"tx_scatter_gather_fraglist": "on [fixed]",
"tx_sctp_segmentation": "on",
"tx_sit_segmentation": "off [fixed]",
"tx_tcp6_segmentation": "on",
"tx_tcp_ecn_segmentation": "on",
"tx_tcp_mangleid_segmentation": "on",
"tx_tcp_segmentation": "on",
"tx_udp_tnl_csum_segmentation": "off [fixed]",
"tx_udp_tnl_segmentation": "off [fixed]",
"tx_vlan_offload": "off [fixed]",
"tx_vlan_stag_hw_insert": "off [fixed]",
"udp_fragmentation_offload": "on",
"vlan_challenged": "on [fixed]"
},
"hw_timestamp_filters": [],
"ipv4": {
"address": "127.0.0.1",
"broadcast": "host",
"netmask": "255.0.0.0",
"network": "127.0.0.0"
},
"ipv6": [
{
"address": "::1",
"prefix": "128",
"scope": "host"
}
],
"mtu": 65536,
"promisc": false,
"timestamping": [
"rx_software",
"software"
],
"type": "loopback"
},
"ansible_local": {},
"ansible_lsb": {},
"ansible_lvm": {
"lvs": {
"home": {
"size_g": "10.00",
"vg": "centos"
},
"root": {
"size_g": "20.00",
"vg": "centos"
},
"swap": {
"size_g": "4.00",
"vg": "centos"
}
},
"pvs": {
"/dev/sda2": {
"free_g": "0",
"size_g": "34.00",
"vg": "centos"
}
},
"vgs": {
"centos": {
"free_g": "0",
"num_lvs": "3",
"num_pvs": "1",
"size_g": "34.00"
}
}
},
"ansible_machine": "x86_64",
"ansible_machine_id": "adff2aa4597e4efd8bdfd59111ebca58",
"ansible_memfree_mb": 404,
"ansible_memory_mb": {
"nocache": {
"free": 1045,
"used": 778
},
"real": {
"free": 404,
"total": 1823,
"used": 1419
},
"swap": {
"cached": 0,
"free": 4095,
"total": 4095,
"used": 0
}
},
"ansible_memtotal_mb": 1823,
"ansible_mounts": [
{
"block_available": 1524712,
"block_size": 4096,
"block_total": 1570304,
"block_used": 45592,
"device": "/dev/sda1",
"fstype": "xfs",
"inode_available": 3145400,
"inode_total": 3145728,
"inode_used": 328,
"mount": "/boot",
"options": "rw,seclabel,relatime,attr2,inode64,noquota",
"size_available": 6245220352,
"size_total": 6431965184,
"uuid": "9ae2cb5c-bdd9-4ede-b66a-46bf98bb25b6"
},
{
"block_available": 0,
"block_size": 2048,
"block_total": 2207296,
"block_used": 2207296,
"device": "/dev/sr0",
"fstype": "iso9660",
"inode_available": 0,
"inode_total": 0,
"inode_used": 0,
"mount": "/run/media/root/CentOS 7 x86_64",
"options": "ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500",
"size_available": 0,
"size_total": 4520542208,
"uuid": "2017-09-06-10-51-00-00"
},
{
"block_available": 4357211,
"block_size": 4096,
"block_total": 5240320,
"block_used": 883109,
"device": "/dev/mapper/centos-root",
"fstype": "xfs",
"inode_available": 10364012,
"inode_total": 10485760,
"inode_used": 121748,
"mount": "/",
"options": "rw,seclabel,relatime,attr2,inode64,noquota",
"size_available": 17847136256,
"size_total": 21464350720,
"uuid": "a4ace815-d0e5-4c72-8b37-0d93190f181b"
},
{
"block_available": 2608621,
"block_size": 4096,
"block_total": 2617856,
"block_used": 9235,
"device": "/dev/mapper/centos-home",
"fstype": "xfs",
"inode_available": 5240673,
"inode_total": 5240832,
"inode_used": 159,
"mount": "/home",
"options": "rw,seclabel,relatime,attr2,inode64,noquota",
"size_available": 10684911616,
"size_total": 10722738176,
"uuid": "fee8d416-f01d-44b7-8e30-3f1b760ff5a3"
}
],
"ansible_nodename": "localhost.localdomain",
"ansible_os_family": "RedHat",
"ansible_pkg_mgr": "yum",
"ansible_proc_cmdline": {
"BOOT_IMAGE": "/vmlinuz-3.10.0-693.el7.x86_64",
"LANG": "zh_CN.UTF-8",
"crashkernel": "auto",
"quiet": true,
"rd.lvm.lv": [
"centos/root",
"centos/swap"
],
"rhgb": true,
"ro": true,
"root": "/dev/mapper/centos-root"
},
"ansible_processor": [
"0",
"GenuineIntel",
"Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz"
],
"ansible_processor_cores": 1,
"ansible_processor_count": 1,
"ansible_processor_threads_per_core": 1,
"ansible_processor_vcpus": 1,
"ansible_product_name": "VMware Virtual Platform",
"ansible_product_serial": "VMware-56 4d 02 06 c0 fb bb ac-5d 3a 87 5d f7 0b 95 af",
"ansible_product_uuid": "06024D56-FBC0-ACBB-5D3A-875DF70B95AF",
"ansible_product_version": "None",
"ansible_python": {
"executable": "/usr/bin/python",
"has_sslcontext": true,
"type": "CPython",
"version": {
"major": 2,
"micro": 5,
"minor": 7,
"releaselevel": "final",
"serial": 0
},
"version_info": [
2,
7,
5,
"final",
0
]
},
"ansible_python_version": "2.7.5",
"ansible_real_group_id": 0,
"ansible_real_user_id": 0,
"ansible_selinux": {
"config_mode": "enforcing",
"mode": "permissive",
"policyvers": 28,
"status": "enabled",
"type": "targeted"
},
"ansible_selinux_python_present": true,
"ansible_service_mgr": "systemd",
"ansible_ssh_host_key_ecdsa_public": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJqF8vZ9sUxQs1hTonVRdR8yt27BZ/f+LJYTkoFz1dFLTLnDuGFvcoIgIq2kJXuUwD3emzIAsR2judu0wqpy4OQ=",
"ansible_ssh_host_key_ed25519_public": "AAAAC3NzaC1lZDI1NTE5AAAAIMixzMu0wuVxviPg6kuRuBfYEBak25WXby/dCb3pJ5Ec",
"ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDWQocNJ2dReAA7vGNaNGnCHAAnY8OnPx0d2hxnsRV6qQYeIiEm+gm4GnWOoAFeFTZfSs5q1ktzHYx/UVNfmkI5S4BY15uiVTDHMVYULxI1230x3Dbr4FiPZj0AtljJaUZLtpJLzJ5x1g8g7C3LCKV7KDLikDTJMhrijlbG0qLz5AhGk6piuLJ6oUC+xVAl4HqHD2Q4Qp4dzwqQL/Gghpa2b28LCDCQbRBWtFzXo9/LqDkJTd7j8KYLz7GuWM5RvbB1jXyT5H/mwSkmxnPUSiPzplIZyWV3NL6dCjBHQcGelfzRxWeI/XFvFNXlW6swgw6IDobR4ADLFL/NG3Wmfq/n",
"ansible_swapfree_mb": 4095,
"ansible_swaptotal_mb": 4095,
"ansible_system": "Linux",
"ansible_system_capabilities": [
"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",
"35",
"36+ep"
],
"ansible_system_capabilities_enforced": "True",
"ansible_system_vendor": "VMware, Inc.",
"ansible_uptime_seconds": 16341,
"ansible_user_dir": "/root",
"ansible_user_gecos": "root",
"ansible_user_gid": 0,
"ansible_user_id": "root",
"ansible_user_shell": "/bin/bash",
"ansible_user_uid": 0,
"ansible_userspace_architecture": "x86_64",
"ansible_userspace_bits": "64",
"ansible_virbr0": {
"active": false,
"device": "virbr0",
"features": {
"busy_poll": "off [fixed]",
"fcoe_mtu": "off [fixed]",
"generic_receive_offload": "on",
"generic_segmentation_offload": "on",
"highdma": "off [requested on]",
"hw_tc_offload": "off [fixed]",
"l2_fwd_offload": "off [fixed]",
"large_receive_offload": "off [fixed]",
"loopback": "off [fixed]",
"netns_local": "on [fixed]",
"ntuple_filters": "off [fixed]",
"receive_hashing": "off [fixed]",
"rx_all": "off [fixed]",
"rx_checksumming": "off [fixed]",
"rx_fcs": "off [fixed]",
"rx_vlan_filter": "off [fixed]",
"rx_vlan_offload": "off [fixed]",
"rx_vlan_stag_filter": "off [fixed]",
"rx_vlan_stag_hw_parse": "off [fixed]",
"scatter_gather": "on",
"tcp_segmentation_offload": "on",
"tx_checksum_fcoe_crc": "off [fixed]",
"tx_checksum_ip_generic": "on",
"tx_checksum_ipv4": "off [fixed]",
"tx_checksum_ipv6": "off [fixed]",
"tx_checksum_sctp": "off [fixed]",
"tx_checksumming": "on",
"tx_fcoe_segmentation": "off [requested on]",
"tx_gre_csum_segmentation": "on",
"tx_gre_segmentation": "on",
"tx_gso_partial": "on",
"tx_gso_robust": "off [requested on]",
"tx_ipip_segmentation": "on",
"tx_lockless": "on [fixed]",
"tx_mpls_segmentation": "on",
"tx_nocache_copy": "off",
"tx_scatter_gather": "on",
"tx_scatter_gather_fraglist": "on",
"tx_sctp_segmentation": "off [requested on]",
"tx_sit_segmentation": "on",
"tx_tcp6_segmentation": "on",
"tx_tcp_ecn_segmentation": "on",
"tx_tcp_mangleid_segmentation": "on",
"tx_tcp_segmentation": "on",
"tx_udp_tnl_csum_segmentation": "on",
"tx_udp_tnl_segmentation": "on",
"tx_vlan_offload": "on",
"tx_vlan_stag_hw_insert": "on",
"udp_fragmentation_offload": "off [requested on]",
"vlan_challenged": "off [fixed]"
},
"hw_timestamp_filters": [],
"id": "8000.525400143999",
"interfaces": [
"virbr0-nic"
],
"ipv4": {
"address": "192.168.122.1",
"broadcast": "192.168.122.255",
"netmask": "255.255.255.0",
"network": "192.168.122.0"
},
"macaddress": "52:54:00:14:39:99",
"mtu": 1500,
"promisc": false,
"stp": true,
"timestamping": [
"rx_software",
"software"
],
"type": "bridge"
},
"ansible_virbr0_nic": {
"active": false,
"device": "virbr0-nic",
"features": {
"busy_poll": "off [fixed]",
"fcoe_mtu": "off [fixed]",
"generic_receive_offload": "on",
"generic_segmentation_offload": "on",
"highdma": "off [fixed]",
"hw_tc_offload": "off [fixed]",
"l2_fwd_offload": "off [fixed]",
"large_receive_offload": "off [fixed]",
"loopback": "off [fixed]",
"netns_local": "off [fixed]",
"ntuple_filters": "off [fixed]",
"receive_hashing": "off [fixed]",
"rx_all": "off [fixed]",
"rx_checksumming": "off [fixed]",
"rx_fcs": "off [fixed]",
"rx_vlan_filter": "off [fixed]",
"rx_vlan_offload": "off [fixed]",
"rx_vlan_stag_filter": "off [fixed]",
"rx_vlan_stag_hw_parse": "off [fixed]",
"scatter_gather": "on",
"tcp_segmentation_offload": "off",
"tx_checksum_fcoe_crc": "off [fixed]",
"tx_checksum_ip_generic": "off [requested on]",
"tx_checksum_ipv4": "off [fixed]",
"tx_checksum_ipv6": "off [fixed]",
"tx_checksum_sctp": "off [fixed]",
"tx_checksumming": "off",
"tx_fcoe_segmentation": "off [fixed]",
"tx_gre_csum_segmentation": "off [fixed]",
"tx_gre_segmentation": "off [fixed]",
"tx_gso_partial": "off [fixed]",
"tx_gso_robust": "off [fixed]",
"tx_ipip_segmentation": "off [fixed]",
"tx_lockless": "on [fixed]",
"tx_mpls_segmentation": "off [fixed]",
"tx_nocache_copy": "off",
"tx_scatter_gather": "on",
"tx_scatter_gather_fraglist": "on",
"tx_sctp_segmentation": "off [fixed]",
"tx_sit_segmentation": "off [fixed]",
"tx_tcp6_segmentation": "off [requested on]",
"tx_tcp_ecn_segmentation": "off [requested on]",
"tx_tcp_mangleid_segmentation": "off",
"tx_tcp_segmentation": "off [requested on]",
"tx_udp_tnl_csum_segmentation": "off [fixed]",
"tx_udp_tnl_segmentation": "off [fixed]",
"tx_vlan_offload": "on",
"tx_vlan_stag_hw_insert": "on",
"udp_fragmentation_offload": "off [requested on]",
"vlan_challenged": "off [fixed]"
},
"hw_timestamp_filters": [],
"macaddress": "52:54:00:14:39:99",
"mtu": 1500,
"promisc": true,
"timestamping": [
"rx_software",
"software"
],
"type": "ether"
},
"ansible_virtualization_role": "guest",
"ansible_virtualization_type": "VMware",
"discovered_interpreter_python": "/usr/bin/python",
"gather_subset": [
"all"
],
"module_setup": true
},
"changed": false
}