Initial commit
[ta/infra-ansible.git] / playbooks / baremetal-setup-nfs-server.yaml
1 ---
2
3 # Copyright 2019 Nokia
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 - name: Create /remote_image_share_root/ directory for virtmedia driver
18   file:
19     path: "/remote_image_share_root/"
20     state: directory
21     mode: u=rwx,g=rwx,o=rx
22     owner: "ironic"
23     group: "ironic"
24
25 - name: Create entry in /etc/exports for other controllers /remote_image_share_root/
26   lineinfile:
27       dest: "/etc/exports"
28       # Use infra_external subnet for now. When we have infra_hwmgmt support add logic to make choice later.
29       line: "/remote_image_share_root/ {{hostvars[item.key]['networking']['infra_external']['ip']}}(rw,sync,no_root_squash,no_subtree_check)"
30       create: yes
31   with_dict: "{{hosts}}"
32   when:
33     - '"controller" in item.value["service_profiles"]'
34     - hostvars[item.key] != inventory_hostname
35     - installation_phase != "provisioning-started"
36   loop_control:
37     label: "{{ item.key }}"
38
39 - name: Create access entries for BMC ports of all nodes in /etc/exports from /remote_image_share_root/
40   lineinfile:
41       dest: "/etc/exports"
42       line: "/remote_image_share_root/ {{item.value['hwmgmt']['address']}}(ro,sync,no_root_squash,no_subtree_check)"
43       create: yes
44   with_dict: "{{hosts}}"
45   loop_control:
46     label: "{{ item.key }}"
47
48 - name: Enable nfs-server
49   systemd:
50     name: "nfs-server"
51     state: started
52     enabled: yes
53
54 - name: Run exportfs command
55   command: "exportfs -a"