文档章节

初识ansible

bboysoulcn
 bboysoulcn
发布于 2018/07/18 15:09
字数 5448
阅读 18
收藏 0

概述

有谁知道ansible是怎么读的

什么是ansible

简单的介绍一下这个东西,首先这个东西是用python写的

说一下我的环境

我的是四台虚拟机,centos系统,然后的话是安装了k8s的分别是

  • k8s-master
  • k8s-slave1
  • k8s-slave2
  • k8s-slave3
  • k8s-slave4

但是这个都不管,我们主要是用来做ansible的实验,还有如果文章中没有说明,那么一切操作都是在k8s-master节点上操作

安装

安装直接使用包管理器安装就好了

yum install epel-release

yum install ansible

给机器添加秘钥

首先在k8s-master节点生成秘钥

ssh-keygen -t rsa

之后一路回车

之后把秘钥导入到每一台机器中

ssh-copy-id root@192.168.1.151

ssh-copy-id root@192.168.1.156

ssh-copy-id root@192.168.1.148

ssh-copy-id root@192.168.1.139

配置ansible

下面有几个配置文件要注意 一下

首先是

vim /etc/ansible/hosts

里面定义的是集群中的主机,比如我的

[k8s-server]
192.168.1.151
192.168.1.139
192.168.1.148
192.168.1.156

[k8s-master]
192.168.1.139

[k8s-slave]
192.168.1.148
192.168.1.156
192.168.1.151

上面这样是一组主机,如果我要在这一组主机里面去执行一个命令如下所示

[root@bboysoul-k8s-master ~]# ansible k8s-server -m shell -a "hostname"
192.168.1.151 | SUCCESS | rc=0 >>
bboysoul-k8s-slave1

192.168.1.156 | SUCCESS | rc=0 >>
bboysoul-k8s-slave3

192.168.1.148 | SUCCESS | rc=0 >>
bboysoul-k8s-slave2

192.168.1.139 | SUCCESS | rc=0 >>
bboysoul-k8s-master

k8s-server表示在这个组主机里面执行命令,-m表示要使用的模块,-a就是模块里面的参数

又如下面这样

[root@bboysoul-k8s-master ~]# ansible k8s-master -m shell -a "hostname"
192.168.1.139 | SUCCESS | rc=0 >>
bboysoul-k8s-master

或者你想要在所有主机下执行这个命令

[root@bboysoul-k8s-master ~]# ansible all -m shell -a "hostname"
192.168.1.139 | SUCCESS | rc=0 >>
bboysoul-k8s-master

192.168.1.151 | SUCCESS | rc=0 >>
bboysoul-k8s-slave1

192.168.1.148 | SUCCESS | rc=0 >>
bboysoul-k8s-slave2

192.168.1.156 | SUCCESS | rc=0 >>
bboysoul-k8s-slave3

可能你觉得ansible执行某些命令会很慢,所以你可以加上-f来fork出多个子进程来执行,但是要值得注意的是如果你执行的是一些简单的命令就不要加了,因为fork进程也是需要时间的

ansible中的模块

ansible中有很多模块

我们可以使用

ansible-doc -l

来查看ansible中包含的一些模块

当然我们可以这样去搜索模块

ansible-doc -l |grep copy

asnible-doc这个命令是用来获取各个模块的帮助信息的,比如我要查看copy模块的帮助信息

ansible-doc -s copy

ansible的一些常用模块

  • copy

这个模块就是用来把本地的文件分发到远程主机上的,比如

首先我们先建立一个目录

ansible all -m shell -a "mkdir /root/bboysoul"

之后我们在本地下载一个小文件

wget http://mirrors.ustc.edu.cn/alpine/v3.8/releases/x86_64/alpine-standard-3.8.0_rc8-x86_64.iso

之后使用copy模块分发

