diff --git a/functions-common b/functions-common
index ceefd443b1..d36d323820 100644
--- a/functions-common
+++ b/functions-common
@@ -73,21 +73,23 @@ function save_stackenv {
 # - A `devstack-admin` entry for the `admin` user for the `admin` project.
 # write_clouds_yaml
 function write_clouds_yaml {
-    # The location is a variable to allow for easier refactoring later to make it
-    # overridable. There is currently no usecase where doing so makes sense, so
-    # it's not currently configurable.
-    for clouds_path in /etc/openstack ~/.config/openstack ; do
-        CLOUDS_YAML=$clouds_path/clouds.yaml
+    local clouds_yaml
 
-        sudo mkdir -p $(dirname $CLOUDS_YAML)
-        sudo chown -R $STACK_USER $(dirname $CLOUDS_YAML)
+    sudo mkdir -p /etc/openstack
+    sudo chown -R $STACK_USER /etc/openstack
+    # XXX: to be removed, see https://review.openstack.org/237149/
+    # careful not to sudo this, incase ~ is NFS mounted
+    mkdir -p ~/.config/openstack
+
+    for clouds_path in /etc/openstack ~/.config/openstack ; do
+        clouds_yaml=$clouds_path/clouds.yaml
 
         CA_CERT_ARG=''
         if [ -f "$SSL_BUNDLE_FILE" ]; then
             CA_CERT_ARG="--os-cacert $SSL_BUNDLE_FILE"
         fi
         $TOP_DIR/tools/update_clouds_yaml.py \
-            --file $CLOUDS_YAML \
+            --file $clouds_yaml \
             --os-cloud devstack \
             --os-region-name $REGION_NAME \
             --os-identity-api-version 3 \
@@ -97,7 +99,7 @@ function write_clouds_yaml {
             --os-password $ADMIN_PASSWORD \
             --os-project-name demo
         $TOP_DIR/tools/update_clouds_yaml.py \
-            --file $CLOUDS_YAML \
+            --file $clouds_yaml \
             --os-cloud devstack-admin \
             --os-region-name $REGION_NAME \
             --os-identity-api-version 3 \