zhuguojun6 发表于 2018-7-31 16:09:02

ansible批量免密脚本

- hosts: all
vars:
    ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
tasks:
    - name: check system os
      fail:
      msg: " This System_OS Unsupport! "
      when: (ansible_os_family != "CentOS")and(ansible_os_family != "RedHat")


    - name: check_ansible_env
      debug:
      msg: "The client ip is {{ansible_default_ipv4.address}}"


    - name: Set authorized key took from file
      authorized_key:
         user: "{{ansible_user_id}}"
         state: present
         key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"


king_python 发表于 2018-7-31 19:00:34

666

king_python 发表于 2018-7-31 19:00:59

666

zhy1022wo 发表于 2018-8-15 10:32:00

赞!
页: [1]
查看完整版本: ansible批量免密脚本