Skip to content

Commit cd398b2

Browse files
committed
ipaserver: Don't run ipa-server-install if packages are not installed
When running ipaserver role with 'state: absent' and packages are not installed, uninstallation fails trying to execute 'ipa-server-install --uninstall' as the command is not available. As user is user is trying to remove a server that does not exist, no error should be raised, as the state is already satisfied. Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
1 parent 89cfb5f commit cd398b2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

roles/ipaserver/tasks/uninstall.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
when: ipaserver_remove_on_server is defined or
4343
result_get_connected_server.server is defined
4444

45+
- name: Unnstall - Check if IPA server packages are installed
46+
ansible.builtin.package:
47+
name: "{{ ipaserver_packages }}"
48+
state: present
49+
check_mode: true
50+
register: ipapackages_available
51+
4552
- name: Uninstall - Uninstall IPA server
4653
ansible.builtin.command: >
4754
/usr/sbin/ipa-server-install
@@ -54,3 +61,4 @@
5461
# 1 means that uninstall failed because IPA server was not configured
5562
failed_when: uninstall.rc != 0 and uninstall.rc != 1
5663
changed_when: uninstall.rc == 0
64+
when: not ipapackages_available.changed

0 commit comments

Comments
 (0)