From 35cff1a7b95d22df81cbc107413cd060ff858d26 Mon Sep 17 00:00:00 2001 From: Naglfar Date: Sun, 3 Jan 2021 15:11:18 +0100 Subject: [PATCH] Move ansible section to its function --- include/functions | 28 ++++++++++++++++++++++++++++ makeuser | 25 +------------------------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/include/functions b/include/functions index f468841..cc33a70 100644 --- a/include/functions +++ b/include/functions @@ -34,6 +34,34 @@ makeuser_no_ansible() #sudo toot "welcome new user ~$1!" } +makeuser_ansible() +{ + currdir=`pwd` + cd $REPO_LOCATION; git pull + echo "--- +- name: Setting up $1 + user: + name: $1 + groups: tilde + state: present + skeleton: /etc/skel + shell: /bin/bash + system: no + createhome: yes + home: /home/$1 +- authorized_key: + user: $1 + state: present + key: \"$3\"" > $REPO_LOCATION/roles/shell/tasks/users/$YAML_FILE + + echo "- include: users/$YAML_FILE" >> $REPO_LOCATION/roles/shell/tasks/users.yml + git add $REPO_LOCATION/roles/shell/tasks/users/$YAML_FILE + git commit -am "Adding user $1" + git push + cd $currdir + $GEN_TDP | sudo tee $TILDE_JSON +} + add_account_recovery() { sudo mkdir -p --mode=700 /home/$1/.thunix diff --git a/makeuser b/makeuser index f7dc00f..5e6f7ac 100755 --- a/makeuser +++ b/makeuser @@ -30,30 +30,7 @@ case $1 in add_account_recovery $1 $2 #Thunix specific section - currdir=`pwd` - cd $REPO_LOCATION; git pull - echo "--- -- name: Setting up $1 - user: - name: $1 - groups: tilde - state: present - skeleton: /etc/skel - shell: /bin/bash - system: no - createhome: yes - home: /home/$1 -- authorized_key: - user: $1 - state: present - key: \"$3\"" > $REPO_LOCATION/roles/shell/tasks/users/$YAML_FILE - - echo "- include: users/$YAML_FILE" >> $REPO_LOCATION/roles/shell/tasks/users.yml - git add $REPO_LOCATION/roles/shell/tasks/users/$YAML_FILE - git commit -am "Adding user $1" - git push - cd $currdir - $GEN_TDP | sudo tee $TILDE_JSON + makeuser_ansible $1 $2 # End Thunix specific section ;;