Skip to content

Commit

Permalink
Don't create an OS user if they have no ssh key.
Browse files Browse the repository at this point in the history
  • Loading branch information
enasca committed Oct 19, 2023
1 parent 2981994 commit 4fd5082
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions ansible/playbooks/single_user_management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# last_name: User
# email: "[email protected]"
# login_shell: "/bin/bash" (optional)
#
#
# Alternatively if you are creating a project / group:
# ansible-playbook -i <path to inventory> user_management.yml -e "@groupdata.yml"
# example contents of the file groupdata.yml:
Expand Down Expand Up @@ -117,7 +117,9 @@
suffix: ".userdata"
state: file
register: usermgmt_tempfile
when: username is defined
when:
- username is defined
- ssh_public_key is defined
- name: Populate the tempfile
vars:
user_list:
Expand All @@ -133,13 +135,14 @@
- usermgmt_tempfile.path is defined
- name: Create the user on the bastion host
ansible.builtin.command:
argv:
argv:
- sudo
- /root/bin/ikimuseradd.sh
- "{{ usermgmt_tempfile.path }}"
creates: "/home/{{ username }}"
when:
- username is defined
- ssh_public_key is defined
- usermgmt_tempfile.path is defined
- name: Delete the temp file
ansible.builtin.file:
Expand All @@ -157,15 +160,17 @@
- /opt/user_scripts/create_user_home.sh
- "{{ username }}"
creates: "/dpool/share/homes/{{ username }}"
when: username is defined
when:
- username is defined
- ssh_public_key is defined
- name: Create the project directory
ansible.builtin.command:
argv:
- sudo
- /opt/user_scripts/create_new_project.sh
- "{{ groupname }}"
creates: "/dpool/share/projects/{{ groupname }}"
when:
when:
- groupname is defined
- is_project
- name: Create the group directory
Expand All @@ -175,8 +180,8 @@
- /opt/user_scripts/create_new_group.sh
- "{{ groupname }}"
creates: "/dpool/share/groups/{{ groupname }}"
when:
- groupname is defined
when:
- groupname is defined
- not is_project

- hosts: slurm_user_facing
Expand All @@ -197,7 +202,9 @@
failed_when:
- sacctmgr_result['rc'] != 0
- not (sacctmgr_result['stdout'] | regex_search('Nothing new added'))
when: username is defined
when:
- username is defined
- ssh_public_key is defined
- name: Modify the Slurm Admin level of the user
become: true
ansible.builtin.command:
Expand Down

0 comments on commit 4fd5082

Please sign in to comment.