部署Ansible与常用模块

1. 构建Ansible清单

1. 1 清单作用

定义了Ansible管理的一批主机名单,通过执行Ansible模块,在调用过程中直接对清单中的主机进行批量管理。

1.2 默认清单位置
  • 默认位置:/etc/ansible/host

  • 使用规则:对于默认清单我们一般不使用,通常为了方便每一位管理者的管理,管理者均会在自己的文件夹目录中设置自己的清单目录。

1.3 使用静态清单指定受管主机

静态清单文件是指定Ansible目标受管主机的文本文件。可以使用多种不同的格式编写此文件,包括INI样式或YAML。

在最简单的形式中。INI样式的静态清单文件是受管主机的主机名或IP地址的列表,每行一个:

[root@localhost ansible]# ls
ansible.cfg  hosts  roles
[root@localhost ansible]# vim hosts...
# Ex 1: Ungrouped hosts, specify before any group headers.## green.example.com
## blue.example.com
## 192.168.100.1
## 192.168.100.10

但通常而言,可以将受管主机组织为主机组。通过主机组,可以更加有效的对一系列系统运行Ansible。这时,每一部分的开头为以中括号括起来的主机组名称。其后为该组中每一受管主机的主机名或IP地址,每行一个。

# Ex 2: A collection of hosts belonging to the 'webservers' group## [webservers]
## alpha.example.org
## beta.example.org
## 192.168.1.100
## 192.168.1.110## www[001:006].example.com# Ex 3: A collection of database servers in the 'dbservers' group## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57# Here's another example of host ranges, this time there are no
# leading 0s:## db-[99:101]-node.example.com
1.4 验证清单
  • 1.命令验证计算机是否存在于清单中:
[root@localhost ~]# ansible 192.168.159.138 --list-hostshosts (1):192.168.159.138
  • 2.查看不存在的
[root@localhost ~]# ansible 192.168.159.139 --list-hosts
[WARNING]: Could not match supplied host pattern, ignoring: 192.168.159.139
[WARNING]: No hosts matched, nothing to dohosts (0):
  • 3.运行以下命令来列出指定组中的所有主机:
[root@localhost ~]# vim /etc/ansible/hosts
...
## db-[99:101]-node.example.com[test]
192.168.159.138
192.168.159.137
192.168.159.134[root@localhost ~]# ansible test --list-hostshosts (3):192.168.159.138192.168.159.137192.168.159.134
1.5 覆盖清单的位置

/etc/ansible/hosts文件被视为系统的默认静态清单文件。不过,通常的做法是不使用该文件,而是在Ansible配置文件中为清单文件定义一个不同的位置。

1.6
  • 列出默认清单文件中的所有受管主机:
[root@localhost ansible]# ansible all --list-hostshosts (4):1.1.1.12.2.2.23.3.3.312.12.12.12
  • 列出不属于任何组的受管主机:
[root@localhost ansible]# ansible ungrouped --list-hosts
[WARNING]: No hosts matched, nothing to dohosts (0):

常用的模块

1. ansible常用模块使用详解

  • ansible常用模块有:
    ping
    yum
    template
    copy
    user
    group
    service
    raw
    command
    shell
    script
  • ansible常用模块raw、command、shell的区别:
    shell模块调用的/bin/sh指令执行
    command模块不是调用的shell的指令,所以没有bash的环境变量
    raw很多地方和shell类似,更多的地方建议使用shell和command模块。但是如果是使用老版本python,需要用到raw,又或者是客户端是路由器,因为没有安装python模块,那就需要使用raw模块了

2. ansible常用模块之ping

[root@localhost ~]# ansible 192.168.159.138 -m ping
192.168.159.138 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": false,"ping": "pong"
}
2.1 ping模块的用法
[root@localhost ~]# ansible-doc ping
> PING    (/usr/lib/python3.6/site-packages/ansible/modules/system/ping.py)A trivial test module, this module always returns `pong' on successfulcontact. It does not make sense in playbooks, but it is useful from`/usr/bin/ansible' to verify the ability to login and that a usablePython is configured. This is NOT ICMP ping, this is just a trivial testmodule that requires Python on the remote-node. For Windows targets, usethe [win_ping] module instead. For Network targets, use the [net_ping]module instead....

3. ansible常用模块之command

command模块用于在远程主机上执行命令,ansible默认就是使用command模块。
command模块有一个缺陷就是不能使用管道符和重定向功能。
  • 查看受控主机的/tmp目录内容
