ansible批量免密脚本
- hosts: allvars:
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') }}"
666 666 赞!
页:
[1]