log fix, install.sh fix

This commit is contained in:
ROTTLER Tamas 2023-03-02 15:22:10 +01:00
parent ded6d274c6
commit 9b4abd2614
4 changed files with 14 additions and 16 deletions

View File

@ -11,8 +11,8 @@
- name: backup
ansible.builtin.command:
cmd: >
{{ routerbackup_bin }}/routerbackup --difflog --diffprint --logfile {{ routerbackup_log }}
--backupdir {{ routerbackup_dir }} --type {{ devtype }}
{{ routerbackup_bin }}/routerbackup --difflog --diffprint --noerrors
--logfile {{ routerbackup_log }} --backupdir {{ routerbackup_dir }} --type {{ devtype }}
--host {{ inventory_hostname }} --address {{ ansible_host }} --user {{ ansible_user }}
{% if ansible_private_key_file is defined %} --sshkey {{ ansible_private_key_file }}{% endif %}
{% if ansible_ssh_pass is defined %} --password {{ ansible_ssh_pass }}{% endif %}

View File

@ -6,19 +6,15 @@ function run() {
}
function createlink() {
if [[ ! -e $2 ]]; then
run ln -sr $1 $2
else
if [[ -h $2 ]]; then
run ln -sfr $1 $2
else
echo "WARNING: not overwriting $2: is not a symlink!"
fi
if [[ -e $2/$3 && ! -h $2/$3 ]]; then
echo "WARNING: not overwriting $2/$3: is not a symlink!"
return
fi
run ln -sfr $1 -t $2 $3
}
createlink routerbackup.yml /etc/ansible/routerbackup.yml
createlink ansible-role /etc/ansible/roles/routerbackup
createlink ansible-routerbackup /etc/ansible/bin/routerbackup
createlink routerbackup.yml /etc/ansible routerbackup.yml
createlink ansible-role /etc/ansible/roles routerbackup
createlink ansible-routerbackup-cron /etc/ansible/bin routerbackup-cron
# vim: set tabstop=4 shiftwidth=4 expandtab smarttab:

View File

@ -372,7 +372,10 @@ class AsaConfig(Config):
return False
def setup_logging(hostname, logfile, loglevel):
handler = logging.FileHandler(logfile, 'a')
if logfile:
handler = logging.FileHandler(logfile, 'a')
else:
handler = logging.StreamHandler()
fmt = logging.Formatter(
"{asctime} "+ hostname +"[{process}] {name}|{levelname} {message}",
style='{')
@ -390,8 +393,7 @@ def setup_logging(hostname, logfile, loglevel):
def main():
args = get_args()
if args.logfile:
setup_logging(args.host, args.logfile, args.loglevel)
setup_logging(args.host, args.logfile, args.loglevel)
try:
if args.type not in ('routeros', 'ios', 'asa'):
raise ValueError(f'Invalid devtype: {args.type}')