Ansible模塊

經常使用模塊

ping        # 測試主機的連通性
file        # 用於配置文件屬性
yum         # 用於管理軟件包
cron        # 配置計劃任務
copy/fetch  # 複製文件到遠程主機/複製遠程主機文件到本地
command     # 在遠程主機上執行命令
shell/raw   # 相似於command模塊,支持管道與通配符(最經常使用)
user/group  # 配置用戶/用戶組
service     # 用於管理服務
ping        # 檢測遠程主機是否存活
setup       # 遠程主機基本信息
mount       # 配置掛載點
script      # 腳本複製拷貝相關(最經常使用)
get_url     # 下載模塊
 

user模塊

append                 # (yes|no, default=no) yes:增量添加group,no: 全量變動group,之設置groups指定的group組
comment                # (default=no) 可選設置用戶的帳戶的描述
createhome             # (yes|no,default=yes),建立用戶時或家目錄不存在時建立home目錄
expires                # 用戶過時時間,
force                  # (yes|no default=no) 強制,與state=absent結合使用時,效果等同於 userdel --force
generate_ssh_key       # (yes|no,default=no) 是否生成 ssh Key,不會覆蓋已有的ssh Key
group                  # 可選。設置用戶屬組
groups                 # 設置用戶附加羣組,使用逗號分開多個羣組home                   # 可選,設置用戶家目錄
login_class            # 可選,設置 bsd系統的用戶登陸class
move_home              # (yes|no,default=no,臨時遷移用戶家目錄到指定目錄)name                   #  用戶名
non_unique             # Optionally when used with the -u option, this option allows to change the user ID to a non-unique
password               # 設置用戶密碼爲指定的密碼remove                 # 至關於 userdel remove
shell                  # 設置用戶shell
skeleton # Optionally set a home skeleton directory. Requires createhome option! ssh_key_bits # 指定生成ssh key的加密位數 ssh_key_comment # 定義ssh key的註釋 ssh_key_file # 指定ssh key文件名 ssh_key_passphrase # 設置ssh key密碼 ssh_key_type # 指定ssh key 類型,默認rsa state # (default=present) present,新建用戶;absent,刪除用戶 system # (yes|no,default=no) 當建立新帳戶時,該選項爲yes,爲用戶設置系統帳戶,對已經存在的用戶無效 uid # 可選,設置用戶uid update_password # (no|always,default=always)  always:只有當密碼不相同時纔會更新密碼,on_create:爲新用戶設置密碼

 

示例:html

//新增用戶,使用bash shell,附加組爲admins,dbagroup,家目錄 /home/dba

ansible dba -m user -a "name=dba shell=/bin/bash groups=admins,dbagroup append=yes home=/home/dba state=present"

//修改用戶屬組
ansible dba -m  user -a "name=dba groups=dbagroup append=no"

//修改用戶屬性
ansible dba -m user -a "name=dba expires=1464775222(時間戳)"

// 刪除用戶
ansible dba -m user "name=dba state=abesent remove=yes"

//變動用戶密碼
ansible dba -m user -a "name=tom shell=/bin/bash password="密碼 update_password=always"
 這裏的password爲通過加密後的密碼,兩種方式生成加密密碼:
方法①、
yum install expect makepasswd
mkpasswd --method=SHA-512

方法②、使用python passlib、getpass庫生成密碼
pip install passlib

生成密碼(python3.x)
python -c "from passlib.hash import sha512_crypt;import getpass;print (sha512_crypt.encrypt(getpass.getpass()))"

普通加密算法
python -c "import crypt;print (crypt.crypt("redhat123","dba")"

 

應用層用戶管理(如MySQL用戶管理)java

//添加一個mysql用戶
ansible db -m mysql_user -a "login_host=localhost login_password="mysqlmima login_user=root name=stanly password=stanlymima priv=zabbix.*:all state=present"

 

synchronize 模塊

模塊參數說明node

archive                # 是否採用歸檔模式同步,即以源文件相同屬性同步到目標地址
checksum               # 是否效驗
compress               # 開啓壓縮,默認爲開啓
copy_links             # 同步的時候是否複製鏈接
delete                 # 刪除源中沒有而目標存在的文件(即以推送方爲主)
dest=                  # 目標地址路徑
dest_port              # 目標接受的端口,ansible配置文件中的 ansible_ssh_port 變量優先級高於該 dest_port 變量
dirs                   # 以非遞歸的方式傳輸目錄
existing_only          # Skip creating new files on receiver.
group                  # Preserve group
links                  # Copy symlinks as symlinks.
mode                   # 模式,rsync 同步的方式 PUSH\PULL,默認都是推送push。若是你在使用拉取pull功能的時候,能夠參考以下來實現mode=pull   更改推送模式爲拉取模式
recursive              # 是否遞歸 yes/no
rsync_opts             # 使用rsync 的參數
rsync_path             # 服務的路徑,指定 rsync 命令來在遠程服務器上運行。這個參考rsync命令的--rsync-path參數,--rsync-path=PATH     # 指定遠程服務器上的rsync命令所在路徑信息
rsync_timeout          # 指定 rsync 操做的 IP 超時時間,和rsync命令的 --timeout 參數效果同樣.
set_remote_user        # put user@ for the remote paths. If you have a custom ssh config to define the remote user for
src=\‘#\‘"                  # 源,同步的數據源
times                  # 
--exclude=.Git  忽略同步.git結尾的文件
因爲模塊默認啓用了archive參數,該參數默認開啓了recursive, links, perms, times, owner,group和-D參數。若是你將該參數設置爲no,那麼你將中止不少參數,好比會致使以下目的遞歸失敗,致使沒法拉取

使用synchronize模塊,系統必須安裝rsync 包,不然沒法使用這個模塊
 

