diff --git a/README-host.md b/README-host.md
index 56c92bdaa92899a40e16db6adf243156c3ac10f9..ba274c98c3e433c9d3a40bb69d17bdaad92d94c1 100644
--- a/README-host.md
+++ b/README-host.md
@@ -320,6 +320,7 @@ Variable | Description | Required
 -------- | ----------- | --------
 `ipaadmin_principal` | The admin principal is a string and defaults to `admin` | no
 `ipaadmin_password` | The admin password is a string and is required if there is no admin ticket available on the node | no
+`ipaapi_context` | The context in which the module will execute. Executing in a server context is preferred. If not provided context will be determined by the execution environment. Valid values are `server` and `client`. | no
 `name` \| `fqdn` | The list of host name strings. `name` with *host variables* or `hosts` containing *host variables* need to be used. | no
 **Host variables** | Only used with `name` variable in the first level. | no
 `hosts` | The list of host dicts. Each `hosts` dict entry can contain **host variables**.<br>There is one required option in the `hosts` dict:| no
diff --git a/tests/host/test_host.yml b/tests/host/test_host.yml
index 3b186525a2c86d34db2e0be28bfb7f6421074227..bee85ef74948d859bbe1ae60cb048b2a8a40a9b1 100644
--- a/tests/host/test_host.yml
+++ b/tests/host/test_host.yml
@@ -1,6 +1,6 @@
 ---
 - name: Test host
-  hosts: ipaserver
+  hosts: "{{ ipa_test_host | default('ipaserver') }}"
   become: true
 
   tasks:
@@ -21,6 +21,7 @@
   - name: Host absent
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name:
       - "{{ host1_fqdn }}"
       - "{{ host2_fqdn }}"
@@ -39,6 +40,7 @@
   - name: Host "{{ host1_fqdn }}" present
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host1_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.201' }}"
       update_dns: yes
@@ -49,6 +51,7 @@
   - name: Host "{{ host1_fqdn }}" present again
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host1_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.201' }}"
       update_dns: yes
@@ -59,6 +62,7 @@
   - name: Host "{{ host2_fqdn }}" present
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host2_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.202' }}"
       update_dns: yes
@@ -69,6 +73,7 @@
   - name: Host "{{ host2_fqdn }}" present again
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host2_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.202' }}"
       update_dns: yes
@@ -79,6 +84,7 @@
   - name: Host "{{ host3_fqdn }}" present
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host3_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.203' }}"
       update_dns: yes
@@ -89,6 +95,7 @@
   - name: Host "{{ host3_fqdn }}" present again
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host3_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.203' }}"
       update_dns: yes
@@ -99,6 +106,7 @@
   - name: Host "{{ host4_fqdn }}" present
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host4_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.204' }}"
       update_dns: yes
@@ -109,6 +117,7 @@
   - name: Host "{{ host4_fqdn }}" present again
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host4_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.204' }}"
       update_dns: yes
@@ -119,6 +128,7 @@
   - name: Host "{{ host5_fqdn }}" present
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host5_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.205' }}"
       update_dns: yes
@@ -129,6 +139,7 @@
   - name: Host "{{ host5_fqdn }}" present again
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host5_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.205' }}"
       update_dns: yes
@@ -139,6 +150,7 @@
   - name: Host "{{ host6_fqdn }}" present
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host6_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.206' }}"
       update_dns: yes
@@ -149,6 +161,7 @@
   - name: Host "{{ host6_fqdn }}" present again
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: "{{ host6_fqdn }}"
       ip_address: "{{ ipv4_prefix + '.206' }}"
       update_dns: yes
@@ -161,6 +174,7 @@
   #- name: Hosts host1..host6 disabled
   #  ipahost:
   #    ipaadmin_password: SomeADMINpassword
+  #    ipaapi_context: "{{ ipa_context | default(omit) }}"
   #    name:
   #    - "{{ host1_fqdn }}"
   #    - "{{ host2_fqdn }}"
@@ -175,6 +189,7 @@
   #- name: Hosts host1..host6 disabled again
   #  ipahost:
   #    ipaadmin_password: SomeADMINpassword
+  #    ipaapi_context: "{{ ipa_context | default(omit) }}"
   #    name:
   #    - "{{ host1_fqdn }}"
   #    - "{{ host2_fqdn }}"
@@ -189,6 +204,7 @@
   - name: Hosts host1..host6 absent
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name:
       - "{{ host1_fqdn }}"
       - "{{ host2_fqdn }}"
@@ -204,6 +220,7 @@
   - name: Hosts host1..host6 absent again
     ipahost:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name:
       - "{{ host1_fqdn }}"
       - "{{ host2_fqdn }}"
@@ -215,4 +232,3 @@
       state: absent
     register: result
     failed_when: result.changed or result.failed
-
diff --git a/tests/host/test_host_client_context.yml b/tests/host/test_host_client_context.yml
new file mode 100644
index 0000000000000000000000000000000000000000..ba3074015896101ac9b7a41148b31f11bffbd397
--- /dev/null
+++ b/tests/host/test_host_client_context.yml
@@ -0,0 +1,37 @@
+---
+- name: Test host
+  hosts: ipaclients, ipaserver
+  become: no
+  gather_facts: no
+
+  tasks:
+  - name: Include FreeIPA facts.
+    include_tasks: ../env_freeipa_facts.yml
+
+  # Test will only be executed if host is not a server.
+  - name: Execute with server context in the client.
+    ipahost:
+      ipaadmin_password: SomeADMINpassword
+      ipaapi_context: server
+      name: ThisShouldNotWork
+    register: result
+    failed_when: not (result.failed and result.msg is regex("No module named '*ipaserver'*"))
+    when: ipa_host_is_client
+
+# Import basic module tests, and execute with ipa_context set to 'client'.
+# If ipaclients is set, it will be executed using the client, if not,
+# ipaserver will be used.
+#
+# With this setup, tests can be executed against an IPA client, against
+# an IPA server using "client" context, and ensure that tests are executed
+# in upstream CI.
+
+- name: Test automember using client context, in client host.
+  import_playbook: test_host.yml
+  when: groups['ipaclients']
+  vars:
+    ipa_test_host: ipaclients
+
+- name: Test automember using client context, in server host.
+  import_playbook: test_host.yml
+  when: groups['ipaclients'] is not defined or not groups['ipaclients']