[root@localhost ~]# ansible 192.168.159.138 -a 'ls /tmp'
192.168.159.138 | CHANGED | rc=0 >>
ansible_command_payload_brfsj9y9
ks-script-zrpwd43g
vmware-root_912-2697663791
vmware-root_931-3988621659
vmware-root_937-4013854423
  • 在受控主机的/tmp目录下新建一个文件test
[root@localhost ~]# ansible 192.168.159.138 -a 'touch /tmp/test'
[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.
192.168.159.138 | CHANGED | rc=0 >>
[root@localhost ~]#  ansible 192.168.159.138 -a 'ls /tmp'
192.168.159.138 | CHANGED | rc=0 >>
ansible_command_payload_c151sy03
ks-script-zrpwd43g
test
vmware-root_912-2697663791
vmware-root_931-3988621659
vmware-root_937-4013854423
  • command模块不支持管道符,不支持重定向
[root@localhost ~]# ansible 192.168.159.138 -a "echo 'hello world' > /tmp/test"
192.168.159.138 | CHANGED | rc=0 >>
hello world > /tmp/test
[root@localhost ~]# ansible 192.168.159.138 -a 'ps -ef|grep vsftpd'
192.168.159.138 | FAILED | rc=1 >>
error: unsupported SysV optionUsage: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

4. ansible常用模块之raw

ansible常用模块之raw
  • 支持重定向
[root@localhost ~]#  ansible 192.168.159.138 -m raw -a 'echo "hello world" > /tmp/test'
192.168.159.138 | CHANGED | rc=0 >>
Shared connection to 192.168.159.138 closed.[root@localhost ~]# ansible 192.168.159.138 -a 'cat /tmp/test'
192.168.159.138 | CHANGED | rc=0 >>
hello world
  • 支持管道符
[root@localhost ~]#  ansible 192.168.159.138 -m raw -a 'cat /tmp/test|grep -Eo hello'
192.168.159.138 | CHANGED | rc=0 >>
hello
Shared connection to 192.168.159.138 closed.

5. ansible常用模块之shell

shell模块用于在受控机上执行受控机上的脚本,亦可直接在受控机上执行命令。shell模块亦支持管道与重定向。
[root@localhost ~]# ansible all -m shell -a 'uptime'
192.168.159.138 | CHANGED | rc=0 >>19:48:31 up  2:36,  2 users,  load average: 0.02, 0.01, 0.00
[root@localhost ~]# ansible all -m shell -a 'uptime'
192.168.159.138 | CHANGED | rc=0 >>19:48:47 up  2:37,  2 users,  load average: 0.02, 0.01, 0.00

6. ansible常用模块之script

script模块用于在受控机上执行主控机上的脚本
  • 写一个脚本,给它加上权限
[root@localhost ~]# vim test.sh
[root@localhost ~]# cat test.sh
#!/bin/bashecho "hello word"
[root@localhost ~]# chmod +x test.sh
[root@localhost ~]# ll
total 8
-rw-------. 1 root root 1172 Aug 26 10:47 anaconda-ks.cfg
-rwxr-xr-x  1 root root   31 Aug 27 19:52 test.sh
[root@localhost ~]# pwd
/root
  • 执行脚本
[root@localhost ~]# ansible all -m script -a '/root/test.sh'
192.168.159.138 | CHANGED => {"changed": true,"rc": 0,"stderr": "Shared connection to 192.168.159.138 closed.\r\n","stderr_lines": ["Shared connection to 192.168.159.138 closed."],"stdout": "hello word\r\n","stdout_lines": ["hello word"]
}
  • 去掉权限,执行脚本
[root@localhost ~]#  chmod -x test.sh
[root@localhost ~]# ll
total 8
-rw-------. 1 root root 1172 Aug 26 10:47 anaconda-ks.cfg
-rw-r--r--  1 root root   31 Aug 27 19:52 test.sh
[root@localhost ~]# ansible all -m script -a '/root/test.sh'
192.168.159.138 | CHANGED => {"changed": true,"rc": 0,"stderr": "Shared connection to 192.168.159.138 closed.\r\n","stderr_lines": ["Shared connection to 192.168.159.138 closed."],"stdout": "hello word\r\n","stdout_lines": ["hello word"]
}

7. template

temolate模块用与生成一个模板,并可将其传输至远程主机上

  • 首先在主控机的根下创建一个一个目录
[root@localhost ~]# mkdir /files/yum -p
[root@localhost ~]# ls /files/
yum
[root@localhost ~]# cd /files/yum
  • 把8的源安装在根下面并清理云缓存
[root@ansible yum]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
--2020-08-30 18:58:03--  https://mirrors.aliyun.com/repo/Centos-8.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 112.28.222.243, 111.7.88.238, 112.28.222.242, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|112.28.222.243|:443... connected.
HTTP request sent, awaiting response... 200 OK
...[root@ansible yum]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
  • 进入vim CentOS-Base.repo 将$releasever改成8
[root@ansible yum]# vim CentOS-Base.repo [centosplus]
name=CentOS-8 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/8/centosplus/$basearch/os/http://mirrors.aliyuncs.com/centos/8/centosplus/$basearch/os/
...
  • 将受控机的源删除
[root@localhost ~]# rm -rf /etc/yum.repos.d/*
[root@localhost ~]# ls /etc/yum.repos.d/
  • 将源的名字改成8
[root@ansible yum]# mv CentOS-Base.repo CentOS8.repo
[root@ansible yum]# ls
CentOS8.repo
  • 使用template命令把源从主控机安装到受控机上去
[root@ansible ~]# ansible 192.168.159.138 -m template -a 'src=/files/yum/CentOS8.repo dest=/etc/yum.repos.d/CentOS-Base.repo'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"checksum": "ff9a9456ae8d34de0496ce35d699f90d992c81a7","dest": "/etc/yum.repos.d/CentOS-Base.repo","gid": 0,"group": "root","md5sum": "6a3fd2cacd1631d6af05a54c50b0513a","mode": "0644","owner": "root","secontext": "system_u:object_r:system_conf_t:s0","size": 2395,"src": "/root/.ansible/tmp/ansible-tmp-1598787001.7791588-1670-168030840085436/source","state": "file","uid": 0
}
  • 然后查看受控机是否有源
