From f8b791bbd2f91ffa1c2edb81e75fc43918b9a6c4 Mon Sep 17 00:00:00 2001 From: Chad Date: Sun, 25 Jun 2023 13:18:44 -0700 Subject: [PATCH] Fix Sudo On OpenSUSE (#39) --- facts/general/system.yml | 1 + tasks/general/acct_mgmt/sudo.yml | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/facts/general/system.yml b/facts/general/system.yml index d11ab18..248eb6a 100644 --- a/facts/general/system.yml +++ b/facts/general/system.yml @@ -25,6 +25,7 @@ set_fact: rc_conf: /dev/null sudoers_install_dir: /etc/sudoers.d/ + sudoers_config: /etc/sudoers shutdown_command: sudo shutdown -h now when: ansible_system == "Linux" diff --git a/tasks/general/acct_mgmt/sudo.yml b/tasks/general/acct_mgmt/sudo.yml index f6bdbcf..3415d30 100644 --- a/tasks/general/acct_mgmt/sudo.yml +++ b/tasks/general/acct_mgmt/sudo.yml @@ -16,3 +16,18 @@ owner: root group: "{{ root_group }}" mode: 0440 + +# Disable these two lines in openSUSE default configuration. +#Defaults targetpw # ask for the password of the target user i.e. root +#ALL ALL=(ALL) ALL # WARNING! Only use this together with 'Defaults targetpw'! +- name: General | Account Management | Sudo | Disable openSUSE Root PW Prompt + lineinfile: + path: "{{ sudoers_config }}" + regexp: '{{ item.key }}' + line: '{{ item.value }} # MANAGED BY ANSIBLE' + state: present + create: yes + backup: yes + loop: + - { "key": '^[\#]?Defaults targetpw', "value": '#Defaults targetpw'} + - { "key": '^[\#]?ALL ALL\=\(ALL\) ALL', "value": '#ALL ALL=(ALL) ALL'}