一、忽略hosts,只在一台机器上执行:
/usr/local/bin/ansible-playbook /app/ansiblecfg/ztr/ent_extract.yml --limit=10.128.109.196
二、批量推送密钥
在ansible管理主机生成密钥id_rsa.pub,使用如下playbook推送密钥至受控主机节点
#push key to remote server
- hosts: nengqian
user: ccssoft
tasks:
- name: ssh-copy
authorized_key: user=ccssoft key="{{ lookup('file', '/home/shdxspark/.ssh/id_rsa.pub') }}"
tags:
- sshkey
user为远程主机账号,key为管理主机生成的公钥key