diff --git a/eval.sh b/eval.sh index 117e517..0949312 100644 --- a/eval.sh +++ b/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 diff --git a/eval.yml b/eval.yml index 3f04179..b25bd3e 100644 --- a/eval.yml +++ b/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 diff --git a/functions.sh b/functions.sh index 9726ce3..0ab7c6b 100644 --- a/functions.sh +++ b/functions.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