вторник, 24 августа 2021 г.

oracle

 ---

# tasks file for cfg_oracle


- name: check os support

  fail: msg="UNSUPPORTED OS"

  when: not

        (( ansible_distribution             == "OracleLinux" or

        ansible_distribution                == "RedHat" or 

        ansible_distribution                == "CentOS" ) and 

        (ansible_distribution_major_version  == "7" or

        ansible_distribution_major_version  == "6")  and

        ansible_userspace_bits              == "64")


#- name: Debug exit check point

#  fail:


- name: Disabling firewalld

  service: name=firewalld state=stopped enabled=no


- name: Disabling selinux

  selinux: state=disabled


- name: Installing chrony

  yum: name=chrony state=present


- name: Stopping chrony

  service: name=chronyd state=stopped enabled=yes


- name: Creating minimal /etc/chrony.conf

  copy:

    src: chrony.conf

    dest: /etc

  when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS"


- name: Starting chrony

  service: name=chronyd state=started enabled=yes


- name: Getting memory size

  shell: free -b | sed -n '2p' | cut -d ' ' -f 5

  register: mem


- name: Calculating KERNEL_SHMALL KERNEL_SHMMAX

  set_fact:

      KERNEL_SHMMAX: "{{ (mem.stdout|int / 2) |int }}"

      KERNEL_SHMALL: "{{ (mem.stdout|int / 2 / 4096) |int }}"


- name: Setting kernel values KERNEL_SHMALL, KERNEL_SHMMAX in /etc/sysctl.d/90-oracle.conf

  template:

    src=../templates/90-oracle.sysctl.conf.j2

    dest=/etc/sysctl.d/90-oracle.conf


- name: Applying kernel settings

  shell: sysctl -p -q



- name: Calculating SHMFS_SIZE

  set_fact:

    SHMFS_SIZE: "{{ (mem.stdout|int *9/10/1024/1024/1024) |int }}"


- name: Mounting shmfs

  mount:

    path: /dev/shm

    src: none

    fstype: tmpfs

    opts: size={{SHMFS_SIZE}}g

    state: mounted



- name: Creating group dba

  group: name=dba state=present gid=103


- name: Creating group oinstall

  group: name=oinstall state=present gid=104


- name: Creating group oper

  group: name=oper state=present gid=105


- name: Adding user oracle

  user: name=oracle groups=dba,oinstall,oper uid=103



- name: Getting root VG name

  shell: df /|tail -1|awk -F [/-] '{print $4}'

  register: root_vg


#- debug: msg={{root_vg}}


- name: Creating /db (30gb)

  lvol:

    vg: "{{root_vg.stdout}}"

    lv: db

    size: 30g

  when: root_vg.stdout != ""


- name: Creating directory /db

  file: path=/db state=directory


- name: Mounting /dev/{{root_vg.stdout}}/db to /db (checking that /dev/{{root_vg.stdout}}/db formated and valid and doesn't need to be formated)

  mount:

    path: /db

    src: /dev/{{root_vg.stdout}}/db

    fstype: ext4

    state: mounted

  ignore_errors: true


- name: Checking if /db is mounted

  shell: mount|grep /db

  register: is_db_mounted

  ignore_errors: true

  

#- debug: msg={{is_db_mounted}}

#- fail:


- name: Formating /dev/{{root_vg.stdout}}/db with mkfs.ext4

  shell: mkfs.ext4 /dev/{{root_vg.stdout}}/db

  when: is_db_mounted.rc != 0


- name: Mounting /dev/{{root_vg.stdout}}/db to /db

  mount:

    path: /db

    src: /dev/{{root_vg.stdout}}/db

    fstype: ext4

    state: mounted


- name: Setting permissions to oracle:dba on /db

  file: path=/db owner=oracle group=dba


- name: Creating /etc/oratab with owner oracle:dba

  file: path={{item}} owner=oracle group=dba state=touch

  with_items:

  - /etc/oratab

  - /etc/oraInst.loc


- name: Calculating memlock limit

  set_fact:

      memlock: "{{ (mem.stdout|int * 9 / 10240) |int }}"


- name: Generating /etc/security/limits.d/90-oracle.conf

  template:

    src=../templates/90-oracle-limits.conf.j2

    dest=/etc/security/limits.d/90-oracle.conf



- name: Copying default /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf to /etc

  shell: cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc


- name: Enabling mpathconf

  shell: mpathconf --enable


- name: Enabling multipathd

  service: name=multipathd state=started enabled=yes


- name: Copying /etc/rc.d/rc.local

  copy: src=rc.local dest=/etc/rc.d mode=0755


- name: Setting relayhost in /etc/postfix/main.cf

  lineinfile:

    path: /etc/postfix/main.cf

    line: 'relayhost = [mxsmtp.homecredit.ru]'


- name: Enabling postfix

  service: name=postfix state=started enabled=yes


- name: Installing Oracle dependencies

  yum: name={{ item }} state=present

  with_items: "{{ DEP_PKG }}"


- name: Copying /etc/fonts/local.conf

  copy: src=local.conf dest=/etc/fonts/local.conf mode=0644