From 58168b200c891b2f94d2ec8281093348f3e26943 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Sun, 23 Sep 2018 17:37:15 +0200 Subject: fedora: dnf: make even more attribute driven --- roles/fedora/tasks/dnf.yml | 50 +++++++++++++++--------------------- roles/space_server/defaults/main.yml | 39 +++++++++++++++------------- 2 files changed, 42 insertions(+), 47 deletions(-) diff --git a/roles/fedora/tasks/dnf.yml b/roles/fedora/tasks/dnf.yml index a0c0db9..cc28e97 100644 --- a/roles/fedora/tasks/dnf.yml +++ b/roles/fedora/tasks/dnf.yml @@ -1,46 +1,38 @@ --- - name: Configure dnf.conf ini_file: - path: /etc/dnf/dnf.conf + path: '/etc/dnf/dnf.conf' no_extra_spaces: yes - section: '{{ item.section }}' - option: '{{ item.option }}' - value: '{{ item.value }}' - with_items: - - section: main - option: 'install_weak_deps' - value: 'False' - - section: main - option: 'best' - value: 'True' - - section: main - option: 'deltarpm' - value: 'False' - -- name: Update all packages - dnf: - name: '*' - state: latest - tags: - - update - - packages + create: no + section: "{{ item.key.split('.',1)[0] }}" + option: "{{ item.key.split('.',1)[1] }}" + value: "{{ item.value|ternary(item.value,omit) }}" + state: "{{ item.value|ternary('present','absent') }}" + with_dict: '{{ dnf_conf }}' - name: Remove packages dnf: name: '{{ item }}' state: absent - with_items: '{{ packages.remove }}' - when: "'remove' in packages" + with_items: "{{ dnf_packages|dictsort(true)|selectattr(1,'equalto','absent')|map(attribute=0)|list }}" + tags: - - packages + - packages + +- name: Update all packages + dnf: + name: '*' + state: latest + tags: + - update + - packages - name: Install packages dnf: name: '{{ item }}' - state: latest - with_items: '{{ packages.install }}' - when: "'install' in packages" + state: present + with_items: "{{ dnf_packages|dictsort(true)|selectattr(1,'equalto','present')|map(attribute=0)|list }}" tags: - - packages + - packages # vim: set ts=2 sw=2 et: diff --git a/roles/space_server/defaults/main.yml b/roles/space_server/defaults/main.yml index 6d6f12d..121a927 100644 --- a/roles/space_server/defaults/main.yml +++ b/roles/space_server/defaults/main.yml @@ -5,24 +5,27 @@ locale: LC_COLLATE: 'C' LC_MESSAGES: 'C' timezone: 'Europe/Copenhagen' -packages: - install: - - initscripts - - dosfstools - - btrfs-progs - - dnf - - python2-dnf - - 'dnf-command(leaves)' - - ansible - - python-netaddr - - vim-enhanced - - git - - diffutils - - htop - - man-db - - passwd - - syslinux - - systemd-container +dnf_conf: + 'main.install_weak_deps': 'False' + 'main.best': 'True' + 'main.deltarpm': 'False' +dnf_packages: + 'initscripts': present + 'dosfstools': present + 'btrfs-progs': present + 'dnf': present + 'python2-dnf': present + 'dnf-command(leaves)': present + 'ansible': present + 'python-netaddr': present + 'vim-enhanced': present + 'git': present + 'diffutils': present + 'htop': present + 'man-db': present + 'passwd': present + 'syslinux': present + 'systemd-container': present boot: device: 'LABEL=BOOT' options: 'noauto,noatime,iocharset=iso8859-15,utf8,tz=UTC,dmask=0022,fmask=0133,x-systemd.automount,x-systemd.device-timeout=5min,x-systemd.idle-timeout=5min' -- cgit v1.2.1