You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

users.yaml 971B

3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. ---
  2. - hosts:
  3. - servers
  4. - desktops
  5. - laptops
  6. remote_user: root
  7. roles:
  8. - name: users
  9. # - hosts: desktops:laptops
  10. # remote_user: root
  11. # tasks:
  12. # - name: /etc/ssh/ssh_config
  13. # template:
  14. # src: ssh_config.j2
  15. # dest: /etc/ssh/ssh_config
  16. # - name: ssh known hosts
  17. # known_hosts:
  18. # name: "{{item}}"
  19. # key: "{{item}},{{hostvars[item].ansible_default_ipv4.address}} {{hostvars[item].ansible_ssh_host_key_ed25519_public_keytype}} {{hostvars[item].ansible_ssh_host_key_ed25519_public}}"
  20. # path: /etc/ssh/ssh_known_hosts
  21. # loop: "{{groups.servers}}"
  22. - hosts:
  23. - servers
  24. remote_user: root
  25. tasks:
  26. - name: authorize ssh public keys
  27. authorized_key:
  28. user: "{{item.name}}"
  29. key: "{{item.ssh_public_key}}"
  30. loop: "{{ hostvars | json_query(\"*.user_ssh_keys_info.results[]\") }}"
  31. loop_control:
  32. label: "{{ item.name }}"
  33. tags:
  34. - users