From 8eede3226b65dde289c21c9b2203d96a406a5a07 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 28 Dec 2020 20:06:41 -0600 Subject: [PATCH] Try to use set_fact for package names. --- facts/package_name.yml | 22 ++++++++++++++++++++++ local.yml | 10 +++++++++- tasks/flatpaks.yml | 4 ++-- vars/package_names.yml | 14 -------------- 4 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 facts/package_name.yml delete mode 100644 vars/package_names.yml diff --git a/facts/package_name.yml b/facts/package_name.yml new file mode 100644 index 0000000..4dc7b9f --- /dev/null +++ b/facts/package_name.yml @@ -0,0 +1,22 @@ +--- +# Define what the program name is on each OS so we can use package builtin. like this: + +- name: Set Pop!_OS Package Names + ansible.builtin.set_fact: + package_name.firefox: firefox + package_name.thunderbird: thunderbird + when: ansible_distribution == "Pop!OS" + + +- name: Set Ubuntu Package Names + ansible.builtin.set_fact: + package_name.firefox: firefox + package_name.thunderbird: thunderbird + when: ansible_distribution == "Ubuntu" + + +- name: Set FreeBSD Package Names + ansible.builtin.set_fact: + package_name.firefox: firefox + package_name.thunderbird: thunderbird + when: ansible_distribution == "FreeBSD" \ No newline at end of file diff --git a/local.yml b/local.yml index ad95019..e4d994b 100644 --- a/local.yml +++ b/local.yml @@ -1,16 +1,24 @@ --- # Harmonize my systems rather than doing everything manually. :) +# Everything - hosts: all connection: local - become: true + become: true + + pre_tasks: + - include: facts/package_name.yml + tasks: - include: tasks/users.yml - include: tasks/cron.yml - include: tasks/packages.yml - include: tasks/harden.yml + +# Desktops and laptops - hosts: workstation become: true + tasks: - include: tasks/flatpaks.yml diff --git a/tasks/flatpaks.yml b/tasks/flatpaks.yml index e392c78..7e17479 100644 --- a/tasks/flatpaks.yml +++ b/tasks/flatpaks.yml @@ -13,8 +13,8 @@ - name: Remove packages that may come with an OS but are being installed as Flatpak package: name: - - {{ firefox[ansible_distribution] }} - - {{ thunderbird[ansible_distribution] }} + - {{ package_name.firefox }} + - {{ package_name.thunderbird }} state: absent - name: Install Discord diff --git a/vars/package_names.yml b/vars/package_names.yml deleted file mode 100644 index 2d21b95..0000000 --- a/vars/package_names.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -# Define what the program name is on each OS so we can use package builtin. like this: - -# POP!_OS -firefox["Pop!_OS"]: firefox -thunderbird["Pop!_OS"]: thunderbird - -# Ubuntu -firefox["Ubuntu"]: firefox -thunderbird["Ubuntu"]: thunderbird - -# FreeBSD -firefox["FreeBSD"]: firefox -thunderbird["FreeBSD"]: thunderbird \ No newline at end of file