示例:python

ansible -i /etc/ansible/web_guanwang huizhongcf -m synchronize -a 'src=/var/lib/jenkins/workspace/HuiZhong/hzcfCMS/ dest=/usr/share/nginx/html/ rsync_opts="--exclude=.git" '

  

解釋:
  指定 /etc/ansible/web_guanwang 目錄下的hosts 文件 裏huizhongcf 組名
  -m 指定模塊名
  -a 命令
  rsync_opts 指定參數 忽略.git 結尾的文件 mysql

 

shell模塊

ansible web -m shell -a 'command' -o
ansible web -m shell -a 'uname -r ' -f 5 -o

 註解: -f 5 線程數  -o 輸出linux

 

chdir命令

shell: chdir={{ tomcat_dir }}/../../ nohup rm -rf work & 

清除tomcat緩存操做ios

 

unarchive 模塊

 
 

一、將ansible主機上的壓縮包在本地解壓縮後傳到遠程主機上,這種狀況下,copy=yes. 本地解壓縮,解壓縮位置不是默認的目錄,沒找到或傳完刪了 後傳到遠程主機nginx

二、將遠程主機上的某個壓縮包解壓縮到指定路徑下。這種狀況下,須要設置copy=no 遠程主機上面的操做,不涉及ansible服務端git

用於解壓文件,模塊包含以下選項:
    copy:默認爲yes。若爲no,則要求目標主機上壓縮包必須存在。
    creates:指定一個文件名,當該文件存在時,則解壓指令不執行
    dest:遠程主機上的一個路徑,即文件解壓的路徑 
    grop:解壓後的目錄或文件的屬組
    list_files:若是爲yes,則會列出壓縮包裏的文件,默認爲no,2.0版本新增的選項
    mode:解決後文件的權限
    src:若是copy爲yes,則須要指定壓縮文件的源路徑 
    owner:解壓後文件或目錄的屬主

示例:web

src: "{{ war_files }}"
dest: "{{ tomcat_root }}"
copy: yes

 

copy模塊

ansible web -m copy  -a 'src=host.py dest=/root/host.py' owner=root group=root  mode=644 backup=yes'

 參數說明

參數名       選項     必須      參數說明
backup       yes/no    no      備份遠程節點上的原始文件,在拷貝以前。若是發生什麼意外,原始文件還能使用。
content      yes/no    no      用來替代src,用於將指定文件的內容,拷貝到遠程文件內
dest         yes/no   yes      用於定位遠程節點上的文件,須要絕對路徑。若是src指向的是文件夾,這個參數也必須是指向文件夾
directory_mode   yes/no   no      這個參數只能用於拷貝文件夾時候,這個設定後,文件夾內新建的文件會被拷貝。而老舊的不會被拷貝
follow       yes/no     no      當拷貝的文件夾內有link存在的時候,那麼拷貝過去的也會有link
group        yes/no   no      指明文件屬組
mode        yes/no    no      指明文件的權限
owner       yes/no      no      指明文件的屬主
src        yes/no    no      文件源地址路徑

 

yum模塊

安裝:ansible web  -m yum -a 'name=httpd state=latest' -f  5 -o
啓動:ansible web  -m yum -a 'name=httpd state=started' -f 5  -o
驗證:ansible web  -m shell -a 'netstat -ntlp| grep httpd ' -f  5 

 

 用戶管理(user)模塊

  首先openssl生成密碼,而後user命令添加用戶

生成密碼
echo ansible|openssl passwd -1 -stdin

新建用戶
ansible web -m user -a 'name=username password="生成的密碼" ' -f 5 -o

 

authorized_key模塊(批量安裝sshkey)

ssh-keyscan xx.xx.xxx.xxx xxx.xxx.xxx.xxx >> /root/.ssh/known_hosts  ##測試貌似沒經過

export ANSIBLE_HOST_KEY_CHECKING=False    ##可用

cat sshkey.yml --- - hosts: Partner gather_facts: false tasks: - name: install sshkey authorized_key: user=root key="{{ lookup('file', '/root/.ssh/id_rsa.pub') }}" state=present
##執行 ansible-playbook -i /etc/ansible/Partner/hosts sshkey.yml --ask-pass

 

get_url模塊

ansible web -m get_url -a "http://xx.com/xx.tar.gz dest=/tmp"

 

lineinfile模塊

lineinfile模塊針對文件特殊行,使用後端引用的正則表達式來替換,相似linux工具中的sed工具

//刪除一行

- name: 刪除一行
   lineinfile:
         dest:  /opt/playbook/test/hosts
         state: absent
         regexp: '^192\.'
   tags: 
   - ...

//添加一行

- name: 添加一行(在最後添加)
   lineinfile:
         dest:  /opt/playbook/test/hosts
         line: '.....'
   tags: 
   - ...


//若是匹配到這一行,引用line這一行做爲替換,若是匹配不到,則引用line這同樣做爲添加

 - name: Fully quoted a line
      lineinfile:
         dest: /opt/playbook/test/testfile
         state: present
         regexp: '^%wheel'
         line: '%wheel  ALL=(ALL)       NOPASSWD: ALL'

      tags:
        - testfile

//關於參數backrefs,backup使用。

  backrefs爲no時,若是沒有匹配,則添加一行line。若是匹配了,則把匹配內容替被換爲line內容。

  backrefs爲yes時,若是沒有匹配,則文件保持不變。若是匹配了,把匹配內容替被換爲line內容。

  backup爲no時,沒有匹配,則添加。若是匹配了,則替換

  backup爲yes時,沒有匹配,添加,若是匹配了,則替換

   
//示例
- name: test backrefs lineinfile: # backup: yes state: present dest: /opt/playbook/test/testfile regexp: '^#\?bar' backrefs: yes line: 'bar' tags: - test_backrefs

 

 