[root@bboysoul-k8s-master ~]# time ansible all -m copy -a "src=/root/alpine-standard-3.8.0_rc8-x86_64.iso dest=/root/bboysoul/alpine.iso"
192.168.1.139 | SUCCESS => {
    "changed": true, 
    "checksum": "01bb2a8206073ecd789367405854765236456737", 
    "dest": "/root/bboysoul/alpine.iso", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "640c9ccc23034a8a3237f5ca920cf339", 
    "mode": "0644", 
    "owner": "root", 
    "secontext": "system_u:object_r:admin_home_t:s0", 
    "size": 109051904, 
    "src": "/root/.ansible/tmp/ansible-tmp-1531285839.13-230038764878103/source", 
    "state": "file", 
    "uid": 0
}
192.168.1.151 | SUCCESS => {
    "changed": true, 
    "checksum": "01bb2a8206073ecd789367405854765236456737", 
    "dest": "/root/bboysoul/alpine.iso", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "640c9ccc23034a8a3237f5ca920cf339", 
    "mode": "0644", 
    "owner": "root", 
    "secontext": "system_u:object_r:admin_home_t:s0", 
    "size": 109051904, 
    "src": "/root/.ansible/tmp/ansible-tmp-1531285839.14-272099530710321/source", 
    "state": "file", 
    "uid": 0
}
192.168.1.156 | SUCCESS => {
    "changed": true, 
    "checksum": "01bb2a8206073ecd789367405854765236456737", 
    "dest": "/root/bboysoul/alpine.iso", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "640c9ccc23034a8a3237f5ca920cf339", 
    "mode": "0644", 
    "owner": "root", 
    "secontext": "system_u:object_r:admin_home_t:s0", 
    "size": 109051904, 
    "src": "/root/.ansible/tmp/ansible-tmp-1531285839.14-236085238208838/source", 
    "state": "file", 
    "uid": 0
}
192.168.1.148 | SUCCESS => {
    "changed": true, 
    "checksum": "01bb2a8206073ecd789367405854765236456737", 
    "dest": "/root/bboysoul/alpine.iso", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "640c9ccc23034a8a3237f5ca920cf339", 
    "mode": "0644", 
    "owner": "root", 
    "secontext": "system_u:object_r:admin_home_t:s0", 
    "size": 109051904, 
    "src": "/root/.ansible/tmp/ansible-tmp-1531285839.12-36460981766787/source", 
    "state": "file", 
    "uid": 0
}

real	0m17.358s
user	0m1.401s
sys	0m0.516s

为了计算时间我使用了time命令

关于这个模块还要说的是,src= 路径后面带/ 表示带里面的所有内容复制到目标目录下,不带/是目录递归复制过去

  • shell

这个不多解释了,就是执行shell命令的

  • cron

这个模块是用来创建计划任务的

比如创建一个每1分钟ping一次百度的计划任务

之前是没有的

[root@bboysoul-k8s-master ~]# ansible all -m shell -a "crontab -l"
192.168.1.151 | FAILED | rc=1 >>
no crontab for rootnon-zero return code

192.168.1.148 | FAILED | rc=1 >>
no crontab for rootnon-zero return code

192.168.1.156 | FAILED | rc=1 >>
no crontab for rootnon-zero return code

192.168.1.139 | FAILED | rc=1 >>
no crontab for rootnon-zero return code

创建任务

ansible all -m cron -a "minute=*/1 job='ping baidu.com' name=ping"

之后查看任务

[root@bboysoul-k8s-master ~]# ansible all -m shell -a "crontab -l"
192.168.1.151 | SUCCESS | rc=0 >>
#Ansible: ping
*/1 * * * * ping baidu.com

192.168.1.148 | SUCCESS | rc=0 >>
#Ansible: ping
*/1 * * * * ping baidu.com

192.168.1.156 | SUCCESS | rc=0 >>
#Ansible: ping
*/1 * * * * ping baidu.com

192.168.1.139 | SUCCESS | rc=0 >>
#Ansible: ping
*/1 * * * * ping baidu.com
  • ** script**

这个就是把本地的脚本上传到远端去执行

首先新建一个脚本

[root@bboysoul-k8s-master ~]# cat test.sh
#!/bin/bash
echo "ansible test ok"

之后使用这个模块执行

ansible all -m script -a "./test.sh"

关于模块的总结

说真的模块太多了,不可能每个都知道都会使用的,如果你不会那么

ansible-doc -s 模块名

关于playbook

前面废话说完了,下面进入正题playbook,如果说ansible的精髓是什么那就是playbook了

我们使用一个实例去入门这个playbook

就是使用playbook去安装nmap

首先新建一个文件

vim playbook.yml

之后写入

- hosts: all
  remote_user: root
  tasks: 
    - name: install nmap
      yum: name=nmap state=latest

    - name: install vim
      yum: name=vim state=latest

    - name: install whois
      yum: name=whois state=latest

    - name: whois bboysoul
      shell: whois bboysoul.com

检查一下语法

ansible-playbook --syntax-check playbook.yml

查看一下涉及到的主机

[root@bboysoul-k8s-master ~]# ansible-playbook --list-hosts playbook.yml 

playbook: playbook.yml

  play #1 (all): all	TAGS: []
    pattern: [u'all']
    hosts (4):
      192.168.1.139
      192.168.1.151
      192.168.1.148
      192.168.1.156

之后查看一下可能会发生的改变

ansible-playbook --check playbook.yml

[root@bboysoul-k8s-master ~]# ansible-playbook --check playbook.yml 

PLAY [all] ********************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [192.168.1.148]
ok: [192.168.1.151]
ok: [192.168.1.156]
ok: [192.168.1.139]

TASK [install nmap] ***********************************************************************************************************************************************************************************************
changed: [192.168.1.156]
changed: [192.168.1.151]
changed: [192.168.1.148]
changed: [192.168.1.139]

TASK [install vim] ************************************************************************************************************************************************************************************************
changed: [192.168.1.156]
ok: [192.168.1.139]
changed: [192.168.1.148]
changed: [192.168.1.151]

TASK [install whois] **********************************************************************************************************************************************************************************************
changed: [192.168.1.156]
changed: [192.168.1.148]
changed: [192.168.1.151]
changed: [192.168.1.139]

