初识ansible

概述

有谁知道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

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏JadePeng的技术博客

Jhipster Registry(Eureka Server) Docker双向联通与高可用部署

构建Image并push到registry,这里是192.168.86.8:5000/registry-dev

21650
来自专栏cloudskyme

虚拟化平台cloudstack(8)——从UI开始

UI ucloudstack采用的是前后端分离的架构,就是说前端可以选择使用web、swing甚至其它的界面,都可以。 我们来看cloudstack的UI信息吧...

40460
来自专栏Java3y

Druid数据库连接池就是这么简单

前言 本章节主要讲解Druid数据库连接池,为什么要学Druid数据库连接池呢?? 我的知识储备数据库连接池有两种->C3P0,DBCP,可是现在看起来并不够用...

558110
来自专栏猿人谷

cocos2d-x 学习笔录:将iOS项目编译成Andriod项目

一、Android 环境搭建 1、安装Andriod-NDK(Native Development Kit)   新建一个文件夹(eg:NDK),解压Andro...

22270
来自专栏Ryan Miao

gradle中使用嵌入式(embedded) tomcat, debug 启动

在gradle项目中使用embedded tomcat。 最开始部署项目需要手动将web项目打成war包,然后手动上传到tomcat的webapp下,然后启动t...

53390
来自专栏about云

flume搜集日志:如何解决实时不断追加的日志文件及不断增加的文件个数问题

本文的背景: 在搜集日志的过程中,日志文件的个数及日志文件需要不断的追加。flume1.6中,可以使用tail -f可以解决不断追加的文件,但是由于日志文件的个...

43370
来自专栏程序员同行者

08-部署node节点

13220
来自专栏Seebug漏洞平台

D-Link系列路由器漏洞挖掘入门

作者:Sebao@知道创宇404实验室 前 言 前几天去上海参加了geekpwn,看着大神们一个个破解成功各种硬件,我只能在下面喊 6666,特别羡慕那些...

46580
来自专栏黑白安全

Kali Linux渗透之获取主机名、MAC

------Kali Linux无线渗透之主机名、MAC与wifi信息获取------

29540
来自专栏Jerry的SAP技术分享

CRM WebUI and Hybris的Product页面标题实现

Controller只需实现IF_BSP_WD_HISTORY_STATE_DESCR~GET_STATE_DESCRIPTION方法:

41340

扫码关注云+社区

领取腾讯云代金券