Añadir 'playbooks/create_user_ssh/main2.yml'

This commit is contained in:
David Lopez 2023-07-20 19:42:50 +00:00
parent b349ec77e9
commit 672eef2873
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
---
- hosts: webservers #modify your server list
remote_user: root
tasks:
- include_vars: users.yml
- name: Creating users to Jump Server
user: name="{{ item.username}}"
with_items: "{{ users }}"
- name: Placing SSH Key to Authorized Key
#please note that this code assumes as if the public-private key pair is generated, all public users (created above) have public keys copied at one place i.e. keyfiles directory for the ease
authorized_key: user="{{item.username}}" key="{{ lookup('file', './keyfiles/authorized_keys.{{ item.username}}.pub')}}"
with_items: "{{ users }}"