---
- name: set the value of the Semaphores
  set_fact:
       SEM_COUNT: "500 256000 64 10240"
  when: SEM_COUNT is not defined
- name: test value
  debug: msg="Value of semaphores is {{ SEM_COUNT }} "  #"
- name: Place comment line in file
  lineinfile: 
     path: /etc/sysctl.d/88-setSemaphore.conf
     line: "#set large semaphore count. Needed for Gamess."
     state: present
     create: yes
     owner: root
     group: root
     mode: "u+rwx,o=rx,g=rx"
  become: true
  become_user: root
  when: ansible_os_family == 'RedHat'
     
- name: Place comment line in file
  lineinfile: 
     path: /etc/sysctl.d/88-setSemaphore.conf
     line: "#https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/tuning_and_optimizing_red_hat_enterprise_linux_for_oracle_9i_and_10g_databases/sect-oracle_9i_and_10g_tuning_guide-setting_semaphores-setting_semaphore_parameters "
     state: present
  become: true
  become_user: root
  when: ansible_os_family == 'RedHat'

- name: Place comment line in file
  lineinfile: 
     path: /etc/sysctl.d/88-setSemaphore.conf
     line: "kernel.sem={{ SEM_COUNT }}"
     state: present
     create: yes
     owner: root
     group: root
     mode: "u+rwx,o=rx,g=rx"
  become: true
  become_user: root
  when: ansible_os_family == 'RedHat'

- name: set semaphore count now 
  shell: "/usr/bin/echo {{ SEM_COUNT }}   > /proc/sys/kernel/sem"
  become: true
  become_user: root
  when: ansible_os_family == 'RedHat'

