add inistal user creation

This commit is contained in:
NotAFile 2018-03-18 02:17:21 +01:00
parent 2ae147a1be
commit f3fe57ca09
1 changed files with 24 additions and 0 deletions

24
main.yaml Normal file
View File

@ -0,0 +1,24 @@
---
- hosts: userhosts
remote_user: ansible
vars:
git_url: "https://git.togrand.xyz"
tasks:
- name: fetch user list from api
uri:
url: "{{ git_url }}/api/v1/orgs/mrtogrand/members"
return_content: yes
register: members
- name: "create users"
user:
name: "{{ item }}"
with_items: "{{ members | json_query('json[*].login') }}"
- name: import user public keys
authorized_key:
key: "{{ git_url }}/{{ item }}.keys"
exclusive: yes
user: "{{ item }}"
with_items: "{{ members | json_query('json[*].login') }}"