deploy/ansible/roles-sap-os/2.6-sap-mounts/tasks/2.6.1-anf-mounts.yaml [9:159]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---

- name:                                "ANF Mount: Set the NFS Service name"
  ansible.builtin.set_fact:
    nfs_service:                       "{% if distribution_id in ['redhat8', 'redhat9'] %}nfs-server{% else %}{% if distribution_id == 'redhat7' %}nfs{% else %}{% if distribution_id == 'oraclelinux8' %}rpcbind{% else %}nfsserver{% endif %}{% endif %}{% endif %}"

- name:                                "ANF Mount: Set the NFSmount options"
  ansible.builtin.set_fact:
    mnt_options:                       'rw,nfsvers=4.1,hard,timeo=600,rsize=262144,wsize=262144,noatime,lock,_netdev,sec=sys'
  when: distribution_full_id not in ['redhat8.4', 'redhat8.6', 'redhat8.8', 'redhat9.0', 'redhat9.2', 'sles_sap15.2', 'sles_sap15.3', 'sles_sap15.4', 'sles_sap15.5', 'sles_sap15.6']

- name:                                "ANF Mount: Set the NFSmount options"
  ansible.builtin.set_fact:
    mnt_options:                       'rw,nfsvers=4.1,hard,timeo=600,rsize=262144,wsize=262144,noatime,lock,_netdev,sec=sys,nconnect=8'
  when: distribution_full_id in ['redhat8.4', 'redhat8.6', 'redhat8.8', 'redhat9.0', 'redhat9.2', 'sles_sap15.2', 'sles_sap15.3', 'sles_sap15.4', 'sles_sap15.5', 'sles_sap15.6']

- name:                                "ANF Mount: Define this SID"
  ansible.builtin.set_fact:
    this_sid:
      {
        'sid': '{{ sap_sid | upper }}',
        'dbsid_uid': '{{ hdbadm_uid }}',
        'sidadm_uid': '{{ sidadm_uid }}',
        'ascs_inst_no': '{{ scs_instance_number }}',
        'pas_inst_no': '{{ pas_instance_number }}',
        'app_inst_no': '{{ app_instance_number }}'
      }

- name:                                "ANF Mount: Create list of all_sap_mounts to support "
  ansible.builtin.set_fact:
    all_sap_mounts:                    "{% if MULTI_SIDS is defined %}{{ MULTI_SIDS }}{% else %}{{ all_sap_mounts | default([]) + [this_sid] }}{% endif %}"
    db_hosts:                          "{{ query('inventory_hostnames', '{{ sap_sid | upper }}_DB') }}"

- name:                                "ANF Mount: Ensure the NFS service is stopped"
  ansible.builtin.systemd:
    name:                              "{{ nfs_service }}"
    state:                             stopped
  when:
    - "'scs' in supported_tiers"
    - sap_mnt is not defined
    - sap_trans is not defined

# /*---------------------------------------------------------------------------8
# |                                                                            |
# |                            Mount the ANF Volumes                           |
# | Make sure to set the NFS domain in /etc/idmapd.conf on the VM to match the |
# | default domain configuration on Azure NetApp Files: defaultv4iddomain.com. |
# | and the mapping is set to nobody                                           |
# | We use tier in tasks as well, to treat any special scenarios that may arise|
# +------------------------------------4--------------------------------------*/
# For additional information refer to the below URLs
# https://docs.microsoft.com/en-us/azure/virtual-machines/workloads/sap/sap-hana-high-availability-netapp-files-suse#mount-the-azure-netapp-files-volume
# https://docs.microsoft.com/en-us/azure/virtual-machines/workloads/sap/sap-hana-high-availability-netapp-files-red-hat#mount-the-azure-netapp-files-volume
- name:                                "ANF Mount: NFS Domain Setting (ANF)"
  block:
    - name:                            "ANF Mount: Domain is configured as
                                        the default Azure NetApp Files domain"
      ansible.builtin.lineinfile:
        path:                          /etc/idmapd.conf
        regexp:                        '^[ #]*Domain = '
        line:                          'Domain = defaultv4iddomain.com'
        insertafter:                   '[General]'
      when:
        - tier == 'sapos'
      register:                        id_mapping_changed

    - name:                            "ANF Mount: Make sure that user
                                        mapping is set to 'nobody'"
      ansible.builtin.lineinfile:
        path:                          /etc/idmapd.conf
        regexp:                        '^[ #]*Nobody-User = '
        line:                          'Nobody-User = nobody'
        insertafter:                   '^[ #]*Nobody-User = '
      when:
        - tier == 'sapos'
      register:                        id_mapping_changed

    - name:                            "ANF Mount: Make sure that group
                                        mapping is set to 'nobody'"
      ansible.builtin.lineinfile:
        path:                          /etc/idmapd.conf
        regexp:                        '^[ #]*Nobody-Group = '
        line:                          'Nobody-Group = nobody'
        insertafter:                   '^[ #]*Nobody-Group = '
      when:
        - tier == 'sapos'
      register:                        id_mapping_changed
  when:
    - tier == 'sapos'

- name:                                "ANF Mount: Set nfs4_disable_idmapping to Y"
  ansible.builtin.lineinfile:
    path:                              /etc/modprobe.d/nfs.conf
    line:                              'options nfs nfs4_disable_idmapping=Y'
    create:                            true
    mode:                              0644
  when:
    - tier == 'sapos'

- name:                                "ANF Mount: Ensure the services are restarted"
  block:
    - name:                            "AF Mount: Ensure the rpcbind service is restarted"
      ansible.builtin.systemd:
        name:                          rpcbind
        state:                         restarted
    - name:                            "ANF Mount: Ensure the NFS ID Map service is restarted"
      ansible.builtin.systemd:
        name:                          "nfs-idmapd"
        daemon-reload:                 true
        state:                         restarted
    - name:                            "ANF Mount: Pause for 5 seconds"
      ansible.builtin.pause:
        seconds:                       5
    - name:                            "ANF Mount: Ensure the NFS service is restarted"
      ansible.builtin.systemd:
        name:                          "{{ nfs_service }}"
        state:                         restarted
  when:
    - id_mapping_changed is changed

# /*---------------------------------------------------------------------------8
# |                                                                            |
# |         Prepare for the /usr/sap mounts                                    |
# |         Create temporary directory structure                               |
# |         Mount the share, create the directory structure on share           |
# |         Unmount and clean up temporary directory structure                 |
# |                                                                            |
# +------------------------------------4--------------------------------------*/

- name:                                "ANF Mount: install:Get the Server name list"
  ansible.builtin.set_fact:
    first_app_server_temp:             "{{ first_app_server_temp | default([]) + [item] }}"
  with_items:
    - "{{ query('inventory_hostnames', '{{ sap_sid | upper }}_PAS') }}"
    - "{{ query('inventory_hostnames', '{{ sap_sid | upper }}_DB') }}"

