From 4e2b9ec5e2ea46968c5de54c6df954b30f3844c3 Mon Sep 17 00:00:00 2001 From: Andrew Steen Date: Wed, 17 Feb 2021 15:32:06 -0500 Subject: [PATCH] handle multiple os family vars in single file --- tasks/main.yml | 7 ------- tasks/vars.yml | 8 -------- vars/FreeBSD.yml | 4 ---- vars/OpenBSD.yml | 4 ---- vars/default.yml | 4 ---- vars/main.yml | 21 +++++++++++++++++++++ 6 files changed, 21 insertions(+), 27 deletions(-) delete mode 100644 tasks/vars.yml delete mode 100644 vars/FreeBSD.yml delete mode 100644 vars/OpenBSD.yml delete mode 100644 vars/default.yml create mode 100644 vars/main.yml diff --git a/tasks/main.yml b/tasks/main.yml index 64484c2..59f2f8f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,12 +1,5 @@ --- -- import_tasks: vars.yml - tags: - - system - - sudo - - vars - - sudo-vars - - import_tasks: install.yml tags: - system diff --git a/tasks/vars.yml b/tasks/vars.yml deleted file mode 100644 index b542808..0000000 --- a/tasks/vars.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: Including variables for distribution - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution }}.yml" - - "{{ ansible_os_family }}.yml" - - default.yml diff --git a/vars/FreeBSD.yml b/vars/FreeBSD.yml deleted file mode 100644 index 992eb5e..0000000 --- a/vars/FreeBSD.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -sudo_pkg_mgr_opts: '' -sudo_sudoers_group: wheel -sudo_visudo: '/usr/local/sbin/visudo' diff --git a/vars/OpenBSD.yml b/vars/OpenBSD.yml deleted file mode 100644 index 992eb5e..0000000 --- a/vars/OpenBSD.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -sudo_pkg_mgr_opts: '' -sudo_sudoers_group: wheel -sudo_visudo: '/usr/local/sbin/visudo' diff --git a/vars/default.yml b/vars/default.yml deleted file mode 100644 index 3f29509..0000000 --- a/vars/default.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -sudo_pkg_mgr_opts: update_cache=yes -sudo_sudoers_group: root -sudo_visudo: '/usr/sbin/visudo' diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..ff2e723 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,21 @@ +--- +_sudo_pkg_mgr_opts: + default: update_cache=yes + FreeBSD: '' + OpenBSD: '' + +sudo_pkg_mgr_opts: "{{ _sudo_pkg_mgr_opts[ansible_os_family] | default(_sudo_pkg_mgr_opts['default']) }}" + +_sudo_sudoers_group: + default: root + FreeBSD: wheel + OpenBSD: wheel + +sudo_sudoers_group: "{{ _sudo_sudoers_group[ansible_os_family] | default(_sudo_sudoers_group['default']) }}" + +_sudo_visudo: + default: '/usr/sbin/visudo' + FreeBSD: '/usr/local/sbin/visudo' + OpenBSD: '/usr/local/sbin/visudo' + +sudo_visudo: "{{ _sudo_visudo[ansible_os_family] | default(_sudo_visudo['default']) }}"