TASK [whois bboysoul] *********************************************************************************************************************************************************************************************
skipping: [192.168.1.156]
skipping: [192.168.1.151]
skipping: [192.168.1.148]
skipping: [192.168.1.139]

PLAY RECAP ********************************************************************************************************************************************************************************************************
192.168.1.139              : ok=4    changed=2    unreachable=0    failed=0   
192.168.1.148              : ok=4    changed=3    unreachable=0    failed=0   
192.168.1.151              : ok=4    changed=3    unreachable=0    failed=0   
192.168.1.156              : ok=4    changed=3    unreachable=0    failed=0   

注意,这个时候其实命令是没有被执行的,只是检查一下命令是不是正确而已

最后执行

[root@bboysoul-k8s-master ~]# ansible-playbook playbook.yml 

PLAY [all] ********************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [192.168.1.156]
ok: [192.168.1.148]
ok: [192.168.1.151]
ok: [192.168.1.139]

TASK [install nmap] ***********************************************************************************************************************************************************************************************
changed: [192.168.1.156]
changed: [192.168.1.151]
changed: [192.168.1.148]
changed: [192.168.1.139]

TASK [install vim] ************************************************************************************************************************************************************************************************
changed: [192.168.1.156]
ok: [192.168.1.139]
changed: [192.168.1.151]
changed: [192.168.1.148]

TASK [install whois] **********************************************************************************************************************************************************************************************
changed: [192.168.1.156]
changed: [192.168.1.148]
changed: [192.168.1.151]
changed: [192.168.1.139]

