Initial commit
[ta/infra-ansible.git] / playbooks / baremetal-setup-nfs-server.yaml
diff --git a/playbooks/baremetal-setup-nfs-server.yaml b/playbooks/baremetal-setup-nfs-server.yaml
new file mode 100644 (file)
index 0000000..076caf8
--- /dev/null
@@ -0,0 +1,55 @@
+---
+
+# Copyright 2019 Nokia
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+- name: Create /remote_image_share_root/ directory for virtmedia driver
+  file:
+    path: "/remote_image_share_root/"
+    state: directory
+    mode: u=rwx,g=rwx,o=rx
+    owner: "ironic"
+    group: "ironic"
+
+- name: Create entry in /etc/exports for other controllers /remote_image_share_root/
+  lineinfile:
+      dest: "/etc/exports"
+      # Use infra_external subnet for now. When we have infra_hwmgmt support add logic to make choice later.
+      line: "/remote_image_share_root/ {{hostvars[item.key]['networking']['infra_external']['ip']}}(rw,sync,no_root_squash,no_subtree_check)"
+      create: yes
+  with_dict: "{{hosts}}"
+  when:
+    - '"controller" in item.value["service_profiles"]'
+    - hostvars[item.key] != inventory_hostname
+    - installation_phase != "provisioning-started"
+  loop_control:
+    label: "{{ item.key }}"
+
+- name: Create access entries for BMC ports of all nodes in /etc/exports from /remote_image_share_root/
+  lineinfile:
+      dest: "/etc/exports"
+      line: "/remote_image_share_root/ {{item.value['hwmgmt']['address']}}(ro,sync,no_root_squash,no_subtree_check)"
+      create: yes
+  with_dict: "{{hosts}}"
+  loop_control:
+    label: "{{ item.key }}"
+
+- name: Enable nfs-server
+  systemd:
+    name: "nfs-server"
+    state: started
+    enabled: yes
+
+- name: Run exportfs command
+  command: "exportfs -a"