[root@localhost ~]# ls /etc/yum.repos.d
CentOS-Base.repo

8. yum模块

  • name:要管理的包名
  • state:要进行的操作
  • state常用的值 :
    - latest:安装软件
    - installed:安装软件
    - present:安装软件
    - removed:卸载软件
    - absent:卸载软件
    若想使用yum来管理软件,请确保受控机上的yum源无异常。
8.1 在主控机里用yum模块给受控机安装zsh
  • 先在受控机里安装dnf
[root@localhost ~]# yum -y install dnf
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:00:15 ago on Sun 30 Aug 2020 07:35:02 PM CST.
Package dnf-4.2.17-6.el8.noarch is already installed.
Dependencies resolved.
======================================================================================================Package                     Architecture        Version                      Repository         Size
======================================================================================================
Upgrading:dnf                         noarch              4.2.17-7.el8_2               base              469 kdnf-data                    noarch              4.2.17-7.el8_2               base              145 klibdnf                      x86_64              0.39.1-6.el8_2               base              620 kpython3-dnf                 noarch              4.2.17-7.el8_2               base              521 k
...
  • 过滤一下,安装python2-dnf
[root@localhost ~]# yum list all |grep dnf
dnf.noarch                                           4.2.17-7.el8_2                                   @base
dnf-data.noarch                                      4.2.17-7.el8_2                                   @base
dnf-plugin-spacewalk.noarch                          2.8.5-11.module+el8.1.0+3455+3ddf2832            @AppStream
dnf-plugin-subscription-manager.x86_64               1.26.16-1.el8                                    @anaconda
...
  • 在受控机上查看是否安装了zsh
[root@localhost ~]# rpm -qa |grep zsh
[root@localhost ~]# 
  • 在主机上给受控机安装zsh
[root@ansible ~]# ansible all -m yum -a 'name=zsh state=present'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"msg": "","rc": 0,"results": ["Installed: zsh-5.5.1-6.el8_1.2.x86_64"]
}
  • 查看受控机是否安好zsh
