Logfile creation
This commit is contained in:
parent
dbb6b97f40
commit
4b5e6baf0b
2 changed files with 17 additions and 4 deletions
17
local.yml
17
local.yml
|
|
@ -1,11 +1,24 @@
|
||||||
---
|
---
|
||||||
- hosts: localhost
|
- name: "Playbook for my various machines"
|
||||||
|
hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
force_handlers: true
|
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:
|
roles:
|
||||||
- name: fedora
|
- name: fedora
|
||||||
when: ansible_distribution == 'Fedora'
|
when: ansible_distribution == 'Fedora'
|
||||||
- name: gnome
|
- name: gnome
|
||||||
when: ansible_env.DESKTOP_SESSION == 'gnome'
|
when: ansible_env.DESKTOP_SESSION == 'gnome'
|
||||||
- name: dotfiles
|
- name: dotfiles
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
msg: "rpmfusion Repos konnten nicht hinzugefügt werden."
|
msg: "rpmfusion Repos konnten nicht hinzugefügt werden."
|
||||||
|
|
||||||
- name: "Remove and install dnf software"
|
- name: "Remove and install dnf software"
|
||||||
become: true
|
become: true
|
||||||
block:
|
block:
|
||||||
- name: "Remove unnecassary packages"
|
- name: "Remove unnecassary packages"
|
||||||
ansible.builtin.dnf:
|
ansible.builtin.dnf:
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
rescue:
|
rescue:
|
||||||
- name: "Log errors"
|
- name: "Log errors"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
dest: /tmp/ansible.log
|
dest: "{{ log_path }}"
|
||||||
line: >-
|
line: >-
|
||||||
[ERR] {{ item }}
|
[ERR] {{ item }}
|
||||||
with_items: "{{ dnf_install_errors.failures }}"
|
with_items: "{{ dnf_install_errors.failures }}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue