mise au point
This commit is contained in:
5
eval.sh
5
eval.sh
@@ -5,12 +5,11 @@ set -u
|
|||||||
source /root/functions.sh
|
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
|
userExists operateur
|
||||||
userHasPassword operateur
|
userHasPassword operateur
|
||||||
|
fileMustExist /etc/sudoers.d/operateur
|
||||||
fileMustContain ~operateur/.ssh/authorized_keys tom@workine
|
fileMustContain ~operateur/.ssh/authorized_keys tom@workine
|
||||||
fileMustExist /etc/sudoers/operateur
|
|
||||||
fileMustExist /var/log/operateur.log
|
fileMustExist /var/log/operateur.log
|
||||||
fileMustExist /etc/logrotate.d/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"
|
result_file: "{{ '%Y-%m-%d' | strftime }}_tp.csv"
|
||||||
script: eval.sh
|
script: eval.sh
|
||||||
|
|
||||||
pre_tasks:
|
# pre_tasks:
|
||||||
- name: insert header
|
# - name: insert header
|
||||||
lineinfile:
|
# lineinfile:
|
||||||
path: "{{ result_file }}"
|
# path: "{{ result_file }}"
|
||||||
line: "machine\tuser\tdir bin\tscript exists\tif\tmysqldump\texit\targ0\targ1\targ2\trc\tdate\texecOk\ttaille"
|
# line: "machine\tuser\tdir bin\tscript exists\tif\tmysqldump\texit\targ0\targ1\targ2\trc\tdate\texecOk\ttaille"
|
||||||
state: present
|
# state: present
|
||||||
create: true
|
# create: true
|
||||||
delegate_to: localhost
|
# delegate_to: localhost
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: copy script
|
- name: copy script
|
||||||
@@ -25,11 +25,7 @@
|
|||||||
mode: 0700
|
mode: 0700
|
||||||
loop:
|
loop:
|
||||||
- "{{ script }}"
|
- "{{ script }}"
|
||||||
|
- "functions.sh"
|
||||||
- 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
|
|
||||||
|
|
||||||
- name: exec script
|
- name: exec script
|
||||||
command: /root/eval.sh
|
command: /root/eval.sh
|
||||||
|
|||||||
@@ -117,9 +117,10 @@ function fileMustNOTContain {
|
|||||||
# insert hostname at beginning of result line
|
# insert hostname at beginning of result line
|
||||||
function addHeader {
|
function addHeader {
|
||||||
test -f /etc/motd && user="$(cat /etc/motd | sed 's/\n//')\t"
|
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"
|
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
|
# Ok if given user exists
|
||||||
@@ -131,7 +132,7 @@ function userExists {
|
|||||||
# Ok if given use has a password
|
# Ok if given use has a password
|
||||||
# arg1: user to check
|
# arg1: user to check
|
||||||
function userHasPassword {
|
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
|
# Ok if given package is installed
|
||||||
# arg1: pkg to check
|
# arg1: pkg to check
|
||||||
|
|||||||
Reference in New Issue
Block a user