TASK [whois bboysoul] *********************************************************************************************************************************************************************************************
fatal: [192.168.1.151]: FAILED! => {"changed": true, "cmd": "whois bboysoul.com", "delta": "0:00:00.436371", "end": "2018-07-11 16:24:41.250469", "msg": "non-zero return code", "rc": 1, "start": "2018-07-11 16:24:40.814098", "stderr": "", "stderr_lines": [], "stdout": "   Domain Name: BBOYSOUL.COM\n   Registry Domain ID: 2154086731_DOMAIN_COM-VRSN\n   Registrar WHOIS Server: grs-whois.hichina.com\n   Registrar URL: http://www.net.cn\n   Updated Date: 2018-04-24T01:30:46Z\n   Creation Date: 2017-08-16T18:06:53Z\n   Registry Expiry Date: 2018-08-16T18:06:53Z\n   Registrar: HiChina Zhicheng Technology Ltd.\n   Registrar IANA ID: 420\n   Registrar Abuse Contact Email: DomainAbuse@service.aliyun.com\n   Registrar Abuse Contact Phone: +86.95187\n   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited\n   Name Server: DNS17.HICHINA.COM\n   Name Server: DNS18.HICHINA.COM\n   DNSSEC: unsigned\n   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/\n>>> Last update of whois database: 2018-07-11T08:24:27Z <<<\n\nFor more information on Whois status codes, please visit https://icann.org/epp\n\nNOTICE: The expiration date displayed in this record is the date the\nregistrar's sponsorship of the domain name registration in the registry is\ncurrently set to expire. This date does not necessarily reflect the expiration\ndate of the domain name registrant's agreement with the sponsoring\nregistrar.  Users may consult the sponsoring registrar's Whois database to\nview the registrar's reported date of expiration for this registration.\n\nTERMS OF USE: You are not authorized to access or query our Whois\ndatabase through the use of electronic processes that are high-volume and\nautomated except as reasonably necessary to register domain names or\nmodify existing registrations; the Data in VeriSign Global Registry\nServices' (\"VeriSign\") Whois database is provided by VeriSign for\ninformation purposes only, and to assist persons in obtaining information\nabout or related to a domain name registration record. VeriSign does not\nguarantee its accuracy. By submitting a Whois query, you agree to abide\nby the following terms of use: You agree that you may use this Data only\nfor lawful purposes and that under no circumstances will you use this Data\nto: (1) allow, enable, or otherwise support the transmission of mass\nunsolicited, commercial advertising or solicitations via e-mail, telephone,\nor facsimile; or (2) enable high volume, automated, electronic processes\nthat apply to VeriSign (or its computer systems). The compilation,\nrepackaging, dissemination or other use of this Data is expressly\nprohibited without the prior written consent of VeriSign. You agree not to\nuse electronic processes that are automated and high-volume to access or\nquery the Whois database except as reasonably necessary to register\ndomain names or modify existing registrations. VeriSign reserves the right\nto restrict your access to the Whois database in its sole discretion to ensure\noperational stability.  VeriSign may restrict or terminate your access to the\nWhois database for failure to abide by these terms of use. VeriSign\nreserves the right to modify these terms at any time.\n\nThe Registry database contains ONLY .COM, .NET, .EDU domains and\nRegistrars.", "stdout_lines": ["   Domain Name: BBOYSOUL.COM", "   Registry Domain ID: 2154086731_DOMAIN_COM-VRSN", "   Registrar WHOIS Server: grs-whois.hichina.com", "   Registrar URL: http://www.net.cn", "   Updated Date: 2018-04-24T01:30:46Z", "   Creation Date: 2017-08-16T18:06:53Z", "   Registry Expiry Date: 2018-08-16T18:06:53Z", "   Registrar: HiChina Zhicheng Technology Ltd.", "   Registrar IANA ID: 420", "   Registrar Abuse Contact Email: DomainAbuse@service.aliyun.com", "   Registrar Abuse Contact Phone: +86.95187", "   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited", "   Name Server: DNS17.HICHINA.COM", "   Name Server: DNS18.HICHINA.COM", "   DNSSEC: unsigned", "   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/", ">>> Last update of whois database: 2018-07-11T08:24:27Z <<<", "", "For more information on Whois status codes, please visit https://icann.org/epp", "", "NOTICE: The expiration date displayed in this record is the date the", "registrar's sponsorship of the domain name registration in the registry is", "currently set to expire. This date does not necessarily reflect the expiration", "date of the domain name registrant's agreement with the sponsoring", "registrar.  Users may consult the sponsoring registrar's Whois database to", "view the registrar's reported date of expiration for this registration.", "", "TERMS OF USE: You are not authorized to access or query our Whois", "database through the use of electronic processes that are high-volume and", "automated except as reasonably necessary to register domain names or", "modify existing registrations; the Data in VeriSign Global Registry", "Services' (\"VeriSign\") Whois database is provided by VeriSign for", "information purposes only, and to assist persons in obtaining information", "about or related to a domain name registration record. VeriSign does not", "guarantee its accuracy. By submitting a Whois query, you agree to abide", "by the following terms of use: You agree that you may use this Data only", "for lawful purposes and that under no circumstances will you use this Data", "to: (1) allow, enable, or otherwise support the transmission of mass", "unsolicited, commercial advertising or solicitations via e-mail, telephone,", "or facsimile; or (2) enable high volume, automated, electronic processes", "that apply to VeriSign (or its computer systems). The compilation,", "repackaging, dissemination or other use of this Data is expressly", "prohibited without the prior written consent of VeriSign. You agree not to", "use electronic processes that are automated and high-volume to access or", "query the Whois database except as reasonably necessary to register", "domain names or modify existing registrations. VeriSign reserves the right", "to restrict your access to the Whois database in its sole discretion to ensure", "operational stability.  VeriSign may restrict or terminate your access to the", "Whois database for failure to abide by these terms of use. VeriSign", "reserves the right to modify these terms at any time.", "", "The Registry database contains ONLY .COM, .NET, .EDU domains and", "Registrars."]}
fatal: [192.168.1.156]: FAILED! => {"changed": true, "cmd": "whois bboysoul.com", "delta": "0:00:00.695995", "end": "2018-07-11 16:24:41.399184", "msg": "non-zero return code", "rc": 1, "start": "2018-07-11 16:24:40.703189", "stderr": "", "stderr_lines": [], "stdout": "   Domain Name: BBOYSOUL.COM\n   Registry Domain ID: 2154086731_DOMAIN_COM-VRSN\n   Registrar WHOIS Server: grs-whois.hichina.com\n   Registrar URL: http://www.net.cn\n   Updated Date: 2018-04-24T01:30:46Z\n   Creation Date: 2017-08-16T18:06:53Z\n   Registry Expiry Date: 2018-08-16T18:06:53Z\n   Registrar: HiChina Zhicheng Technology Ltd.\n   Registrar IANA ID: 420\n   Registrar Abuse Contact Email: DomainAbuse@service.aliyun.com\n   Registrar Abuse Contact Phone: +86.95187\n   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited\n   Name Server: DNS17.HICHINA.COM\n   Name Server: DNS18.HICHINA.COM\n   DNSSEC: unsigned\n   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/\n>>> Last update of whois database: 2018-07-11T08:24:27Z <<<\n\nFor more information on Whois status codes, please visit https://icann.org/epp\n\nNOTICE: The expiration date displayed in this record is the date the\nregistrar's sponsorship of the domain name registration in the registry is\ncurrently set to expire. This date does not necessarily reflect the expiration\ndate of the domain name registrant's agreement with the sponsoring\nregistrar.  Users may consult the sponsoring registrar's Whois database to\nview the registrar's reported date of expiration for this registration.\n\nTERMS OF USE: You are not authorized to access or query our Whois\ndatabase through the use of electronic processes that are high-volume and\nautomated except as reasonably necessary to register domain names or\nmodify existing registrations; the Data in VeriSign Global Registry\nServices' (\"VeriSign\") Whois database is provided by VeriSign for\ninformation purposes only, and to assist persons in obtaining information\nabout or related to a domain name registration record. VeriSign does not\nguarantee its accuracy. By submitting a Whois query, you agree to abide\nby the following terms of use: You agree that you may use this Data only\nfor lawful purposes and that under no circumstances will you use this Data\nto: (1) allow, enable, or otherwise support the transmission of mass\nunsolicited, commercial advertising or solicitations via e-mail, telephone,\nor facsimile; or (2) enable high volume, automated, electronic processes\nthat apply to VeriSign (or its computer systems). The compilation,\nrepackaging, dissemination or other use of this Data is expressly\nprohibited without the prior written consent of VeriSign. You agree not to\nuse electronic processes that are automated and high-volume to access or\nquery the Whois database except as reasonably necessary to register\ndomain names or modify existing registrations. VeriSign reserves the right\nto restrict your access to the Whois database in its sole discretion to ensure\noperational stability.  VeriSign may restrict or terminate your access to the\nWhois database for failure to abide by these terms of use. VeriSign\nreserves the right to modify these terms at any time.\n\nThe Registry database contains ONLY .COM, .NET, .EDU domains and\nRegistrars.", "stdout_lines": ["   Domain Name: BBOYSOUL.COM", "   Registry Domain ID: 2154086731_DOMAIN_COM-VRSN", "   Registrar WHOIS Server: grs-whois.hichina.com", "   Registrar URL: http://www.net.cn", "   Updated Date: 2018-04-24T01:30:46Z", "   Creation Date: 2017-08-16T18:06:53Z", "   Registry Expiry Date: 2018-08-16T18:06:53Z", "   Registrar: HiChina Zhicheng Technology Ltd.", "   Registrar IANA ID: 420", "   Registrar Abuse Contact Email: DomainAbuse@service.aliyun.com", "   Registrar Abuse Contact Phone: +86.95187", "   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited", "   Name Server: DNS17.HICHINA.COM", "   Name Server: DNS18.HICHINA.COM", "   DNSSEC: unsigned", "   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/", ">>> Last update of whois database: 2018-07-11T08:24:27Z <<<", "", "For more information on Whois status codes, please visit https://icann.org/epp", "", "NOTICE: The expiration date displayed in this record is the date the", "registrar's sponsorship of the domain name registration in the registry is", "currently set to expire. This date does not necessarily reflect the expiration", "date of the domain name registrant's agreement with the sponsoring", "registrar.  Users may consult the sponsoring registrar's Whois database to", "view the registrar's reported date of expiration for this registration.", "", "TERMS OF USE: You are not authorized to access or query our Whois", "database through the use of electronic processes that are high-volume and", "automated except as reasonably necessary to register domain names or", "modify existing registrations; the Data in VeriSign Global Registry", "Services' (\"VeriSign\") Whois database is provided by VeriSign for", "information purposes only, and to assist persons in obtaining information", "about or related to a domain name registration record. VeriSign does not", "guarantee its accuracy. By submitting a Whois query, you agree to abide", "by the following terms of use: You agree that you may use this Data only", "for lawful purposes and that under no circumstances will you use this Data", "to: (1) allow, enable, or otherwise support the transmission of mass", "unsolicited, commercial advertising or solicitations via e-mail, telephone,", "or facsimile; or (2) enable high volume, automated, electronic processes", "that apply to VeriSign (or its computer systems). The compilation,", "repackaging, dissemination or other use of this Data is expressly", "prohibited without the prior written consent of VeriSign. You agree not to", "use electronic processes that are automated and high-volume to access or", "query the Whois database except as reasonably necessary to register", "domain names or modify existing registrations. VeriSign reserves the right", "to restrict your access to the Whois database in its sole discretion to ensure", "operational stability.  VeriSign may restrict or terminate your access to the", "Whois database for failure to abide by these terms of use. VeriSign", "reserves the right to modify these terms at any time.", "", "The Registry database contains ONLY .COM, .NET, .EDU domains and", "Registrars."]}
fatal: [192.168.1.148]: FAILED! => {"changed": true, "cmd": "whois bboysoul.com", "delta": "0:00:00.691615", "end": "2018-07-11 16:24:41.729534", "msg": "non-zero return code", "rc": 1, "start": "2018-07-11 16:24:41.037919", "stderr": "", "stderr_lines": [], "stdout": "   Domain Name: BBOYSOUL.COM\n   Registry Domain ID: 2154086731_DOMAIN_COM-VRSN\n   Registrar WHOIS Server: grs-whois.hichina.com\n   Registrar URL: http://www.net.cn\n   Updated Date: 2018-04-24T01:30:46Z\n   Creation Date: 2017-08-16T18:06:53Z\n   Registry Expiry Date: 2018-08-16T18:06:53Z\n   Registrar: HiChina Zhicheng Technology Ltd.\n   Registrar IANA ID: 420\n   Registrar Abuse Contact Email: DomainAbuse@service.aliyun.com\n   Registrar Abuse Contact Phone: +86.95187\n   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited\n   Name Server: DNS17.HICHINA.COM\n   Name Server: DNS18.HICHINA.COM\n   DNSSEC: unsigned\n   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/\n>>> Last update of whois database: 2018-07-11T08:24:27Z <<<\n\nFor more information on Whois status codes, please visit https://icann.org/epp\n\nNOTICE: The expiration date displayed in this record is the date the\nregistrar's sponsorship of the domain name registration in the registry is\ncurrently set to expire. This date does not necessarily reflect the expiration\ndate of the domain name registrant's agreement with the sponsoring\nregistrar.  Users may consult the sponsoring registrar's Whois database to\nview the registrar's reported date of expiration for this registration.\n\nTERMS OF USE: You are not authorized to access or query our Whois\ndatabase through the use of electronic processes that are high-volume and\nautomated except as reasonably necessary to register domain names or\nmodify existing registrations; the Data in VeriSign Global Registry\nServices' (\"VeriSign\") Whois database is provided by VeriSign for\ninformation purposes only, and to assist persons in obtaining information\nabout or related to a domain name registration record. VeriSign does not\nguarantee its accuracy. By submitting a Whois query, you agree to abide\nby the following terms of use: You agree that you may use this Data only\nfor lawful purposes and that under no circumstances will you use this Data\nto: (1) allow, enable, or otherwise support the transmission of mass\nunsolicited, commercial advertising or solicitations via e-mail, telephone,\nor facsimile; or (2) enable high volume, automated, electronic processes\nthat apply to VeriSign (or its computer systems). The compilation,\nrepackaging, dissemination or other use of this Data is expressly\nprohibited without the prior written consent of VeriSign. You agree not to\nuse electronic processes that are automated and high-volume to access or\nquery the Whois database except as reasonably necessary to register\ndomain names or modify existing registrations. VeriSign reserves the right\nto restrict your access to the Whois database in its sole discretion to ensure\noperational stability.  VeriSign may restrict or terminate your access to the\nWhois database for failure to abide by these terms of use. VeriSign\nreserves the right to modify these terms at any time.\n\nThe Registry database contains ONLY .COM, .NET, .EDU domains and\nRegistrars.", "stdout_lines": ["   Domain Name: BBOYSOUL.COM", "   Registry Domain ID: 2154086731_DOMAIN_COM-VRSN", "   Registrar WHOIS Server: grs-whois.hichina.com", "   Registrar URL: http://www.net.cn", "   Updated Date: 2018-04-24T01:30:46Z", "   Creation Date: 2017-08-16T18:06:53Z", "   Registry Expiry Date: 2018-08-16T18:06:53Z", "   Registrar: HiChina Zhicheng Technology Ltd.", "   Registrar IANA ID: 420", "   Registrar Abuse Contact Email: DomainAbuse@service.aliyun.com", "   Registrar Abuse Contact Phone: +86.95187", "   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited", "   Name Server: DNS17.HICHINA.COM", "   Name Server: DNS18.HICHINA.COM", "   DNSSEC: unsigned", "   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/", ">>> Last update of whois database: 2018-07-11T08:24:27Z <<<", "", "For more information on Whois status codes, please visit https://icann.org/epp", "", "NOTICE: The expiration date displayed in this record is the date the", "registrar's sponsorship of the domain name registration in the registry is", "currently set to expire. This date does not necessarily reflect the expiration", "date of the domain name registrant's agreement with the sponsoring", "registrar.  Users may consult the sponsoring registrar's Whois database to", "view the registrar's reported date of expiration for this registration.", "", "TERMS OF USE: You are not authorized to access or query our Whois", "database through the use of electronic processes that are high-volume and", "automated except as reasonably necessary to register domain names or", "modify existing registrations; the Data in VeriSign Global Registry", "Services' (\"VeriSign\") Whois database is provided by VeriSign for", "information purposes only, and to assist persons in obtaining information", "about or related to a domain name registration record. VeriSign does not", "guarantee its accuracy. By submitting a Whois query, you agree to abide", "by the following terms of use: You agree that you may use this Data only", "for lawful purposes and that under no circumstances will you use this Data", "to: (1) allow, enable, or otherwise support the transmission of mass", "unsolicited, commercial advertising or solicitations via e-mail, telephone,", "or facsimile; or (2) enable high volume, automated, electronic processes", "that apply to VeriSign (or its computer systems). The compilation,", "repackaging, dissemination or other use of this Data is expressly", "prohibited without the prior written consent of VeriSign. You agree not to", "use electronic processes that are automated and high-volume to access or", "query the Whois database except as reasonably necessary to register", "domain names or modify existing registrations. VeriSign reserves the right", "to restrict your access to the Whois database in its sole discretion to ensure", "operational stability.  VeriSign may restrict or terminate your access to the", "Whois database for failure to abide by these terms of use. VeriSign", "reserves the right to modify these terms at any time.", "", "The Registry database contains ONLY .COM, .NET, .EDU domains and", "Registrars."]}
fatal: [192.168.1.139]: FAILED! => {"changed": true, "cmd": "whois bboysoul.com", "delta": "0:00:01.107660", "end": "2018-07-11 16:24:41.693555", "msg": "non-zero return code", "rc": 1, "start": "2018-07-11 16:24:40.585895", "stderr": "", "stderr_lines": [], "stdout": "   Domain Name: BBOYSOUL.COM\n   Registry Domain ID: 2154086731_DOMAIN_COM-VRSN\n   Registrar WHOIS Server: grs-whois.hichina.com\n   Registrar URL: http://www.net.cn\n   Updated Date: 2018-04-24T01:30:46Z\n   Creation Date: 2017-08-16T18:06:53Z\n   Registry Expiry Date: 2018-08-16T18:06:53Z\n   Registrar: HiChina Zhicheng Technology Ltd.\n   Registrar IANA ID: 420\n   Registrar Abuse Contact Email: DomainAbuse@service.aliyun.com\n   Registrar Abuse Contact Phone: +86.95187\n   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited\n   Name Server: DNS17.HICHINA.COM\n   Name Server: DNS18.HICHINA.COM\n   DNSSEC: unsigned\n   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/\n>>> Last update of whois database: 2018-07-11T08:24:27Z <<<\n\nFor more information on Whois status codes, please visit https://icann.org/epp\n\nNOTICE: The expiration date displayed in this record is the date the\nregistrar's sponsorship of the domain name registration in the registry is\ncurrently set to expire. This date does not necessarily reflect the expiration\ndate of the domain name registrant's agreement with the sponsoring\nregistrar.  Users may consult the sponsoring registrar's Whois database to\nview the registrar's reported date of expiration for this registration.\n\nTERMS OF USE: You are not authorized to access or query our Whois\ndatabase through the use of electronic processes that are high-volume and\nautomated except as reasonably necessary to register domain names or\nmodify existing registrations; the Data in VeriSign Global Registry\nServices' (\"VeriSign\") Whois database is provided by VeriSign for\ninformation purposes only, and to assist persons in obtaining information\nabout or related to a domain name registration record. VeriSign does not\nguarantee its accuracy. By submitting a Whois query, you agree to abide\nby the following terms of use: You agree that you may use this Data only\nfor lawful purposes and that under no circumstances will you use this Data\nto: (1) allow, enable, or otherwise support the transmission of mass\nunsolicited, commercial advertising or solicitations via e-mail, telephone,\nor facsimile; or (2) enable high volume, automated, electronic processes\nthat apply to VeriSign (or its computer systems). The compilation,\nrepackaging, dissemination or other use of this Data is expressly\nprohibited without the prior written consent of VeriSign. You agree not to\nuse electronic processes that are automated and high-volume to access or\nquery the Whois database except as reasonably necessary to register\ndomain names or modify existing registrations. VeriSign reserves the right\nto restrict your access to the Whois database in its sole discretion to ensure\noperational stability.  VeriSign may restrict or terminate your access to the\nWhois database for failure to abide by these terms of use. VeriSign\nreserves the right to modify these terms at any time.\n\nThe Registry database contains ONLY .COM, .NET, .EDU domains and\nRegistrars.", "stdout_lines": ["   Domain Name: BBOYSOUL.COM", "   Registry Domain ID: 2154086731_DOMAIN_COM-VRSN", "   Registrar WHOIS Server: grs-whois.hichina.com", "   Registrar URL: http://www.net.cn", "   Updated Date: 2018-04-24T01:30:46Z", "   Creation Date: 2017-08-16T18:06:53Z", "   Registry Expiry Date: 2018-08-16T18:06:53Z", "   Registrar: HiChina Zhicheng Technology Ltd.", "   Registrar IANA ID: 420", "   Registrar Abuse Contact Email: DomainAbuse@service.aliyun.com", "   Registrar Abuse Contact Phone: +86.95187", "   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited", "   Name Server: DNS17.HICHINA.COM", "   Name Server: DNS18.HICHINA.COM", "   DNSSEC: unsigned", "   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/", ">>> Last update of whois database: 2018-07-11T08:24:27Z <<<", "", "For more information on Whois status codes, please visit https://icann.org/epp", "", "NOTICE: The expiration date displayed in this record is the date the", "registrar's sponsorship of the domain name registration in the registry is", "currently set to expire. This date does not necessarily reflect the expiration", "date of the domain name registrant's agreement with the sponsoring", "registrar.  Users may consult the sponsoring registrar's Whois database to", "view the registrar's reported date of expiration for this registration.", "", "TERMS OF USE: You are not authorized to access or query our Whois", "database through the use of electronic processes that are high-volume and", "automated except as reasonably necessary to register domain names or", "modify existing registrations; the Data in VeriSign Global Registry", "Services' (\"VeriSign\") Whois database is provided by VeriSign for", "information purposes only, and to assist persons in obtaining information", "about or related to a domain name registration record. VeriSign does not", "guarantee its accuracy. By submitting a Whois query, you agree to abide", "by the following terms of use: You agree that you may use this Data only", "for lawful purposes and that under no circumstances will you use this Data", "to: (1) allow, enable, or otherwise support the transmission of mass", "unsolicited, commercial advertising or solicitations via e-mail, telephone,", "or facsimile; or (2) enable high volume, automated, electronic processes", "that apply to VeriSign (or its computer systems). The compilation,", "repackaging, dissemination or other use of this Data is expressly", "prohibited without the prior written consent of VeriSign. You agree not to", "use electronic processes that are automated and high-volume to access or", "query the Whois database except as reasonably necessary to register", "domain names or modify existing registrations. VeriSign reserves the right", "to restrict your access to the Whois database in its sole discretion to ensure", "operational stability.  VeriSign may restrict or terminate your access to the", "Whois database for failure to abide by these terms of use. VeriSign", "reserves the right to modify these terms at any time.", "", "The Registry database contains ONLY .COM, .NET, .EDU domains and", "Registrars."]}
	to retry, use: --limit @/root/playbook.retry