設定regexp匹配不到,而後匹配「insertbefore」文本:

若匹配到「insertbefore」值=1:匹配「insertbefore」值以前的行,精確匹配行「line」;若匹配行「line」到,不作任何操做;若未匹配到,則在「insertbefore」值以前增長行「line」。

若匹配到「insertbefore」值>1:則只有最後一個「insertbefore」值爲有效匹配值,其他同上。

- name: Lineinfile-iptables

  lineinfile:

      dest: /etc/sysconfig/iptables

      regexp: "ruler:other start"

      line: "{{item.line}}"

       insertbefore: "ruler:other end"

       backrefs: yes

       with_items:

        - { line: '-A INPUT -p tcp -m multiport --dports {{TOMCAT_PORT}} -j ACCEPT'}

 

優先匹配「regexp」,若匹配到則直接替換爲「line」,未匹配到則分紅下面的狀況

①   存在backrefs: yes 參數:

A匹配「insertbefore」文本或者「insertafter」文本,若都未匹配到,則不會作任何操做。

B匹配到「insertbefore」文本(匹配多個最後一個有效),會從「insertbefore」文本往前匹配「line」,若匹配不到則新增行「line」,不然不作任何操做。

C匹配到「insertafter」文本(匹配多個最後一個有效),會從「insertafter」文本日後匹配「line」,若匹配不到則新增行「line」,不然不作任何操做。

②   不存在backrefs: yes 參數:

A匹配「insertbefore」文本或者「insertafter」文本,若都未匹配到,則在文件末尾新增行「line」。

B匹配到「insertbefore」文本(匹配多個最後一個有效),直接在「insertbefore」文本前面新增行「line」。

C匹配到「insertafter」文本(匹配多個最後一個有效),直接在「insertafter」文本後面新增行「line」。

- name: Lineinfile-iptables

  lineinfile:

    dest: /etc/sysconfig/iptables

    regexp: "ruler:other start"

    line: "{{item.line}}"

    insertbefore: "ruler:other end"

#   insertafter: "ruler:other start"

    backrefs: yes

  with_items:

    - { line: '-A INPUT -p tcp -m multiport --dports {{TOMCAT_PORT}} -j ACCEPT'}

 

示例

---
- hosts: test
  tasks:
  - name: 修改ssh配置
    lineinfile:
      dest: /etc/ssh/sshd_config        #要修改的配置文件
      regexp: "{{ item.regexp }}"        #要修改的行
      line: "{{ item.line }}"          #修改後的行
      state: present
    with_items:
    - { regexp: "^PasswordAuthentication" , line: "PasswordAuthentication no"}
    - { regexp: "^#PermitRootLogin", line: "PermitRootLogin no"}
    notify: restart ssh
 
  handlers:
  - name: restart ssh
    service: name=sshd.service state=restarted  

 

setup模塊

setup模塊主要用來顯示主機的系統信息(cpu,ip,dns等等),以key:values的形式列出,最主要的功能就是這些信息能夠被playbook的yml文件所引用

如:查看本機的主要ip:playbook裏能夠寫成{{ ansible_ens32.ipv4.address }} (ansible_ens32爲key,ipv4 爲key的values值裏的一個key,address爲ipv4這個key的值裏的key)獲取到的值爲ip:10.10.10.11

 若是想在命令行過濾: ansible 主機組 -m setup -a "filter=ansible_ens32"

