<commit_before>---
  - name: Check if firewall is installed
    yum: list={{ firewall_service }} disablerepo=*
    when: disable_firewall|bool and ansible_os_family == 'RedHat'
    tags: firewall
    register: firewall

  - name: Disable firewall
    service: name={{ firewall_service }} state=stopped enabled=no
    when: disable_firewall|bool and ansible_os_family == 'RedHat' and firewall.results
    tags: firewall

  - name: Disable selinux (permanently)
    selinux: state=disabled
    when: disable_selinux and ansible_os_family == 'RedHat'
    tags: selinux
    register: selinux

  - name: Disable selinux (runtime)
    command: setenforce 0
    when: disable_selinux and ansible_os_family == 'RedHat' and ansible_selinux.status != 'disabled'
    changed_when: disable_selinux_runtime.rc == 0
    failed_when: disable_selinux_runtime.rc > 0 and "SELinux is disabled" not in disable_selinux_runtime.stderr
    register: disable_selinux_runtime
    tags: selinux

  - name: Stat RHEL7 base repo
    stat:
      path: /etc/yum.repos.d/redhat.repo
    register: redhat_repo

  - name: Stat RHEL7 rhui repo
    stat:
      path: /etc/yum.repos.d/rh-cloud.repo
    register: rh_cloud_repo

  - name: Install Oracle required packages (base/non-rhui config)
    yum:
      name: "{{ oracle_required_rpms }}"
      state: present
      lock_timeout: 180
      enablerepo: server_optional_rpms
    when:
      - install_os_packages|bool and ansible_os_family == 'RedHat'
      - redhat_repo.stat.exists|bool
    tags: os-packages

  - name: Install Oracle required packages (rhui config)
    yum:
      name: "{{ oracle_required_rpms }}"
      state: present
      lock_timeout: 180
      enablerepo: rhui-rhel-7-server-rhui-optional-rpms
    when:
      - install_os_packages|bool and ansible_os_family == 'RedHat'
      - rh_cloud_repo.stat.exists|bool
      - not redhat_repo.stat.exists|bool
    tags: os-packages

  - name: Add OS groups
    group:
      name: "{{ item.group }}"
      gid: "{{ item.gid }}"
      state: present
    with_items:
      - "{{ oracle_groups }}"
      - "{{ asm_groups }}"
    tags: os-groups

  - name: Add users
    user:
      name: "{{ item.name }}"
      comment: "{{ item.comment }}"
      uid: "{{ item.uid }}"
      group: "{{ item.group }}"
    with_items: "{{ oracle_users }}"
    tags: os-users

  - name: Add necessary groups to grid user
    user:
      name: "{{ grid_user }}"
      groups: "{{ item.group }}"
      append: yes
    with_items:
      - "{{ asm_groups }}"
      - "{{ extra_asm_groups }}"
    tags: os-users,os-groups

  - name: Add necessary groups to the oracle user
    user:
      name: "{{ oracle_user }}"
      groups: "{{ item.group }}"
      append: yes
    with_items:
      - "{{ oracle_groups }}"
      - "{{ extra_oracle_groups }}"
    tags: os-users,os-groups

  - name: Add sysctl entries
    sysctl:
      name: "{{ item.name }}"
      value: "{{ item.value }}"
      state: present
      reload: yes
    with_items:
      - "{{ sysctl_entries }}"
    tags: sysctl

  - name: Adjust kernel limits for users
    pam_limits:
      domain: "{{ item[0] }}"
      limit_type: "{{ item[1].type }}"
      limit_item: "{{ item[1].name }}"
      value: "{{ item[1].value }}"
    with_nested:
      - [ "{{ oracle_user }}", "{{ grid_user }}" ]
      - "{{ resource_limits }}"
    tags: kernel-setup

  - name: Create required directories
    file:
      path: "{{ item.name }}"
      state: directory
      owner: "{{ item.owner }}"
      group: "{{ item.group }}"
      mode: "{{ item.mode }}"
    with_items: "{{ oracle_dirs }}"
    tags: os-dirs

  - name: tmp file configuration
    blockinfile:
      block: "{{ item }}"
      dest: "/usr/lib/tmpfiles.d/tmp.conf"
      marker: "# {mark} Oracle Temp Settings {{ item }}:"
      backup: no
    become: yes
    with_items:
      - x /var/tmp/.oracle
      - x /tmp/.oracle
      - x /usr/tmp/.oracle
    tags: os-dirs

  - name: Uncomment line from /etc/systemd/logind.conf
    lineinfile:
      dest: /etc/systemd/logind.conf
      regexp: '^#\s*RemoveIPC.*$'
      line: 'RemoveIPC=no'

  - name: Append database variables to bash_profile
    blockinfile:
      block: "{{ lookup('template', 'bash_profile_rdbms.j2') }}"
      dest: "/home/{{ oracle_user }}/.bash_profile"
      marker: "# {mark} Oracle RDBMS Settings:"
      backup: yes
    become: yes
    become_user: "{{ oracle_user }}"
    tags: os-users

  - name: Append GI variables to bash_profile
    blockinfile:
      block: "{{ lookup('template', 'bash_profile_gi.j2') }}"
      dest: "/home/{{ grid_user }}/.bash_profile"
      marker: "# {mark} Oracle Grid Infrastructure Settings:"
      backup: yes
    when: role_separaion|bool
    become: yes
    become_user: "{{ grid_user }}"
    tags: os-users

  - name: (asmlib) | asmlib or udev?
    debug:
      msg: "asm_disk_control is set to {{ asm_disk_control }}"
    tags: asm-disks

  - name: Partition all ASM raw disks
    parted:
      device: "{{ item.1.blk_device }}"
      number: 1
      state: present
      label: gpt
    when: "'mapper' not in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: asm-disks

  - name: Collect new disk facts
    setup:
      gather_subset:
        - '!all'
        - '!any'
        - devices

  - name: (debug) asm disk configuration
    debug:
      msg:
       - asm_disks {{ asm_disks }}
       - asm_def_file {{ asm_definition_file }}
       - asm_disk_input {{ asm_disk_input }}
    tags: asm-disks

  - name: (udev) Add ASM disk rules on virtualbox
    blockinfile:
      block: "KERNEL==\"sd?1\", SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id -g -u -d /dev/$parent\", RESULT==\"1{{ hostvars[inventory_hostname]['ansible_device_links']['ids']['%s' | format( item.1.blk_device | regex_replace('/dev/') )][0] | regex_replace('ata-','ATA_') }}\", SYMLINK+=\"oracleasm/{{ item.1.name }}\", OWNER=\"{{ grid_user }}\", GROUP=\"{{ grid_group }}\", MODE=\"0660\""
      dest: "/etc/udev/rules.d/99-oracle-asmdevices.rules"
      marker: "# {mark} ASM disk udev rules for {{ item.1.name }}:"
      create: yes
    become: yes
    register: udevRules
    when:
      - ansible_virtualization_type == "virtualbox"
      - asm_disk_control == "udev"
      - "'mapper' not in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: asm-disks

  - name: (udev) Add ASM disk rules on baremetal (not mpath)
    blockinfile:
      block: "KERNEL==\"sd?1\", SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id -g -u -d /dev/$parent\", RESULT==\"{{ hostvars[inventory_hostname]['ansible_device_links']['ids']['%s' | format( item.1.blk_device | regex_replace('/dev/') )][0] | regex_replace('scsi-') }}\", SYMLINK+=\"oracleasm/{{ item.1.name }}\", OWNER=\"{{ grid_user }}\", GROUP=\"{{ grid_group }}\", MODE=\"0660\""
      dest: "/etc/udev/rules.d/99-oracle-asmdevices.rules"
      marker: "# {mark} ASM disk udev rules for {{ item.1.name }}:"
      create: yes
    become: yes
    register: udevRules
    when:
      - ansible_virtualization_type == "kvm"
      - ansible_virtualization_role == "host"
      - asm_disk_control == "udev"
      - "'mapper' not in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: asm-disks

  - name: (udev) Add ASM mpath disk rules on BM (udevadm info)
    shell: udevadm info --query=all --name={{ item.1.blk_device }} | grep DM_UUID | awk -F'=' '{print $2}'
    become: yes
    register: udevadm_result
    when:
      - "'mapper' in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: udev_mpath

  - name: (udev) Add ASM mpath disk rules on BM (init dict)
    set_fact:
      uuid_result: []
    when:
      - udevadm_result is defined
    tags: udev_mpath

  - name: (udev) Add ASM mpath disk rules on BM (filling dict)
    set_fact:
      uuid_result: "{{ uuid_result | combine({item.stdout: item.item}) }}"
    when:
      - udevadm_result is defined
    with_items:
      - "{{ udevadm_result.results }}"
    tags: udev_mpath

  - name: (udev) Add ASM mpath disk rules on BM (udev rules file)
    blockinfile:
      block: "ACTION==\"add|change\", ENV{DM_UUID}==\"{{ item }}\", SYMLINK+=\"oracleasm/{{ uuid_result[item] | json_query ('[*].name') | list | join(', ') }}\", GROUP=\"{{ grid_group }}\", OWNER=\"{{ grid_user }}\", MODE=\"0660\""
      path: "/etc/udev/rules.d/99-oracle-asmdevices.rules"
      marker: "# {mark} ASM disk udev rules for {{ uuid_result[item] | json_query ('[*].blk_device') | list | join(', ') }}"
      create: yes
    become: yes
    register: udevRules
    when:
      - uuid_result is defined
    with_items:
      - "{{ uuid_result.keys() }}"
    tags: udev_mpath

  - name: (udev) Add ASM disk rules on GCE
    blockinfile:
      block: "KERNEL==\"sd?1\", SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id -g -u -d /dev/$parent\", RESULT==\"{{ hostvars[inventory_hostname]['ansible_device_links']['ids']['%s' | format( item.1.blk_device | regex_replace('/dev/') )][1] | regex_replace('scsi-') }}\", SYMLINK+=\"oracleasm/{{ item.1.name }}\", OWNER=\"{{ grid_user }}\", GROUP=\"{{ grid_group }}\", MODE=\"0660\""
      dest: "/etc/udev/rules.d/99-oracle-asmdevices.rules"
      marker: "# {mark} ASM disk udev rules for {{ item.1.name }}:"
      create: yes
    become: yes
    register: udevRules
    when:
      - ansible_system_vendor == "Google"
      - ansible_virtualization_type == "kvm"
      - ansible_virtualization_role == "guest"
      - asm_disk_control == "udev"
      - "'mapper' not in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: asm-disks

  - name: (udev) reload rules
    shell: ( /sbin/udevadm control --reload-rules && /sbin/udevadm trigger )
    become: yes
    tags: asm-disks

  - name: (asmlib) Install Oracle ASM libraries
    yum:
      name: "{{ oracleasm_libs }}"
    when: asm_disk_control == "asmlib"
    tags: oracleasmlib

  - name: (asmlib) Configure oracleasm
    shell: |
      /usr/sbin/oracleasm configure -e -u {{ grid_user }} -g {{ grid_group }} -b -s y
      /usr/sbin/oracleasm init
      /usr/sbin/oracleasm status
      /usr/sbin/oracleasm scandisks
      cat /etc/sysconfig/oracleasm
    register: asmconfig
    when: asm_disk_control == "asmlib"
    become: yes
    become_user: root
    tags: asm-disks

  - name: (asmlib) Create Oracle ASM raw disks
    command: "/usr/sbin/oracleasm createdisk -v {{ item.1.name }} {{ item.1.blk_device }}1"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    when: asm_disk_control == "asmlib" and ( not ( item.1.blk_device is search('mapper') ) )
    register: asmraw
    failed_when: "( ( asmraw.rc != 0 ) and ( 'ERROR' in asmraw.stdout ) ) or ( ( asmraw.rc != 0 ) and ( 'is already labeled for ASM disk' not in asmraw.stdout ) )"
    changed_when: "'Writing disk header: done' in asmraw.stdout"
    become: yes
    become_user: root
    tags: asm-disks

  - name: (asmlib) Create Oracle ASM lv disks
    command: "/usr/sbin/oracleasm createdisk -v {{ item.1.name }} {{ item.1.blk_device }}"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    when: asm_disk_control == "asmlib"
    register: asmlv
    failed_when: "( ( asmlv.rc != 0 ) and ( 'ERROR' in asmlv.stdout ) ) or ( ( asmlv.rc != 0 ) and ( 'is already labeled for ASM disk' not in asmlv.stdout ) )"
    changed_when: "'Writing disk header: done' in asmlv.stdout"
    become: yes
    become_user: root
    tags: asm-disks

  - name: (asmlib) List ASM disks
    shell: |
      /usr/sbin/oracleasm-discover 'ORCL:*'
      /usr/sbin/oracleasm listdisks
      ls -l /dev/oracleasm/disks
    register: listdisks
    when: asm_disk_control == "asmlib"
    become: yes
    become_user: root
    tags: asm-disks

  - name: (asmlib) ASM listing results
    debug:
      msg:
      - "{{ item.stderr_lines }}"
      - "{{ item.stdout_lines }}"
      #verbosity: 1
    with_items:
      - "{{ asmconfig }}"
      - "{{ listdisks }}"
    when: asm_disk_control == "asmlib"
    tags: asm-disks