PLAY RECAP ********************************************************************************************************************************************************************************************************
192.168.1.139              : ok=4    changed=2    unreachable=0    failed=1   
192.168.1.148              : ok=4    changed=3    unreachable=0    failed=1   
192.168.1.151              : ok=4    changed=3    unreachable=0    failed=1   
192.168.1.156              : ok=4    changed=3    unreachable=0    failed=1   

没错,你看到有一步是出错的,其实并没有出错,你可以看到whois信息还是出来的

关于playbook,详细的可以看文档

http://ansible-tran.readthedocs.io/en/latest/docs/playbooks_intro.html

说真的,有了ansible,妈妈再也不用担心我要在不同的主机上执行相同的命令,就连ddos也变得方便起来

欢迎关注Bboysoul的博客www.bboysoul.com Have Fun

© 著作权归作者所有

bboysoulcn
粉丝 7
博文 110
码字总数 78152
作品 0
美国
私信 提问
《Python自动化运维开发实战》课程配套手记内容列表

自动化实战课程的手记内容手记列表 各位同学,《Python自动化运维开发实战》实战课中的配套手记内容列表如下,供大家参考学习,已经出的手记将参考大家的实际情况进行补充,其他的配套课程整...

幕客技术
2018/01/12
0
0
ansible 初体验

