-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add playbook to run on controller node
- Loading branch information
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- hosts: 127.0.0.1 | ||
connection: local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ssh_users: | ||
agrabeli: | ||
login: agrabeli | ||
comment: Maria Xynou | ||
keys: ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDD0JSwM+t3Uz9lS3Mjoz9oo4vOToWyzboZhYQbP8JY5HvFtAvWanWHnUBO91t6hkgKIMiUqhdCJn26fqkhSGe/bRBaFUocOmuyfcmZoRdi0qzAskmycJsj/w6vWR4x6MYkmJvSeI/MGxjEFt4s2MfOG1tP8CBLUYft9qUleeJa7Jln8c+xbnqB7YngaI190icQHE9NuIB2CXvzbmo3tLtHNMagEwI7VoBDj6mxzTxBd9JhuhF4w5uGxxm0Gp1hzk+15obNnaBS+Anr7jXz8FPwwxCH+XhBZxB1PPpcIayKrf9iLyGtwmhkdDoWCqYAr1mue3LxFso+TZF4bwE4Cjt1 agrabelh@agrabelh"] | ||
art: | ||
login: art | ||
comment: Arturo Filasto | ||
keys: ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJsibU0nsQFFIdolD1POzXOws4VetV0ZNByINRzY8Hx0 [email protected]"] | ||
majakomel: | ||
login: majakomel | ||
comment: Maja Komel | ||
keys: | ||
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC7gWQL4h/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PRULFtn6C7aA7ddirck+k=" | ||
|
||
admin_usernames: [ art, majakomel, mehul ] | ||
non_admin_usernames: [ agrabeli ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
- name: create admin users | ||
tags: ssh_users | ||
user: | ||
name: "{{ item }}" | ||
group: "admin" | ||
comment: "{{ ssh_users[item].comment }}" | ||
shell: /bin/bash | ||
state: present | ||
with_items: "{{ admin_usernames }}" | ||
|
||
- name: create non-admin users | ||
tags: ssh_users | ||
user: | ||
name: "{{ item }}" | ||
group: "{{ item }}" | ||
comment: "{{ ssh_users[item].comment }}" | ||
shell: /bin/bash | ||
state: present | ||
with_items: "{{ non_admin_usernames }}" | ||
|
||
- name: create .ssh dir in user homes | ||
tags: ssh_users | ||
file: path=/home/{{item}}/.ssh state=directory owner={{item}} group={{item}} mode=0700 | ||
with_items: "{{ admin_usernames | union(non_admin_usernames) }}" | ||
|
||
- name: create .ssh/authorized_keys for each user | ||
tags: ssh_users | ||
template: src=authorized_keys dest=/home/{{item}}/.ssh/authorized_keys owner={{item}} group={{item}} mode=0400 | ||
with_items: "{{ admin_usernames | union(non_admin_usernames) }}" | ||
|
||
- name: list all users currently on the system | ||
shell: "getent passwd | awk -F: '$3 > 1000 {print $1}'" | ||
register: user_list | ||
|
||
- name: remove any stale users | ||
user: | ||
name: "{{ item }}" | ||
state: "absent" | ||
remove: "yes" | ||
with_items: user_list.stdout_lines | ||
when: "item is not nobody and item not in admin_usernames | union(non_admin_usernames)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# managed by ansible | ||
# see roles/adm/templates/authorized_keys | ||
{% for k in passwd[item]['keys'] %} | ||
{{ k }} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# ansible-managed in ooni-sysadmin.git | ||
{% for login in adm_logins %} | ||
{% for k in passwd[login]['keys'] %} | ||
{{ k }} | ||
{% endfor %} | ||
{% endfor %} |