# 'target_nodes':      ['app','pas'], - will be set to only pas as we do not
# have the ability to set the different app instance numbers for multiple nodes
# todo: fix this so that we validate that the app_instance_number is not the
# same as the pas_instance_number. If it is the same, then we should only
# mount the pas instance.
- name:                                "ANF Mount: usr/sap"
  ansible.builtin.include_tasks:       2.6.1.1-anf-mount.yaml
  loop:
    - {
      'type':              'usrsap',
      'temppath':          'tmpusersap',
      'mount':             '{{ usr_sap_mountpoint }}',
      'opts':              'rw,hard,rsize=65536,wsize=65536,sec=sys,vers=4.1,tcp',
      'path':              '/usr/sap',
      'set_chattr_on_dir': false,
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



deploy/ansible/roles-sap-os/2.6-sap-mounts/tasks/2.6.8-anf-mounts-simplemount.yaml [9:154]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---

- name:                                "ANF Mount: Set the NFS Service name"
  ansible.builtin.set_fact:
    nfs_service:                       "{% if distribution_id in ['redhat8', 'redhat9'] %}nfs-server{% else %}{% if distribution_id == 'redhat7' %}nfs{% else %}{% if distribution_id == 'oraclelinux8' %}rpcbind{% else %}nfsserver{% endif %}{% endif %}{% endif %}"

- name:                                "ANF Mount: Set the NFSmount options"
  ansible.builtin.set_fact:
    mnt_options:                       'rw,nfsvers=4.1,hard,timeo=600,rsize=262144,wsize=262144,noatime,lock,_netdev,sec=sys'
  when: distribution_full_id not in ['redhat8.4', 'redhat8.6', 'redhat8.8', 'redhat9.0', 'redhat9.2', 'sles_sap15.2', 'sles_sap15.3', 'sles_sap15.4', 'sles_sap15.5', 'sles_sap15.6']

- name:                                "ANF Mount: Set the NFSmount options"
  ansible.builtin.set_fact:
    mnt_options:                       'rw,nfsvers=4.1,hard,timeo=600,rsize=262144,wsize=262144,noatime,lock,_netdev,sec=sys,nconnect=8'
  when: distribution_full_id in ['redhat8.4', 'redhat8.6', 'redhat8.8', 'redhat9.0', 'redhat9.2', 'sles_sap15.2', 'sles_sap15.3', 'sles_sap15.4', 'sles_sap15.5', 'sles_sap15.6']

- name:                                "ANF Mount: Define this SID"
  ansible.builtin.set_fact:
    this_sid:
      {
        'sid': '{{ sap_sid | upper }}',
        'dbsid_uid': '{{ hdbadm_uid }}',
        'sidadm_uid': '{{ sidadm_uid }}',
        'ascs_inst_no': '{{ scs_instance_number }}',
        'pas_inst_no': '{{ pas_instance_number }}',
        'app_inst_no': '{{ app_instance_number }}'
      }

- name:                                "ANF Mount: Create list of all_sap_mounts to support "
  ansible.builtin.set_fact:
    all_sap_mounts:                    "{% if MULTI_SIDS is defined %}{{ MULTI_SIDS }}{% else %}{{ all_sap_mounts | default([]) + [this_sid] }}{% endif %}"
    db_hosts:                          "{{ query('inventory_hostnames', '{{ sap_sid | upper }}_DB') }}"

- name:                                "ANF Mount: Ensure the NFS service is stopped"
  ansible.builtin.systemd:
    name:                              "{{ nfs_service }}"
    state:                             stopped
  when:
    - "'scs' in supported_tiers"
    - sap_mnt is not defined
    - sap_trans is not defined

# /*---------------------------------------------------------------------------8
# |                                                                            |
# |                            Mount the ANF Volumes                           |
# | Make sure to set the NFS domain in /etc/idmapd.conf on the VM to match the |
# | default domain configuration on Azure NetApp Files: defaultv4iddomain.com. |
# | and the mapping is set to nobody                                           |
# | We use tier in tasks as well, to treat any special scenarios that may arise|
# +------------------------------------4--------------------------------------*/
# For additional information refer to the below URLs
# https://docs.microsoft.com/en-us/azure/virtual-machines/workloads/sap/sap-hana-high-availability-netapp-files-suse#mount-the-azure-netapp-files-volume
# https://docs.microsoft.com/en-us/azure/virtual-machines/workloads/sap/sap-hana-high-availability-netapp-files-red-hat#mount-the-azure-netapp-files-volume
- name:                                "ANF Mount: NFS Domain Setting (ANF)"
  block:
    - name:                            "ANF Mount: Domain is configured as
                                        the default Azure NetApp Files domain"
      ansible.builtin.lineinfile:
        path:                          /etc/idmapd.conf
        regexp:                        '^[ #]*Domain = '
        line:                          'Domain = defaultv4iddomain.com'
        insertafter:                   '[General]'
      when:
        - tier == 'sapos'
      register:                        id_mapping_changed

    - name:                            "ANF Mount: Make sure that user
                                        mapping is set to 'nobody'"
      ansible.builtin.lineinfile:
        path:                          /etc/idmapd.conf
        regexp:                        '^[ #]*Nobody-User = '
        line:                          'Nobody-User = nobody'
        insertafter:                   '^[ #]*Nobody-User = '
      when:
        - tier == 'sapos'
      register:                        id_mapping_changed

    - name:                            "ANF Mount: Make sure that group
                                        mapping is set to 'nobody'"
      ansible.builtin.lineinfile:
        path:                          /etc/idmapd.conf
        regexp:                        '^[ #]*Nobody-Group = '
        line:                          'Nobody-Group = nobody'
        insertafter:                   '^[ #]*Nobody-Group = '
      when:
        - tier == 'sapos'
      register:                        id_mapping_changed
  when:
    - tier == 'sapos'

- name:                                "ANF Mount: Set nfs4_disable_idmapping to Y"
  ansible.builtin.lineinfile:
    path:                              /etc/modprobe.d/nfs.conf
    line:                              'options nfs nfs4_disable_idmapping=Y'
    create:                            true
    mode:                              0644
  when:
    - tier == 'sapos'

- name:                                "ANF Mount: Ensure the services are restarted"
  block:
    - name:                            "AF Mount: Ensure the rpcbind service is restarted"
      ansible.builtin.systemd:
        name:                          rpcbind
        state:                         restarted
    - name:                            "ANF Mount: Ensure the NFS ID Map service is restarted"
      ansible.builtin.systemd:
        name:                          "nfs-idmapd"
        daemon-reload:                 true
        state:                         restarted
    - name:                            "ANF Mount: Pause for 5 seconds"
      ansible.builtin.pause:
        seconds:                       5
    - name:                            "ANF Mount: Ensure the NFS service is restarted"
      ansible.builtin.systemd:
        name:                          "{{ nfs_service }}"
        state:                         restarted
  when:
    - id_mapping_changed is changed

# /*---------------------------------------------------------------------------8
# |                                                                            |
# |         Prepare for the /usr/sap mounts                                    |
# |         Create temporary directory structure                               |
# |         Mount the share, create the directory structure on share           |
# |         Unmount and clean up temporary directory structure                 |
# |                                                                            |
# +------------------------------------4--------------------------------------*/

- name:                                "ANF Mount: install:Get the Server name list"
  ansible.builtin.set_fact:
    first_app_server_temp:             "{{ first_app_server_temp | default([]) + [item] }}"
  with_items:
    - "{{ query('inventory_hostnames', '{{ sap_sid | upper }}_PAS') }}"
    - "{{ query('inventory_hostnames', '{{ sap_sid | upper }}_DB') }}"

- name:                                "ANF Mount: usr/sap"
  ansible.builtin.include_tasks:       2.6.1.1-anf-mount.yaml
  loop:
    - {
      'type':              'usrsap',
      'temppath':          'tmpusersap',
      'mount':             '{{ usr_sap_mountpoint }}',
      'opts':              'rw,hard,rsize=65536,wsize=65536,sec=sys,vers=4.1,tcp',
      'path':              '/usr/sap',
      'set_chattr_on_dir': false,
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