使用命令生成秘钥(机器互信) [root@ansible ~]# ssh-keygen 将公钥发送到所有安装 客户端的主机 [root@ansible ~]# ssh-copy-id 192.168.163.170 [root@ansible ~]# ssh-copy-id 192.168....

一条特立独行的贪吃蛇
2018/01/06
0
0
Ext.Error: Unable to parse the JSON returned by the server: You're trying to decode an invalid JSON String

Firefox给出的错误 Ext.Error: Unable to parse the JSON returned by the server: You're trying to decode an invalid JSON String: articlelist.jsp {"results":"100","rows":[{"id":"1"......

anonymous_007
2014/05/28
2.2K
2
转Elasticsearch顶尖高手系列课程

Elasticsearch,是目前行业中非常热门的一个技术。Elasticsearch是一种分布式的海量数据搜索与分析的技术,可以用于电商网站、门户网站、企业IT系统等各种场景下的搜索引擎,也可以用于对海量...

小花卷juan
2017/06/24
124
0
初识OpenStack Pike版

Preface 前言 OpenStack系统由几个单独安装的关键服务组成。这些服务根据您的云需求一起工作,包括计算、身份验证、网络、镜像、块存储、对象存储、监控、编排和数据库服务。您可以分别安装这...

duyuheng
2017/09/15
0
0

