有谁知道ansible是怎么读的html
简单的介绍一下这个东西,首先这个东西是用python写的python
个人是四台虚拟机,centos系统,而后的话是安装了k8s的分别是shell
可是这个都无论,咱们主要是用来作ansible的实验,还有若是文章中没有说明,那么一切操做都是在k8s-master节点上操做express
安装直接使用包管理器安装就行了vim
yum install epel-release
centos
yum install ansible
bash
首先在k8s-master节点生成秘钥app
ssh-keygen -t rsa
dom
以后一路回车ssh
以后把秘钥导入到每一台机器中
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
下面有几个配置文件要注意 一下
首先是
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-doc -l
来查看ansible中包含的一些模块
固然咱们能够这样去搜索模块
ansible-doc -l |grep copy
asnible-doc这个命令是用来获取各个模块的帮助信息的,好比我要查看copy模块的帮助信息
ansible-doc -s 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命令的
这个模块是用来建立计划任务的
好比建立一个每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
这个就是把本地的脚本上传到远端去执行
首先新建一个脚本
[root@bboysoul-k8s-master ~]# cat test.sh #!/bin/bash echo "ansible test ok"
以后使用这个模块执行
ansible all -m script -a "./test.sh"
说真的模块太多了,不可能每一个都知道都会使用的,若是你不会那么
ansible-doc -s 模块名
前面废话说完了,下面进入正题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