diff --git a/changelogs/fragments/73840_apt-policy-rc-d.yml b/changelogs/fragments/73840_apt-policy-rc-d.yml new file mode 100644 index 00000000000..4c260ce8c11 --- /dev/null +++ b/changelogs/fragments/73840_apt-policy-rc-d.yml @@ -0,0 +1,4 @@ +bugfixes: + - >- + apt - fix policy_rc_d parameter throwing an exception when restoring + original file (https://github.com/ansible/ansible/issues/66211) diff --git a/lib/ansible/modules/apt.py b/lib/ansible/modules/apt.py index 0300d866c31..d6b038acc63 100644 --- a/lib/ansible/modules/apt.py +++ b/lib/ansible/modules/apt.py @@ -428,7 +428,7 @@ class PolicyRcD(object): try: shutil.move(os.path.join(self.backup_dir, 'policy-rc.d'), '/usr/sbin/policy-rc.d') - os.rmdir(self.tmpdir_name) + os.rmdir(self.backup_dir) except Exception: self.m.fail_json(msg="Fail to move back %s to /usr/sbin/policy-rc.d" % os.path.join(self.backup_dir, 'policy-rc.d'))