配置個人ansible工作目錄,編寫自動免密yml文件

mkdir /root/2019ansible

cd /root/2019ansible

vim ansible.cfg

[defaults]

inventory = hosts

remote_user = root

vim hosts

[webservers]

node1.sina.com

node2.sina.com

vim auth_key.yml

---

- name: configure authorized key

  hosts: all

  tasks:

  - name: auth key

    authorized_key:

    user: root

    state: present

    key: "{{ lookup('file', '/root/.ssh/id_rsa.pub') }}"

 

執行命令

ansible-playbook auth_key.yml -k

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章