[root@localhost ~]# rpm -qa |grep zsh
zsh-5.5.1-6.el8_1.2.x86_64
8.2 给主机安装zsh
[root@ansible ~]# rpm -qa |grep zsh
[root@ansible ~]# yum -y install zsh
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
CentOS-8 - Base - mirrors.aliyun.com                                  7.6 kB/s | 3.9 kB     00:00
CentOS-8 - Extras - mirrors.aliyun.com                                4.0 kB/s | 1.5 kB     00:00
CentOS-8 - AppStream - mirrors.aliyun.com                             9.5 kB/s | 4.3 kB     00:00
Dependencies resolved.
...
[root@ansible ~]# rpm -qa |grep zsh
zsh-5.5.1-6.el8_1.2.x86_64
  • 卸载absent
[root@ansible ~]# ansible localhost -m dnf -a 'name=zsh state=absent'
localhost | CHANGED => {"changed": true,"msg": "","rc": 0,"results": ["Removed: zsh-5.5.1-6.el8_1.2.x86_64"]
}
8.3 download_only:只下载 ; download_dir:下载到哪去
[root@ansible ~]# ls /tmp/
ks-script-xmj7ui4e          vmware-root_916-2689078442  vmware-root_922-2722632355
vmware-root_915-4022177651  vmware-root_918-2697532712  vmware-root_933-3988752732
[root@ansible ~]# ansible localhost  -m dnf -a 'name=zsh download_only=yes download_dir=/tmp/'
localhost | CHANGED => {"changed": true,"msg": "","rc": 0,"results": ["Downloaded: zsh-5.5.1-6.el8_1.2.x86_64"]
}
[root@ansible ~]# ls /tmp/
ks-script-xmj7ui4e          vmware-root_918-2697532712  zsh-5.5.1-6.el8_1.2.x86_64.rpm
vmware-root_915-4022177651  vmware-root_922-2722632355
vmware-root_916-2689078442  vmware-root_933-3988752732

9. copy模块

copy模块用于复制文件至远程受控机。y模块用于复制文件至远程受控机。

9.1 把zsh从主控机copy到受控机上
  • 查看受控上是否有zsh
[root@localhost ~]# ls
anaconda-ks.cfg
  • 在主控机上进行copy
[root@ansible ~]# ansible all -m copy -a 'src=/tmp/zsh-5.5.1-6.el8_1.2.x86_64.rpm dest=/root/'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"checksum": "3101ef1f2e61fc08f7fa698fe7754b3007663c26","dest": "/root/zsh-5.5.1-6.el8_1.2.x86_64.rpm","gid": 0,"group": "root","md5sum": "4d242d649ea376f21fd83e47003c18ee","mode": "0644","owner": "root","secontext": "system_u:object_r:admin_home_t:s0","size": 3039264,"src": "/root/.ansible/tmp/ansible-tmp-1598791346.6248155-2970-76739662063530/source","state": "file","uid": 0
}
  • 查看受控机是否有zsh
[root@localhost ~]# ls
anaconda-ks.cfg  zsh-5.5.1-6.el8_1.2.x86_64.rpm

10 group模块

group模块用于在受控机上添加或删除组。

10.1 创建组
  • 在受控机上查看没有组
[root@localhost ~]# grep runtime /etc/group
  • 在主机新建组叫runtime
[root@ansible ~]# ansible all -m group -a 'name=runtime state=present'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"gid": 1000,"name": "runtime","state": "present","system": false
}
  • 查看受控机是否有组
[root@localhost ~]# grep runtime /etc/group
runtime:x:1000:
10.2 删除组
  • 用absent来删除
[root@ansible ~]# ansible all -m group -a 'name=runtime state=absent'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"name": "runtime","state": "absent"
}
  • 在受控机中查看是否1删除成功
[root@localhost ~]# grep runtime /etc/group
[root@localhost ~]#
已删除成功

11. user模块

user模块用于管理受控机的用户帐号

11.1 创建tom用户
  • 在受控机上查看是否有tom用户
[root@localhost ~]# id tom
id: ‘tom’: no such user
  • 用user创建透明用户
[root@ansible ~]# ansible all -m user -a 'name=tom uid=2000 state=present'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"comment": "","create_home": true,"group": 2000,"home": "/home/tom","name": "tom","shell": "/bin/bash","state": "present","system": false,"uid": 2000
}
  • 在受控机查看是否创建成功
[root@localhost ~]# id tom
uid=2000(tom) gid=2000(tom) groups=2000(tom)
11.2 修改tom用户的uid
[root@ansible ~]# ansible all -m user -a 'name=tom uid=3000'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"append": false,"changed": true,"comment": "","group": 2000,"home": "/home/tom","move_home": false,"name": "tom","shell": "/bin/bash","state": "present","uid": 3000
}
  • 查看是否修改成功
