Logfile creation

This commit is contained in:
Raphael Werner 2025-04-28 22:24:23 +02:00
parent dbb6b97f40
commit 4b5e6baf0b
2 changed files with 17 additions and 4 deletions

View file

@ -1,8 +1,21 @@
---
- hosts: localhost
- name: "Playbook for my various machines"
hosts: localhost
connection: local
force_handlers: true
vars:
log_path: "/var/log/ansible/{{ ansible_date_time.iso8601_basic_short }}.log"
pre_tasks:
- name: "Create Logfile"
block:
- name: "Create File"
ansible.builtin.file:
path: "{{ log_path }}"
state: touch
mode: '0644'
roles:
- name: fedora
when: ansible_distribution == 'Fedora'

View file

@ -43,7 +43,7 @@
rescue:
- name: "Log errors"
ansible.builtin.lineinfile:
dest: /tmp/ansible.log
dest: "{{ log_path }}"
line: >-
[ERR] {{ item }}
with_items: "{{ dnf_install_errors.failures }}"