<commit_msg>GOBMCN2-51 - T-125 - Bug - compat-stdlibc++-33 not available<commit_after>---
  - name: Check if firewall is installed
    yum: list={{ firewall_service }} disablerepo=*
    when: disable_firewall|bool and ansible_os_family == 'RedHat'
    tags: firewall
    register: firewall

  - name: Disable firewall
    service: name={{ firewall_service }} state=stopped enabled=no
    when: disable_firewall|bool and ansible_os_family == 'RedHat' and firewall.results
    tags: firewall

  - name: Disable selinux (permanently)
    selinux: state=disabled
    when: disable_selinux and ansible_os_family == 'RedHat'
    tags: selinux
    register: selinux

  - name: Disable selinux (runtime)
    command: setenforce 0
    when: disable_selinux and ansible_os_family == 'RedHat' and ansible_selinux.status != 'disabled'
    changed_when: disable_selinux_runtime.rc == 0
    failed_when: disable_selinux_runtime.rc > 0 and "SELinux is disabled" not in disable_selinux_runtime.stderr
    register: disable_selinux_runtime
    tags: selinux

  - name: Stat RHEL7 base repo
    stat:
      path: /etc/yum.repos.d/redhat.repo
    register: redhat_repo

  - name: Stat RHEL7 rhui repo
    stat:
      path: /etc/yum.repos.d/rh-cloud.repo
    register: rh_cloud_repo

  - name: Install Oracle required packages (base/non-rhui config)
    yum:
      name: "{{ oracle_required_rpms }}"
      state: present
      lock_timeout: 180
      enablerepo: rhel-7-server-optional-rpms
    when:
      - install_os_packages|bool and ansible_os_family == 'RedHat'
      - redhat_repo.stat.exists|bool
    tags: os-packages

  - name: Install Oracle required packages (rhui config)
    yum:
      name: "{{ oracle_required_rpms }}"
      state: present
      lock_timeout: 180
      enablerepo: rhui-rhel-7-server-rhui-optional-rpms
    when:
      - install_os_packages|bool and ansible_os_family == 'RedHat'
      - rh_cloud_repo.stat.exists|bool
      - not redhat_repo.stat.exists|bool
    tags: os-packages

  - name: Add OS groups
    group:
      name: "{{ item.group }}"
      gid: "{{ item.gid }}"
      state: present
    with_items:
      - "{{ oracle_groups }}"
      - "{{ asm_groups }}"
    tags: os-groups

  - name: Add users
    user:
      name: "{{ item.name }}"
      comment: "{{ item.comment }}"
      uid: "{{ item.uid }}"
      group: "{{ item.group }}"
    with_items: "{{ oracle_users }}"
    tags: os-users

  - name: Add necessary groups to grid user
    user:
      name: "{{ grid_user }}"
      groups: "{{ item.group }}"
      append: yes
    with_items:
      - "{{ asm_groups }}"
      - "{{ extra_asm_groups }}"
    tags: os-users,os-groups

  - name: Add necessary groups to the oracle user
    user:
      name: "{{ oracle_user }}"
      groups: "{{ item.group }}"
      append: yes
    with_items:
      - "{{ oracle_groups }}"
      - "{{ extra_oracle_groups }}"
    tags: os-users,os-groups

  - name: Add sysctl entries
    sysctl:
      name: "{{ item.name }}"
      value: "{{ item.value }}"
      state: present
      reload: yes
    with_items:
      - "{{ sysctl_entries }}"
    tags: sysctl

  - name: Adjust kernel limits for users
    pam_limits:
      domain: "{{ item[0] }}"
      limit_type: "{{ item[1].type }}"
      limit_item: "{{ item[1].name }}"
      value: "{{ item[1].value }}"
    with_nested:
      - [ "{{ oracle_user }}", "{{ grid_user }}" ]
      - "{{ resource_limits }}"
    tags: kernel-setup

  - name: Create required directories
    file:
      path: "{{ item.name }}"
      state: directory
      owner: "{{ item.owner }}"
      group: "{{ item.group }}"
      mode: "{{ item.mode }}"
    with_items: "{{ oracle_dirs }}"
    tags: os-dirs

  - name: tmp file configuration
    blockinfile:
      block: "{{ item }}"
      dest: "/usr/lib/tmpfiles.d/tmp.conf"
      marker: "# {mark} Oracle Temp Settings {{ item }}:"
      backup: no
    become: yes
    with_items:
      - x /var/tmp/.oracle
      - x /tmp/.oracle
      - x /usr/tmp/.oracle
    tags: os-dirs

  - name: Uncomment line from /etc/systemd/logind.conf
    lineinfile:
      dest: /etc/systemd/logind.conf
      regexp: '^#\s*RemoveIPC.*$'
      line: 'RemoveIPC=no'

  - name: Append database variables to bash_profile
    blockinfile:
      block: "{{ lookup('template', 'bash_profile_rdbms.j2') }}"
      dest: "/home/{{ oracle_user }}/.bash_profile"
      marker: "# {mark} Oracle RDBMS Settings:"
      backup: yes
    become: yes
    become_user: "{{ oracle_user }}"
    tags: os-users

  - name: Append GI variables to bash_profile
    blockinfile:
      block: "{{ lookup('template', 'bash_profile_gi.j2') }}"
      dest: "/home/{{ grid_user }}/.bash_profile"
      marker: "# {mark} Oracle Grid Infrastructure Settings:"
      backup: yes
    when: role_separaion|bool
    become: yes
    become_user: "{{ grid_user }}"
    tags: os-users

  - name: (asmlib) | asmlib or udev?
    debug:
      msg: "asm_disk_control is set to {{ asm_disk_control }}"
    tags: asm-disks

  - name: Partition all ASM raw disks
    parted:
      device: "{{ item.1.blk_device }}"
      number: 1
      state: present
      label: gpt
    when: "'mapper' not in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: asm-disks

  - name: Collect new disk facts
    setup:
      gather_subset:
        - '!all'
        - '!any'
        - devices

  - name: (debug) asm disk configuration
    debug:
      msg:
       - asm_disks {{ asm_disks }}
       - asm_def_file {{ asm_definition_file }}
       - asm_disk_input {{ asm_disk_input }}
    tags: asm-disks

  - name: (udev) Add ASM disk rules on virtualbox
    blockinfile:
      block: "KERNEL==\"sd?1\", SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id -g -u -d /dev/$parent\", RESULT==\"1{{ hostvars[inventory_hostname]['ansible_device_links']['ids']['%s' | format( item.1.blk_device | regex_replace('/dev/') )][0] | regex_replace('ata-','ATA_') }}\", SYMLINK+=\"oracleasm/{{ item.1.name }}\", OWNER=\"{{ grid_user }}\", GROUP=\"{{ grid_group }}\", MODE=\"0660\""
      dest: "/etc/udev/rules.d/99-oracle-asmdevices.rules"
      marker: "# {mark} ASM disk udev rules for {{ item.1.name }}:"
      create: yes
    become: yes
    register: udevRules
    when:
      - ansible_virtualization_type == "virtualbox"
      - asm_disk_control == "udev"
      - "'mapper' not in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: asm-disks

  - name: (udev) Add ASM disk rules on baremetal (not mpath)
    blockinfile:
      block: "KERNEL==\"sd?1\", SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id -g -u -d /dev/$parent\", RESULT==\"{{ hostvars[inventory_hostname]['ansible_device_links']['ids']['%s' | format( item.1.blk_device | regex_replace('/dev/') )][0] | regex_replace('scsi-') }}\", SYMLINK+=\"oracleasm/{{ item.1.name }}\", OWNER=\"{{ grid_user }}\", GROUP=\"{{ grid_group }}\", MODE=\"0660\""
      dest: "/etc/udev/rules.d/99-oracle-asmdevices.rules"
      marker: "# {mark} ASM disk udev rules for {{ item.1.name }}:"
      create: yes
    become: yes
    register: udevRules
    when:
      - ansible_virtualization_type == "kvm"
      - ansible_virtualization_role == "host"
      - asm_disk_control == "udev"
      - "'mapper' not in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: asm-disks

  - name: (udev) Add ASM mpath disk rules on BM (udevadm info)
    shell: udevadm info --query=all --name={{ item.1.blk_device }} | grep DM_UUID | awk -F'=' '{print $2}'
    become: yes
    register: udevadm_result
    when:
      - "'mapper' in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: udev_mpath

  - name: (udev) Add ASM mpath disk rules on BM (init dict)
    set_fact:
      uuid_result: []
    when:
      - udevadm_result is defined
    tags: udev_mpath

  - name: (udev) Add ASM mpath disk rules on BM (filling dict)
    set_fact:
      uuid_result: "{{ uuid_result | combine({item.stdout: item.item}) }}"
    when:
      - udevadm_result is defined
    with_items:
      - "{{ udevadm_result.results }}"
    tags: udev_mpath

  - name: (udev) Add ASM mpath disk rules on BM (udev rules file)
    blockinfile:
      block: "ACTION==\"add|change\", ENV{DM_UUID}==\"{{ item }}\", SYMLINK+=\"oracleasm/{{ uuid_result[item] | json_query ('[*].name') | list | join(', ') }}\", GROUP=\"{{ grid_group }}\", OWNER=\"{{ grid_user }}\", MODE=\"0660\""
      path: "/etc/udev/rules.d/99-oracle-asmdevices.rules"
      marker: "# {mark} ASM disk udev rules for {{ uuid_result[item] | json_query ('[*].blk_device') | list | join(', ') }}"
      create: yes
    become: yes
    register: udevRules
    when:
      - uuid_result is defined
    with_items:
      - "{{ uuid_result.keys() }}"
    tags: udev_mpath

  - name: (udev) Add ASM disk rules on GCE
    blockinfile:
      block: "KERNEL==\"sd?1\", SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id -g -u -d /dev/$parent\", RESULT==\"{{ hostvars[inventory_hostname]['ansible_device_links']['ids']['%s' | format( item.1.blk_device | regex_replace('/dev/') )][1] | regex_replace('scsi-') }}\", SYMLINK+=\"oracleasm/{{ item.1.name }}\", OWNER=\"{{ grid_user }}\", GROUP=\"{{ grid_group }}\", MODE=\"0660\""
      dest: "/etc/udev/rules.d/99-oracle-asmdevices.rules"
      marker: "# {mark} ASM disk udev rules for {{ item.1.name }}:"
      create: yes
    become: yes
    register: udevRules
    when:
      - ansible_system_vendor == "Google"
      - ansible_virtualization_type == "kvm"
      - ansible_virtualization_role == "guest"
      - asm_disk_control == "udev"
      - "'mapper' not in item.1.blk_device"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    tags: asm-disks

  - name: (udev) reload rules
    shell: ( /sbin/udevadm control --reload-rules && /sbin/udevadm trigger )
    become: yes
    tags: asm-disks

  - name: (asmlib) Install Oracle ASM libraries
    yum:
      name: "{{ oracleasm_libs }}"
    when: asm_disk_control == "asmlib"
    tags: oracleasmlib

  - name: (asmlib) Configure oracleasm
    shell: |
      /usr/sbin/oracleasm configure -e -u {{ grid_user }} -g {{ grid_group }} -b -s y
      /usr/sbin/oracleasm init
      /usr/sbin/oracleasm status
      /usr/sbin/oracleasm scandisks
      cat /etc/sysconfig/oracleasm
    register: asmconfig
    when: asm_disk_control == "asmlib"
    become: yes
    become_user: root
    tags: asm-disks

  - name: (asmlib) Create Oracle ASM raw disks
    command: "/usr/sbin/oracleasm createdisk -v {{ item.1.name }} {{ item.1.blk_device }}1"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    when: asm_disk_control == "asmlib" and ( not ( item.1.blk_device is search('mapper') ) )
    register: asmraw
    failed_when: "( ( asmraw.rc != 0 ) and ( 'ERROR' in asmraw.stdout ) ) or ( ( asmraw.rc != 0 ) and ( 'is already labeled for ASM disk' not in asmraw.stdout ) )"
    changed_when: "'Writing disk header: done' in asmraw.stdout"
    become: yes
    become_user: root
    tags: asm-disks

  - name: (asmlib) Create Oracle ASM lv disks
    command: "/usr/sbin/oracleasm createdisk -v {{ item.1.name }} {{ item.1.blk_device }}"
    with_subelements:
      - "{{ asm_disks }}"
      - disks
    when: asm_disk_control == "asmlib"
    register: asmlv
    failed_when: "( ( asmlv.rc != 0 ) and ( 'ERROR' in asmlv.stdout ) ) or ( ( asmlv.rc != 0 ) and ( 'is already labeled for ASM disk' not in asmlv.stdout ) )"
    changed_when: "'Writing disk header: done' in asmlv.stdout"
    become: yes
    become_user: root
    tags: asm-disks

  - name: (asmlib) List ASM disks
    shell: |
      /usr/sbin/oracleasm-discover 'ORCL:*'
      /usr/sbin/oracleasm listdisks
      ls -l /dev/oracleasm/disks
    register: listdisks
    when: asm_disk_control == "asmlib"
    become: yes
    become_user: root
    tags: asm-disks

  - name: (asmlib) ASM listing results
    debug:
      msg:
      - "{{ item.stderr_lines }}"
      - "{{ item.stdout_lines }}"
      #verbosity: 1
    with_items:
      - "{{ asmconfig }}"
      - "{{ listdisks }}"
    when: asm_disk_control == "asmlib"
    tags: asm-disks

{'fraction_non_alphanumeric': 0.15286807670150604, 'fraction_numerical': 0.006789564644885194, 'mean_word_length': 2.590868794326241, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '750651', 'n_tokens_mistral': 8897, 'n_tokens_neox': 8589, 'n_words': 1981}