Authored by BuddyJack

fix

- hosts: '{{module}}'
tasks:
- name: clear /etc/rsyslog.d
command: rm -rf /etc/rsyslog.d
- name: mkdir /etc/rsyslog.d
command: mkdir -p /etc/rsyslog.d
- name: cp rsyslog.conf to dest host
copy:
src: '{{src_path}}/log-centralization/client/etc/rsyslog.conf'
dest: /etc/
backup: yes
- name: cp rsyslog.d/module.conf to dest host
copy:
src: '{{src_path}}/log-centralization/client/etc/rsyslog.d/{{module}}.conf'
dest: /etc/rsyslog.d/
- name: restart rsyslog
command: service rsyslog restart
... ...
#! /bin/bash
#source /home/master/ansible/ansible/hacking/env-setup
work_path=$(dirname $(readlink -f $0))
module=''
inventory=${work_path}/hosts
ssh_key=''
user=''
usage(){
echo " sh rsyslog_install.sh -m module -i hosts -u user -s private_key
this command will install rsyslog on module in hosts , ssh hosts with user and private_key
"
}
install(){
ansible-playbook -i ${inventory} -u ${user} --private-key ${ssh_key} -s --extra-vars "src_path=${work_path} module=${module}" rsyslog.yaml
exit 0
}
while [ $# -gt 0 ];do
case $1 in
-m)
shift
module=$1
shift
;;
-i)
shift
inventory=$1
shift
;;
-s)
shift
ssh_key=$1
shift
;;
-u)
shift
user=$1
shift
;;
-h)
usage
exit 0
;;
\?)
usage
exit 1
;;
esac
done
install
... ...