Move ansible section to its function

This commit is contained in:
Blade of Darkness 2021-01-03 15:11:18 +01:00
parent 35cc77bca6
commit 35cff1a7b9
2 changed files with 29 additions and 24 deletions

View File

@ -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

View File

@ -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
;;