没有更多内容

加载失败,请刷新页面

加载更多

容器中的JVM资源该如何被安全的限制?

前言 Java与Docker的结合,虽然更好的解决了application的封装问题。但也存在着不兼容,比如Java并不能自动的发现Docker设置的内存限制,CPU限制。 这将导致JVM不能稳定服务业务!容器会杀死你...

xiaomin0322
17分钟前
3
0
mysql查询最近连续登录和累计登录

这条sql写了一天,百度无数,终于摸到点门路 需求是查询从当前日期向前推的连续登录,比如一个用户他今天登录了,昨天没登,连续登录为1 他昨天前天都登录了,今天没登录,连续登录为0 SELEC...

七月大人
19分钟前
1
0
常用的一些Vip解析

无广告解析推荐(排行不分前后) 黑米免费解析   https://www.myxin.top/jx/api/?url= 随缘免费解析   http://www.syhbyl.tw/jx/api/?url= 快快免费解析   http://jx.kkqtv.com/jx/...

chenhongjiang
19分钟前
2
0
Netty 整合spring bean注入失败。

1.Netty整合spring bean注入为null的问题,自己折腾了好久,试过各种方式(@Component,@PostConstruct)这些都不行。 2.最后发现了关键的问题就是添加的回调类(处理类)/初始化的类也必须由s...

轻量级赤影
23分钟前
7
0
消息中间件

本文大概围绕如下几点进行阐述: 为什么使用消息队列? 使用消息队列有什么缺点? 消息队列如何选型? 如何保证消息队列是高可用的? 如何保证消息不被重复消费? 如何保证消费的可靠性传输? 如何...

石日天
26分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部