[root@localhost ~]# id tom
uid=3000(tom) gid=2000(tom) groups=2000(tom)
11.3 删除
[root@ansible ~]# ansible all -m user -a 'name=tom state=absent'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"force": false,"name": "tom","remove": false,"state": "absent"
}
  • 在受控机上查看是否删除成功
[root@localhost ~]# id tom
id: ‘tom’: no such user

12. service模块

service模块用于管理受控机上的服务

12.1 停止受控机postfix服务
  • 查看受控机postfix服务在启动
[root@localhost ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport AgentLoaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)Active: active (running) since Sun 2020-08-30 21:05:35 CST; 2s agoProcess: 12495 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)Process: 12492 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)Process: 12486 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)Main PID: 12562 (master)Tasks: 3 (limit: 5869)Memory: 8.8MCGroup: /system.slice/postfix.service├─12562 /usr/libexec/postfix/master -w├─12563 pickup -l -t unix -u└─12564 qmgr -l -t unix -u
...
  • 在主控机上停止该服务
[root@ansible ~]# ansible all -m service -a 'name=postfix state=stopped'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"name": "postfix","state": "stopped","status": {"ActiveEnterTimestamp": "Sun 2020-08-30 21:05:35 CST","ActiveEnterTimestampMonotonic": "8628258867","ActiveExitTimestampMonotonic": "0","ActiveState": "active","After": "systemd-tmpfiles-setup.service network.target systemd-journald.socket tmp.mount basic.target system.slice syslog.target sysinit.target -.mount","AllowIsolate": "no",
  • 在受控机上查看postfix服务是否已经停止
[root@localhost ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport AgentLoaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)Active: inactive (dead)...
12.2 启动该服务
  • 在主控机上启动
[root@ansible ~]# ansible all -m service -a 'name=postfix state=started'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"name": "postfix","state": "started","status": {"ActiveEnterTimestampMonotonic": "0","ActiveExitTimestampMonotonic": "0",
...
  • 在受控机上查看该服务是否已经启动
[root@localhost ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport AgentLoaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)Active: active (running) since Sun 2020-08-30 21:10:47 CST; 1min 0s agoProcess: 12863 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)Process: 12861 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)Process: 12858 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)Main PID: 12930 (master)Tasks: 3 (limit: 5869)Memory: 7.5MCGroup: /system.slice/postfix.service├─12930 /usr/libexec/postfix/master -w├─12931 pickup -l -t unix -u└─12932 qmgr -l -t unix -u
...
12.3 设置受控机上postfix服务开机不自动启动
  • 在主控机上用enabled=no来设置
[root@ansible ~]# ansible all -m service -a 'name=postfix enabled=no'
192.168.159.138 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": false,"enabled": false,"name": "postfix","status": {"ActiveEnterTimestamp": "Sun 2020-08-30 21:10:47 CST","ActiveEnterTimestampMonotonic": "8940404462","ActiveExitTimestampMonotonic": "0","ActiveState": "active",
  • 查看受控机
[root@localhost ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport AgentLoaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)Active: active (running) since Sun 2020-08-30 21:10:47 CST; 21min agoProcess: 12863 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)Process: 12861 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)Process: 12858 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)Main PID: 12930 (master)
12.4 设置重启自动启动
[root@ansible ~]# ansible all -m service -a 'name=postfix enabled=yes state=restarted'
192.168.159.138 | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": true,"enabled": true,"name": "postfix","state": "started","status": {"ActiveEnterTimestamp": "Sun 2020-08-30 21:10:47 CST","ActiveEnterTimestampMonotonic": "8940404462",
  • 在受控机上查看
[root@localhost ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport AgentLoaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)Active: active (running) since Sun 2020-08-30 21:34:57 CST; 1min 4s agoProcess: 13259 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)Process: 13283 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)Process: 13280 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)Process: 13276 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)Main PID: 13350 (master)Tasks: 3 (limit: 5869)Memory: 7.6MCGroup: /system.slice/postfix.service├─13350 /usr/libexec/postfix/master -w├─13351 pickup -l -t unix -u└─13352 qmgr -l -t unix -u
...

