Asible 批量跑出服务器相关信息

1、定义剧本(我这里只输出序列号)

[root@libin3]# cat libin.yml 
- hosts: task
  gather_facts: no
  tasks:
    - name: fetch
      shell: |
        dmidecode -t 1 | grep "Serial Number" | awk -F ":" '{print $2}'
      register: serial
    - name: dd
      shell: |
        echo "{{serial.stdout}},{{inventory_hostname}}" >> libin.csv
      delegate_to: localhost
2、定义清单


[root@libin3]# cat hosts [task] ip地址 [task:vars] ansible_become=yes ansible_become_method=sudo ansible_become_user=root ansible_become_password= ansible_user= ansible_password=

  

相关文章

----name:setpublickeyonremotehosts&setreomtehostssud...
环境准备#cat/etcedhat-releaseCentOSLinuxrelease7.9.2009(...
准备好环境,在安装之前请先了解openshift提供的ansible有大...
Ansible:运维工作:系统安装(物理机、虚拟机)-->程序包...
ansible与salt对比相同都是为了同时在多台机器上执行相同的命...
[root@node1playbook]#catnginx.yml-hosts:test\\主...