10.10.10.11 | SUCCESS => {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "172.17.0.1", 
            "10.10.10.11", 
            "172.18.0.1", 
            "192.168.122.1"
        ], 
        "ansible_all_ipv6_addresses": [
            "fe80::250:56ff:fe93:e5c6"
        ], 
        "ansible_apparmor": {
            "status": "disabled"
        }, 
        "ansible_architecture": "x86_64", 
        "ansible_bios_date": "06/22/2012", 
        "ansible_bios_version": "6.00", 
        "ansible_br_715339010b9c": {
            "active": false, 
            "device": "br-715339010b9c", 
            "features": {
                "busy_poll": "off [fixed]", 
                "fcoe_mtu": "off [fixed]", 
                "generic_receive_offload": "on", 
                "generic_segmentation_offload": "on", 
                "highdma": "on", 
                "hw_tc_offload": "off [fixed]", 
                "l2_fwd_offload": "off [fixed]", 
                "large_receive_offload": "off [fixed]", 
                "loopback": "off [fixed]", 
                "netns_local": "on [fixed]", 
                "ntuple_filters": "off [fixed]", 
                "receive_hashing": "off [fixed]", 
                "rx_all": "off [fixed]", 
                "rx_checksumming": "off [fixed]", 
                "rx_fcs": "off [fixed]", 
                "rx_vlan_filter": "off [fixed]", 
                "rx_vlan_offload": "off [fixed]", 
                "rx_vlan_stag_filter": "off [fixed]", 
                "rx_vlan_stag_hw_parse": "off [fixed]", 
                "scatter_gather": "on", 
                "tcp_segmentation_offload": "on", 
                "tx_checksum_fcoe_crc": "off [fixed]", 
                "tx_checksum_ip_generic": "on", 
                "tx_checksum_ipv4": "off [fixed]", 
                "tx_checksum_ipv6": "off [fixed]", 
                "tx_checksum_sctp": "off [fixed]", 
                "tx_checksumming": "on", 
                "tx_fcoe_segmentation": "on", 
                "tx_gre_segmentation": "on", 
                "tx_gso_robust": "on", 
                "tx_ipip_segmentation": "on", 
                "tx_lockless": "on [fixed]", 
                "tx_mpls_segmentation": "on", 
                "tx_nocache_copy": "off", 
                "tx_scatter_gather": "on", 
                "tx_scatter_gather_fraglist": "on", 
                "tx_sctp_segmentation": "on", 
                "tx_sit_segmentation": "on", 
                "tx_tcp6_segmentation": "on", 
                "tx_tcp_ecn_segmentation": "on", 
                "tx_tcp_segmentation": "on", 
                "tx_udp_tnl_segmentation": "on", 
                "tx_vlan_offload": "on", 
                "tx_vlan_stag_hw_insert": "off [fixed]", 
                "udp_fragmentation_offload": "on", 
                "vlan_challenged": "off [fixed]"
            }, 
            "id": "8000.0242218ae431", 
            "interfaces": [], 
            "ipv4": {
                "address": "172.18.0.1", 
                "broadcast": "global", 
                "netmask": "255.255.0.0", 
                "network": "172.18.0.0"
            }, 
            "macaddress": "02:42:21:8a:e4:31", 
            "mtu": 1500, 
            "promisc": false, 
            "stp": false, 
            "type": "bridge"
        }, 
        "ansible_cmdline": {
            "BOOT_IMAGE": "/vmlinuz-3.10.0-514.26.2.el7.x86_64", 
            "LANG": "en_US.UTF-8", 
            "crashkernel": "auto", 
            "quiet": true, 
            "rd.lvm.lv": "centos/swap", 
            "rhgb": true, 
            "ro": true, 
            "root": "/dev/mapper/centos-root"
        }, 
        "ansible_date_time": {
            "date": "2018-01-18", 
            "day": "18", 
            "epoch": "1516240309", 
            "hour": "09", 
            "iso8601": "2018-01-18T01:51:49Z", 
            "iso8601_basic": "20180118T095149945019", 
            "iso8601_basic_short": "20180118T095149", 
            "iso8601_micro": "2018-01-18T01:51:49.945264Z", 
            "minute": "51", 
            "month": "01", 
            "second": "49", 
            "time": "09:51:49", 
            "tz": "CST", 
            "tz_offset": "+0800", 
            "weekday": "Thursday", 
            "weekday_number": "4", 
            "weeknumber": "03", 
            "year": "2018"
        }, 
        "ansible_default_ipv4": {
            "address": "10.10.10.11", 
            "alias": "ens32", 
            "broadcast": "10.10.10.255", 
            "gateway": "10.10.10.1", 
            "interface": "ens32", 
            "macaddress": "00:50:56:93:e5:c6", 
            "mtu": 1500, 
            "netmask": "255.255.255.0", 
            "network": "10.10.10.0", 
            "type": "ether"
        }, 
        "ansible_default_ipv6": {}, 
        "ansible_devices": {
            "fd0": {
                "holders": [], 
                "host": "", 
                "model": null, 
                "partitions": {}, 
                "removable": "1", 
                "rotational": "1", 
                "sas_address": null, 
                "sas_device_handle": null, 
                "scheduler_mode": "deadline", 
                "sectors": "8", 
                "sectorsize": "512", 
                "size": "4.00 KB", 
                "support_discard": "0", 
                "vendor": null
            }, 
            "sda": {
                "holders": [], 
                "host": "SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)", 
                "model": "Virtual disk", 
                "partitions": {
                    "sda1": {
                        "holders": [], 
                        "sectors": "1024000", 
                        "sectorsize": 512, 
                        "size": "500.00 MB", 
                        "start": "2048", 
                        "uuid": "d8dc2423-3de9-44d6-a983-ec66e55581bf"
                    }, 
                    "sda2": {
                        "holders": [
                            "centos-root", 
                            "centos-swap", 
                            "centos-home"
                        ], 
                        "sectors": "418404352", 
                        "sectorsize": 512, 
                        "size": "199.51 GB", 
                        "start": "1026048", 
                        "uuid": null
                    }
                }, 
                "removable": "0", 
                "rotational": "1", 
                "sas_address": null, 
                "sas_device_handle": null, 
                "scheduler_mode": "deadline", 
                "sectors": "419430400", 
                "sectorsize": "512", 
                "size": "200.00 GB", 
                "support_discard": "0", 
                "vendor": "VMware"
            }, 
            "sr0": {
                "holders": [], 
                "host": "IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)", 
                "model": "VMware IDE CDR10", 
                "partitions": {}, 
                "removable": "1", 
                "rotational": "1", 
                "sas_address": null, 
                "sas_device_handle": null, 
                "scheduler_mode": "cfq", 
                "sectors": "2097151", 
                "sectorsize": "512", 
                "size": "1024.00 MB", 
                "support_discard": "0", 
                "vendor": "NECVMWar"
            }
        }, 
        "ansible_distribution": "CentOS", 
        "ansible_distribution_major_version": "7", 
        "ansible_distribution_release": "Core", 
        "ansible_distribution_version": "7.3.1611", 
        "ansible_dns": {
            "nameservers": [
                "219.141.136.10"
            ]
        }, 
        "ansible_docker0": {
            "active": false, 
            "device": "docker0", 
            "features": {
                "busy_poll": "off [fixed]", 
                "fcoe_mtu": "off [fixed]", 
                "generic_receive_offload": "on", 
                "generic_segmentation_offload": "on", 
                "highdma": "on", 
                "hw_tc_offload": "off [fixed]", 
                "l2_fwd_offload": "off [fixed]", 
                "large_receive_offload": "off [fixed]", 
                "loopback": "off [fixed]", 
                "netns_local": "on [fixed]", 
                "ntuple_filters": "off [fixed]", 
                "receive_hashing": "off [fixed]", 
                "rx_all": "off [fixed]", 
                "rx_checksumming": "off [fixed]", 
                "rx_fcs": "off [fixed]", 
                "rx_vlan_filter": "off [fixed]", 
                "rx_vlan_offload": "off [fixed]", 
                "rx_vlan_stag_filter": "off [fixed]", 
                "rx_vlan_stag_hw_parse": "off [fixed]", 
                "scatter_gather": "on", 
                "tcp_segmentation_offload": "on", 
                "tx_checksum_fcoe_crc": "off [fixed]", 
                "tx_checksum_ip_generic": "on", 
                "tx_checksum_ipv4": "off [fixed]", 
                "tx_checksum_ipv6": "off [fixed]", 
                "tx_checksum_sctp": "off [fixed]", 
                "tx_checksumming": "on", 
                "tx_fcoe_segmentation": "on", 
                "tx_gre_segmentation": "on", 
                "tx_gso_robust": "on", 
                "tx_ipip_segmentation": "on", 
                "tx_lockless": "on [fixed]", 
                "tx_mpls_segmentation": "on", 
                "tx_nocache_copy": "off", 
                "tx_scatter_gather": "on", 
                "tx_scatter_gather_fraglist": "on", 
                "tx_sctp_segmentation": "on", 
                "tx_sit_segmentation": "on", 
                "tx_tcp6_segmentation": "on", 
                "tx_tcp_ecn_segmentation": "on", 
                "tx_tcp_segmentation": "on", 
                "tx_udp_tnl_segmentation": "on", 
                "tx_vlan_offload": "on", 
                "tx_vlan_stag_hw_insert": "off [fixed]", 
                "udp_fragmentation_offload": "on", 
                "vlan_challenged": "off [fixed]"
            }, 
            "id": "8000.024263e72f42", 
            "interfaces": [], 
            "ipv4": {
                "address": "172.17.0.1", 
                "broadcast": "global", 
                "netmask": "255.255.0.0", 
                "network": "172.17.0.0"
            }, 
            "macaddress": "02:42:63:e7:2f:42", 
            "mtu": 1500, 
            "promisc": false, 
            "stp": false, 
            "type": "bridge"
        }, 
        "ansible_domain": "", 
        "ansible_effective_group_id": 0, 
        "ansible_effective_user_id": 0, 
        "ansible_ens32": {
            "active": true, 
            "device": "ens32", 
            "features": {
                "busy_poll": "off [fixed]", 
                "fcoe_mtu": "off [fixed]", 
                "generic_receive_offload": "on", 
                "generic_segmentation_offload": "on", 
                "highdma": "off [fixed]", 
                "hw_tc_offload": "off [fixed]", 
                "l2_fwd_offload": "off [fixed]", 
                "large_receive_offload": "off [fixed]", 
                "loopback": "off [fixed]", 
                "netns_local": "off [fixed]", 
                "ntuple_filters": "off [fixed]", 
                "receive_hashing": "off [fixed]", 
                "rx_all": "off", 
                "rx_checksumming": "off", 
                "rx_fcs": "off", 
                "rx_vlan_filter": "on [fixed]", 
                "rx_vlan_offload": "on", 
                "rx_vlan_stag_filter": "off [fixed]", 
                "rx_vlan_stag_hw_parse": "off [fixed]", 
                "scatter_gather": "on", 
                "tcp_segmentation_offload": "on", 
                "tx_checksum_fcoe_crc": "off [fixed]", 
                "tx_checksum_ip_generic": "on", 
                "tx_checksum_ipv4": "off [fixed]", 
                "tx_checksum_ipv6": "off [fixed]", 
                "tx_checksum_sctp": "off [fixed]", 
                "tx_checksumming": "on", 
                "tx_fcoe_segmentation": "off [fixed]", 
                "tx_gre_segmentation": "off [fixed]", 
                "tx_gso_robust": "off [fixed]", 
                "tx_ipip_segmentation": "off [fixed]", 
                "tx_lockless": "off [fixed]", 
                "tx_mpls_segmentation": "off [fixed]", 
                "tx_nocache_copy": "off", 
                "tx_scatter_gather": "on", 
                "tx_scatter_gather_fraglist": "off [fixed]", 
                "tx_sctp_segmentation": "off [fixed]", 
                "tx_sit_segmentation": "off [fixed]", 
                "tx_tcp6_segmentation": "off [fixed]", 
                "tx_tcp_ecn_segmentation": "off [fixed]", 
                "tx_tcp_segmentation": "on", 
                "tx_udp_tnl_segmentation": "off [fixed]", 
                "tx_vlan_offload": "on [fixed]", 
                "tx_vlan_stag_hw_insert": "off [fixed]", 
                "udp_fragmentation_offload": "off [fixed]", 
                "vlan_challenged": "off [fixed]"
            }, 
            "ipv4": {
                "address": "10.10.10.11", 
                "broadcast": "10.10.10.255", 
                "netmask": "255.255.255.0", 
                "network": "10.10.10.0"
            }, 
            "ipv6": [
                {
                    "address": "fe80::250:56ff:fe93:e5c6", 
                    "prefix": "64", 
                    "scope": "link"
                }
            ], 
            "macaddress": "00:50:56:93:e5:c6", 
            "module": "e1000", 
            "mtu": 1500, 
            "pciid": "0000:02:00.0", 
            "promisc": false, 
            "speed": 1000, 
            "type": "ether"
        }, 
        "ansible_env": {
            "CLASSPATH": ".:/usr/local/java/jdk1.8.0_151/jre/lib/rt.jar:/usr/local/java/jdk1.8.0_151/lib/dt.jar:/usr/local/java/jdk1.8.0_151/lib/tools.jar", 
            "HARDWARE_PLATFORM": "x86_64", 
            "HOME": "/root", 
            "JAVA_HOME": "/usr/local/java/jdk1.8.0_151", 
            "LANG": "en_US.UTF-8", 
            "LESSOPEN": "||/usr/bin/lesspipe.sh %s", 
            "LOGNAME": "root", 
            "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:", 
            "MAIL": "/var/mail/root", 
            "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/java/jdk1.8.0_151/bin", 
            "PWD": "/root", 
            "SHELL": "/bin/bash", 
            "SHLVL": "2", 
            "SSH_CLIENT": "10.10.10.11 44884 22", 
            "SSH_CONNECTION": "10.10.10.11 44884 10.10.10.11 22", 
            "SSH_TTY": "/dev/pts/2", 
            "TERM": "xterm", 
            "USER": "root", 
            "XDG_RUNTIME_DIR": "/run/user/0", 
            "XDG_SESSION_ID": "4036", 
            "_": "/usr/bin/python"
        }, 
        "ansible_fips": false, 
        "ansible_form_factor": "Other", 
        "ansible_fqdn": "bogon", 
        "ansible_gather_subset": [
            "hardware", 
            "network", 
            "virtual"
        ], 
        "ansible_hostname": "bogon", 
        "ansible_interfaces": [
            "docker0", 
            "lo", 
            "ens32", 
            "br-715339010b9c", 
            "virbr0-nic", 
            "virbr0"
        ], 
        "ansible_kernel": "3.10.0-514.26.2.el7.x86_64", 
        "ansible_lo": {
            "active": true, 
            "device": "lo", 
            "features": {
                "busy_poll": "off [fixed]", 
                "fcoe_mtu": "off [fixed]", 
                "generic_receive_offload": "on", 
                "generic_segmentation_offload": "on", 
                "highdma": "on [fixed]", 
                "hw_tc_offload": "off [fixed]", 
                "l2_fwd_offload": "off [fixed]", 
                "large_receive_offload": "off [fixed]", 
                "loopback": "on [fixed]", 
                "netns_local": "on [fixed]", 
                "ntuple_filters": "off [fixed]", 
                "receive_hashing": "off [fixed]", 
                "rx_all": "off [fixed]", 
                "rx_checksumming": "on [fixed]", 
                "rx_fcs": "off [fixed]", 
                "rx_vlan_filter": "off [fixed]", 
                "rx_vlan_offload": "off [fixed]", 
                "rx_vlan_stag_filter": "off [fixed]", 
                "rx_vlan_stag_hw_parse": "off [fixed]", 
                "scatter_gather": "on", 
                "tcp_segmentation_offload": "on", 
                "tx_checksum_fcoe_crc": "off [fixed]", 
                "tx_checksum_ip_generic": "on [fixed]", 
                "tx_checksum_ipv4": "off [fixed]", 
                "tx_checksum_ipv6": "off [fixed]", 
                "tx_checksum_sctp": "on [fixed]", 
                "tx_checksumming": "on", 
                "tx_fcoe_segmentation": "off [fixed]", 
                "tx_gre_segmentation": "off [fixed]", 
                "tx_gso_robust": "off [fixed]", 
                "tx_ipip_segmentation": "off [fixed]", 
                "tx_lockless": "on [fixed]", 
                "tx_mpls_segmentation": "off [fixed]", 
                "tx_nocache_copy": "off [fixed]", 
                "tx_scatter_gather": "on [fixed]", 
                "tx_scatter_gather_fraglist": "on [fixed]", 
                "tx_sctp_segmentation": "on", 
                "tx_sit_segmentation": "off [fixed]", 
                "tx_tcp6_segmentation": "on", 
                "tx_tcp_ecn_segmentation": "on", 
                "tx_tcp_segmentation": "on", 
                "tx_udp_tnl_segmentation": "off [fixed]", 
                "tx_vlan_offload": "off [fixed]", 
                "tx_vlan_stag_hw_insert": "off [fixed]", 
                "udp_fragmentation_offload": "on", 
                "vlan_challenged": "on [fixed]"
            }, 
            "ipv4": {
                "address": "127.0.0.1", 
                "broadcast": "host", 
                "netmask": "255.0.0.0", 
                "network": "127.0.0.0"
            }, 
            "ipv6": [
                {
                    "address": "::1", 
                    "prefix": "128", 
                    "scope": "host"
                }
            ], 
            "mtu": 65536, 
            "promisc": false, 
            "type": "loopback"
        }, 
        "ansible_lvm": {
            "lvs": {
                "home": {
                    "size_g": "148.70", 
                    "vg": "centos"
                }, 
                "root": {
                    "size_g": "50.00", 
                    "vg": "centos"
                }, 
                "swap": {
                    "size_g": "0.75", 
                    "vg": "centos"
                }
            }, 
            "vgs": {
                "centos": {
                    "free_g": "0.06", 
                    "num_lvs": "3", 
                    "num_pvs": "1", 
                    "size_g": "199.51"
                }
            }
        }, 
        "ansible_machine": "x86_64", 
        "ansible_machine_id": "2b31f6e89b764c1dbf1feed150e6387e", 
        "ansible_memfree_mb": 1379, 
        "ansible_memory_mb": {
            "nocache": {
                "free": 10284, 
                "used": 5603
            }, 
            "real": {
                "free": 1379, 
                "total": 15887, 
                "used": 14508
            }, 
            "swap": {
                "cached": 0, 
                "free": 767, 
                "total": 767, 
                "used": 0
            }
        }, 
        "ansible_memtotal_mb": 15887, 
        "ansible_mounts": [
            {
                "device": "/dev/mapper/centos-root", 
                "fstype": "xfs", 
                "mount": "/", 
                "options": "rw,relatime,attr2,inode64,noquota", 
                "size_available": 28555288576, 
                "size_total": 53660876800, 
                "uuid": "8767ae54-8e15-434f-a128-cfcf10e9dd94"
            }, 
            {
                "device": "/dev/sda1", 
                "fstype": "xfs", 
                "mount": "/boot", 
                "options": "rw,relatime,attr2,inode64,noquota", 
                "size_available": 295768064, 
                "size_total": 520794112, 
                "uuid": "d8dc2423-3de9-44d6-a983-ec66e55581bf"
            }, 
            {
                "device": "/dev/mapper/centos-home", 
                "fstype": "xfs", 
                "mount": "/home", 
                "options": "rw,relatime,attr2,inode64,noquota", 
                "size_available": 118263951360, 
                "size_total": 159582416896, 
                "uuid": "6cb4a5e8-c6ef-4aa0-9962-c0f9dc5a3bd7"
            }, 
            {
                "device": "/dev/mapper/centos-root", 
                "fstype": "xfs", 
                "mount": "/var/lib/docker/overlay", 
                "options": "rw,relatime,attr2,inode64,noquota,bind", 
                "size_available": 28555288576, 
                "size_total": 53660876800, 
                "uuid": "8767ae54-8e15-434f-a128-cfcf10e9dd94"
            }
        ], 
        "ansible_nodename": "bogon", 
        "ansible_os_family": "RedHat", 
        "ansible_pkg_mgr": "yum", 
        "ansible_processor": [
            "GenuineIntel", 
            "Intel(R) Xeon(R) CPU E5-2609 0 @ 2.40GHz"
        ], 
        "ansible_processor_cores": 1, 
        "ansible_processor_count": 1, 
        "ansible_processor_threads_per_core": 1, 
        "ansible_processor_vcpus": 1, 
        "ansible_product_name": "VMware Virtual Platform", 
        "ansible_product_serial": "VMware-42 13 5f e0 8d cd 65 83-11 c5 1a 9d 2a db af c6", 
        "ansible_product_uuid": "42135FE0-8DCD-6583-11C5-1A9D2ADBAFC6", 
        "ansible_product_version": "None", 
        "ansible_python": {
            "executable": "/usr/bin/python", 
            "has_sslcontext": true, 
            "type": "CPython", 
            "version": {
                "major": 2, 
                "micro": 5, 
                "minor": 7, 
                "releaselevel": "final", 
                "serial": 0
            }, 
            "version_info": [
                2, 
                7, 
                5, 
                "final", 
                0
            ]
        }, 
        "ansible_python_version": "2.7.5", 
        "ansible_real_group_id": 0, 
        "ansible_real_user_id": 0, 
        "ansible_selinux": {
            "status": "disabled"
        }, 
        "ansible_service_mgr": "systemd", 
        "ansible_ssh_host_key_ecdsa_public": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBE700gduIJpJxhp8EqsoUZRzoilVN05yzb9iK5nn9M6dJ0Yw6tkySsr6su4hc2Zpb2fzWpFofvG/hzYtefL4HOs=", 
        "ansible_ssh_host_key_ed25519_public": "AAAAC3NzaC1lZDI1NTE5AAAAINyD5dVhLehvWunswzhduxK0JQI8Fq1qItw/0k86MC76", 
        "ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDUK3RE3vy6eICHEqVwZ5zgksP1+J0oboKnCrkwYJxCFEPzGG6eQoyfRANIp0fjUagGj5AXebBdCagzrneVH7zNjxs2+2gIrH0iDbhiSMqKXCltnJwJssxI4XgXXJlFa42Wh2bCC6qUf3+o+nCkwQWBhGsZUM//GkRsIDNdXrnX7tfIKham8i205GQlADAxO2OaXsnsJ7/2IxBCabFyaJ55Si1gwqBhF+XtCCeTXCxX9AiUvu8lTSB69fukPDugh45pnq05tFU6IoY9F2EgTIK9eNP8TxAa1cwzRbUTtCYHdC2qEijX1hv43n+PwHxf2Q4pZ0HmUBfgRwOFx14LKh7l", 
        "ansible_swapfree_mb": 767, 
        "ansible_swaptotal_mb": 767, 
        "ansible_system": "Linux", 
        "ansible_system_capabilities": [
            "cap_chown", 
            "cap_dac_override", 
            "cap_dac_read_search", 
            "cap_fowner", 
            "cap_fsetid", 
            "cap_kill", 
            "cap_setgid", 
            "cap_setuid", 
            "cap_setpcap", 
            "cap_linux_immutable", 
            "cap_net_bind_service", 
            "cap_net_broadcast", 
            "cap_net_admin", 
            "cap_net_raw", 
            "cap_ipc_lock", 
            "cap_ipc_owner", 
            "cap_sys_module", 
            "cap_sys_rawio", 
            "cap_sys_chroot", 
            "cap_sys_ptrace", 
            "cap_sys_pacct", 
            "cap_sys_admin", 
            "cap_sys_boot", 
            "cap_sys_nice", 
            "cap_sys_resource", 
            "cap_sys_time", 
            "cap_sys_tty_config", 
            "cap_mknod", 
            "cap_lease", 
            "cap_audit_write", 
            "cap_audit_control", 
            "cap_setfcap", 
            "cap_mac_override", 
            "cap_mac_admin", 
            "cap_syslog", 
            "35", 
            "36+ep"
        ], 
        "ansible_system_capabilities_enforced": "True", 
        "ansible_system_vendor": "VMware, Inc.", 
        "ansible_uptime_seconds": 1275247, 
        "ansible_user_dir": "/root", 
        "ansible_user_gecos": "root", 
        "ansible_user_gid": 0, 
        "ansible_user_id": "root", 
        "ansible_user_shell": "/bin/bash", 
        "ansible_user_uid": 0, 
        "ansible_userspace_architecture": "x86_64", 
        "ansible_userspace_bits": "64", 
        "ansible_virbr0": {
            "active": false, 
            "device": "virbr0", 
            "features": {
                "busy_poll": "off [fixed]", 
                "fcoe_mtu": "off [fixed]", 
                "generic_receive_offload": "on", 
                "generic_segmentation_offload": "on", 
                "highdma": "off [requested on]", 
                "hw_tc_offload": "off [fixed]", 
                "l2_fwd_offload": "off [fixed]", 
                "large_receive_offload": "off [fixed]", 
                "loopback": "off [fixed]", 
                "netns_local": "on [fixed]", 
                "ntuple_filters": "off [fixed]", 
                "receive_hashing": "off [fixed]", 
                "rx_all": "off [fixed]", 
                "rx_checksumming": "off [fixed]", 
                "rx_fcs": "off [fixed]", 
                "rx_vlan_filter": "off [fixed]", 
                "rx_vlan_offload": "off [fixed]", 
                "rx_vlan_stag_filter": "off [fixed]", 
                "rx_vlan_stag_hw_parse": "off [fixed]", 
                "scatter_gather": "on", 
                "tcp_segmentation_offload": "off", 
                "tx_checksum_fcoe_crc": "off [fixed]", 
                "tx_checksum_ip_generic": "on", 
                "tx_checksum_ipv4": "off [fixed]", 
                "tx_checksum_ipv6": "off [fixed]", 
                "tx_checksum_sctp": "off [fixed]", 
                "tx_checksumming": "on", 
                "tx_fcoe_segmentation": "off [requested on]", 
                "tx_gre_segmentation": "on", 
                "tx_gso_robust": "off [requested on]", 
                "tx_ipip_segmentation": "on", 
                "tx_lockless": "on [fixed]", 
                "tx_mpls_segmentation": "on", 
                "tx_nocache_copy": "off", 
                "tx_scatter_gather": "on", 
                "tx_scatter_gather_fraglist": "on", 
                "tx_sctp_segmentation": "off [requested on]", 
                "tx_sit_segmentation": "on", 
                "tx_tcp6_segmentation": "off [requested on]", 
                "tx_tcp_ecn_segmentation": "off [requested on]", 
                "tx_tcp_segmentation": "off [requested on]", 
                "tx_udp_tnl_segmentation": "on", 
                "tx_vlan_offload": "on", 
                "tx_vlan_stag_hw_insert": "off [fixed]", 
                "udp_fragmentation_offload": "off [requested on]", 
                "vlan_challenged": "off [fixed]"
            }, 
            "id": "8000.525400b76fef", 
            "interfaces": [
                "virbr0-nic"
            ], 
            "ipv4": {
                "address": "192.168.122.1", 
                "broadcast": "192.168.122.255", 
                "netmask": "255.255.255.0", 
                "network": "192.168.122.0"
            }, 
            "macaddress": "52:54:00:b7:6f:ef", 
            "mtu": 1500, 
            "promisc": false, 
            "stp": true, 
            "type": "bridge"
        }, 
        "ansible_virbr0_nic": {
            "active": false, 
            "device": "virbr0-nic", 
            "features": {
                "busy_poll": "off [fixed]", 
                "fcoe_mtu": "off [fixed]", 
                "generic_receive_offload": "on", 
                "generic_segmentation_offload": "on", 
                "highdma": "off [fixed]", 
                "hw_tc_offload": "off [fixed]", 
                "l2_fwd_offload": "off [fixed]", 
                "large_receive_offload": "off [fixed]", 
                "loopback": "off [fixed]", 
                "netns_local": "off [fixed]", 
                "ntuple_filters": "off [fixed]", 
                "receive_hashing": "off [fixed]", 
                "rx_all": "off [fixed]", 
                "rx_checksumming": "off [fixed]", 
                "rx_fcs": "off [fixed]", 
                "rx_vlan_filter": "off [fixed]", 
                "rx_vlan_offload": "off [fixed]", 
                "rx_vlan_stag_filter": "off [fixed]", 
                "rx_vlan_stag_hw_parse": "off [fixed]", 
                "scatter_gather": "on", 
                "tcp_segmentation_offload": "off", 
                "tx_checksum_fcoe_crc": "off [fixed]", 
                "tx_checksum_ip_generic": "off [requested on]", 
                "tx_checksum_ipv4": "off [fixed]", 
                "tx_checksum_ipv6": "off [fixed]", 
                "tx_checksum_sctp": "off [fixed]", 
                "tx_checksumming": "off", 
                "tx_fcoe_segmentation": "off [fixed]", 
                "tx_gre_segmentation": "off [fixed]", 
                "tx_gso_robust": "off [fixed]", 
                "tx_ipip_segmentation": "off [fixed]", 
                "tx_lockless": "on [fixed]", 
                "tx_mpls_segmentation": "off [fixed]", 
                "tx_nocache_copy": "off", 
                "tx_scatter_gather": "on", 
                "tx_scatter_gather_fraglist": "on", 
                "tx_sctp_segmentation": "off [fixed]", 
                "tx_sit_segmentation": "off [fixed]", 
                "tx_tcp6_segmentation": "off [requested on]", 
                "tx_tcp_ecn_segmentation": "off [requested on]", 
                "tx_tcp_segmentation": "off [requested on]", 
                "tx_udp_tnl_segmentation": "off [fixed]", 
                "tx_vlan_offload": "on", 
                "tx_vlan_stag_hw_insert": "on", 
                "udp_fragmentation_offload": "off [requested on]", 
                "vlan_challenged": "off [fixed]"
            }, 
            "macaddress": "52:54:00:b7:6f:ef", 
            "mtu": 1500, 
            "promisc": true, 
            "type": "ether"
        }, 
        "ansible_virtualization_role": "guest", 
        "ansible_virtualization_type": "VMware", 
        "module_setup": true
    }, 
    "changed": false
}
相關文章
相關標籤/搜索