部署Ansible与常用模块相关推荐

  1. ansible 的常用模块操作

    ansible 的常用模块操作 文章目录 ansible 的常用模块操作 一. 常用模块 二. Ansible命令行选项 三. 运行临时命令 1. 使用临时命令通过模块来执行任务 1.1. ansib ...

  2. 自动化运维工具Ansible实战---常用模块

    Ansible默认提供了很多模块来供我们使用.在Linux中,我们可以通过 ansible-doc -l 命令查看到当前Ansible支持哪些模块,通过 ansible-doc -s [模块名] 又可 ...

  3. 总结Ansible中常用模块

    文章目录 前言 一.ansible实现管理的方式 二.Ad-Hoc执行方式中如何获得帮助 三.ansible命令运行方式及常用参数 四.ansible的基本颜色代表信 五.ansible中的常用模块 ...

  4. Ansible纸上谈兵02:常用模块

    背景 这里以 ad-hoc 命令的方式介绍下 Ansible 经常用到的模块. Ansible 已经具备丰富的模块生态,我们可以借助 Ansible 的模块完成日常在 Linux 操作系统上的运维工作 ...

  5. ansible自动化运维(二)——环境部署及常用模块的使用

    实验环境 主机 ip server1(主控端) 172.25.6.1 server2(节点) 172.25.6.2 server3(节点) 172.25.6.3 一.环境部署 ansible的配置文件 ...

  6. ansible安装部署和配置、常用模块整理

    今天心情不错~~~~第25个生日了,又遇昨晚百年难得一见的蓝月亮,所以昨晚连夜整理了文档, 会分为两部分发出去,ansible批量化部署在工作中是非常实用,建议呢 整理大量常用模块去练习 1.1.1  ...

  7. Ansible基本使用及常用模块详解

    一.ansible基本使用 定义主机组 定义被管理节点列表的文件/etc/ansible/hosts,在定义被管理节点的时候,可以单独基于主机做定义,也可以将多个主机定义成一个主机组. 在上篇博文安装 ...

  8. Ansible简介及常用模块

    一.基础介绍 1.简介 ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric)的优点,实现了批量系统配置. ...

  9. Ansible基础和常用模块(一)

    文章目录 1. Ansible 概述 2. Ansible 安装配置 3. Ansible Inventory 清单 4. Ansible ad-hoc 5. Ansible 功能模块 5.1 Ans ...

  10. ANSIBLE的安装和常用模块使用详细教程

    ANSIBLE安装和各种模块应用功能 文章目录 ANSIBLE安装和各种模块应用功能 安装配置ANSIBLE ANSIBLE使用 ansible-galaxy工具 ansible-pull工具 ans ...

最新文章

  1. MongoDb 安全配置
  2. 一、华为云ModelArts环配置
  3. 一天学完spark的Scala基础语法教程一、基础语法与变量(idea版本)
  4. SAP Spartacus core模块的单元测试
  5. devc编译器配置如何配置_如何使用notepad++搭配MinGW配置编译C/C++
  6. python语句可以采用交互式执行方式_怎么在Python交互式命令行中运行脚本?
  7. 如何理解mysql数据库_怎么简单地理解数据库的概念?
  8. Spring Boot 发送邮件
  9. 使用 Unity* 进行并行处理的一种方法
  10. 江苏科技大学MATLAB考试,江苏科技大学精品课程申报表.DOC
  11. eovs实训报告总结心得_实训报告心得体会范文大全
  12. mac M1 安装navicat亲测有效
  13. 开发一个商城小程序要多少钱
  14. PHP正则匹配全中文
  15. 专业软件测试工程师必备之软件测试要学什么技能?
  16. flex布局学习记录
  17. Android最佳性能实践(一)——合理管理内存
  18. SpringSecurity - 用户动态授权 及 动态角色权限
  19. 程序员提前下班的福音来了!GitHub、OpenAI 联手推出 AI 代码生成神器
  20. 在linux系统,用FTP工具下载文件

热门文章

  1. 基于二叉链表的二叉树最长路径的求解
  2. RabbitMQ项目实战——商户管理系统
  3. 外包软件开发时要避免的五个陷阱
  4. linux系统 安装svn客户端下载,Linux安装svn客户端
  5. android modbus 串口,手机Modbus 安卓Modbus调试软件
  6. 算法分析c语言版+视频教程,数据结构c语言版
  7. 武汉ISO27001认证的完整步骤
  8. 软考中级网络工程师-每日一练-01
  9. 神经网络加速器设计研究:GoSPA ISCA2021论文研读
  10. SVN客户端和服务端的安装教程