用户工具

站点工具


ansible

这是本文档旧的修订版!


ansible

Usage

Add public key to server

1. Edit host inventory, add server host like this:

host
[test]
test1 ansible_ssh_host=1.1.1.1

2. Create upload_ssh_keys.yml:

upload_ssh_keys.yml
---
- hosts: all
  remote_user: root
  tasks:
    - name: upload key to server
      authorized_key:
        user: root
        state: present
        key: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/id_rsa.pub') }}"

3. Run ansible-playbook command:

ansible-playbook -l test upload_ssh_keys.yml
ansible.1501647016.txt.gz · 最后更改: (外部编辑)