Asible 批量跑出服务器的特权用户
作者:互联网
1、定义剧本(我这里只输出序列号) [root@libin3]# cat libin.yml - hosts: task gather_facts: no tasks: - name: fetch shell: | awk -F ":" '{ print $1,$7 }' /etc/passwd | grep -v "/sbin/nologin" | grep -v "root" | awk -F " " '{ print $1}' 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= 3、执行ansible任务 [root@libin3]# ansible-playbook -i hosts task libin.yaml
标签:libin3,task,Asible,批量,ansible,libin,become,服务器,root 来源: https://www.cnblogs.com/libin-linux/p/16609214.html