diff --git a/README-location.md b/README-location.md
index 3e9b7ef161ffb0e3080bc03bad92816edc8d55ab..203ba254ed9988655e06ca5bdca5ab88898ef8cc 100644
--- a/README-location.md
+++ b/README-location.md
@@ -81,6 +81,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` \| `idnsname` | The list of location name strings. | yes
 `description` | The IPA location string | false
 `state` | The state to ensure. It can be one of `present`, `absent`, default: `present`. | no
diff --git a/tests/location/test_location.yml b/tests/location/test_location.yml
index 10aed32fda68072b754e2226ad1d04584d593bd5..3cda4115db7fd5c0d857565fc069cdbb18ba6e84 100644
--- a/tests/location/test_location.yml
+++ b/tests/location/test_location.yml
@@ -1,6 +1,6 @@
 ---
 - name: Test location
-  hosts: ipaserver
+  hosts: "{{ ipa_test_host | default('ipaserver') }}"
   become: true
 
   tasks:
@@ -10,6 +10,7 @@
   - name: Ensure location my_location1 is absent
     ipalocation:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: my_location1
       state: absent
 
@@ -20,6 +21,7 @@
   - name: Ensure location my_location1 is present
     ipalocation:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: my_location1
     register: result
     failed_when: not result.changed or result.failed
@@ -27,6 +29,7 @@
   - name: Ensure location my_location1 is present again
     ipalocation:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: my_location1
     register: result
     failed_when: result.changed or result.failed
@@ -34,6 +37,7 @@
   - name: Ensure location my_location1 is present with description
     ipalocation:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: my_location1
       description: My Location 1
     register: result
@@ -42,6 +46,7 @@
   - name: Ensure location my_location1 is present again with description
     ipalocation:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: my_location1
       description: My Location 1
     register: result
@@ -50,6 +55,7 @@
   - name: Ensure location my_location1 is absent
     ipalocation:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: my_location1
       state: absent
     register: result
@@ -58,6 +64,7 @@
   - name: Ensure location my_location1 is absent again
     ipalocation:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: my_location1
       state: absent
     register: result
@@ -68,5 +75,6 @@
   - name: Ensure location my_location1 is absent
     ipalocation:
       ipaadmin_password: SomeADMINpassword
+      ipaapi_context: "{{ ipa_context | default(omit) }}"
       name: my_location1
       state: absent
diff --git a/tests/location/test_location_client_context.yml b/tests/location/test_location_client_context.yml
new file mode 100644
index 0000000000000000000000000000000000000000..00d5749f8938a3949573b8082265b72c086c7083
--- /dev/null
+++ b/tests/location/test_location_client_context.yml
@@ -0,0 +1,37 @@
+---
+- name: Test location
+  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.
+    ipalocation:
+      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 location using client context, in client host.
+  import_playbook: test_location.yml
+  when: groups['ipaclients']
+  vars:
+    ipa_test_host: ipaclients
+
+- name: Test location using client context, in server host.
+  import_playbook: test_location.yml
+  when: groups['ipaclients'] is not defined or not groups['ipaclients']