mise au point
This commit is contained in:
5
eval.sh
5
eval.sh
@@ -5,12 +5,11 @@ set -u
|
||||
source /root/functions.sh
|
||||
|
||||
|
||||
addHeader
|
||||
addHeader "user_operateur" "pass_operateur" "sudo_config" "ssh_key_tom" "log_operateur" "logrotate"
|
||||
|
||||
fileMustExist /etc/sudoers.d/operateur
|
||||
userExists operateur
|
||||
userHasPassword operateur
|
||||
fileMustExist /etc/sudoers.d/operateur
|
||||
fileMustContain ~operateur/.ssh/authorized_keys tom@workine
|
||||
fileMustExist /etc/sudoers/operateur
|
||||
fileMustExist /var/log/operateur.log
|
||||
fileMustExist /etc/logrotate.d/operateur.log
|
||||
|
||||
22
eval.yml
22
eval.yml
@@ -8,14 +8,14 @@
|
||||
result_file: "{{ '%Y-%m-%d' | strftime }}_tp.csv"
|
||||
script: eval.sh
|
||||
|
||||
pre_tasks:
|
||||
- name: insert header
|
||||
lineinfile:
|
||||
path: "{{ result_file }}"
|
||||
line: "machine\tuser\tdir bin\tscript exists\tif\tmysqldump\texit\targ0\targ1\targ2\trc\tdate\texecOk\ttaille"
|
||||
state: present
|
||||
create: true
|
||||
delegate_to: localhost
|
||||
# pre_tasks:
|
||||
# - name: insert header
|
||||
# lineinfile:
|
||||
# path: "{{ result_file }}"
|
||||
# line: "machine\tuser\tdir bin\tscript exists\tif\tmysqldump\texit\targ0\targ1\targ2\trc\tdate\texecOk\ttaille"
|
||||
# state: present
|
||||
# create: true
|
||||
# delegate_to: localhost
|
||||
|
||||
tasks:
|
||||
- name: copy script
|
||||
@@ -25,11 +25,7 @@
|
||||
mode: 0700
|
||||
loop:
|
||||
- "{{ script }}"
|
||||
|
||||
- name: get latest version of functions.sh
|
||||
git:
|
||||
repo: ssh://infra.opendoor.fr:2222/srv/git/repos/tom/eval_functions.git
|
||||
dest: root/eval_functions.git
|
||||
- "functions.sh"
|
||||
|
||||
- name: exec script
|
||||
command: /root/eval.sh
|
||||
|
||||
@@ -117,9 +117,10 @@ function fileMustNOTContain {
|
||||
# insert hostname at beginning of result line
|
||||
function addHeader {
|
||||
test -f /etc/motd && user="$(cat /etc/motd | sed 's/\n//')\t"
|
||||
echo -ne "${user}$(hostname -s)\t"
|
||||
for i in $@ ; do echo -ne "$i\t" ; done
|
||||
echo -ne "\n\t\t"
|
||||
for i in $@ ; do echo -ne "$i\t" ; done
|
||||
echo -ne "\n"
|
||||
echo -ne "${user}$(hostname -s)\t"
|
||||
}
|
||||
|
||||
# Ok if given user exists
|
||||
@@ -131,7 +132,7 @@ function userExists {
|
||||
# Ok if given use has a password
|
||||
# arg1: user to check
|
||||
function userHasPassword {
|
||||
if ( passwd --status $1 2>&1 | grep -q 'Password Set' ) ; then e 1 ; else e 0 ; fi
|
||||
if ( passwd --status $1 2>&1 | grep -q 'Password set' ) ; then e 1 ; else e 0 ; fi
|
||||
}
|
||||
# Ok if given package is installed
|
||||
# arg1: pkg to check
|
||||
|
||||
Reference in New Issue
Block a user