Also, you are iterating over a list of 1 item, which is incorrect as well.
Also, you’re trying to establish something called “os_type” using a shell task, but that is not necessary - this is already available in the ansible facts (which you’ve explicitly gathered).
So just use ‘ansible_system’ instead.
Also, you declare “become: yes”, but also “remote_user: root”. That’s double. Either connect as non-root user and only declare “become: yes” (which implies become_user = root). Or just only declare “remote_user: root”.
Also, you are iterating over a list of 1 item, which is incorrect as well.
Also, you're trying to establish something called "os_type" using a shell task, but that is not necessary - this is
already available in the ansible facts (which you've explicitly gathered).
So just use 'ansible_system' instead.
Also, you declare "become: yes", but also "remote_user: root". That's double. Either connect as non-root user and only
declare "become: yes" (which implies become_user = root). Or just only declare "remote_user: root".
Try this:
- hosts: temp
gather_facts: yes
remote_user: root
tasks:
- name: Adjust OOM to negative so that OOM killer does not kill below processes
shell: 'ps -ef|egrep
"sssd|wdmd|portreserve|autofs|automount|ypbind|rpcbind|rpc.statd|rpc.mountd|rpc.idampd|ntpd|lmgrd|Xvnc|vncconfig|irqblance|rpc.rquotad|metric|nscd|crond|snpslmd|getpwname.pl
<http://getpwname.pl>|mysqld|rsyslogd|xinetd|sendmail|lsf|tigervnc|tightvnc|cfadm" |egrep -ve "ps|egrep" |awk "{print \$2}"'
register: oom
when: ansible_system == 'Linux'
- debug: var=oom.stdout
- name: update the pid
raw: echo -17 > /proc/{{ item }}/oom_adj
loop: "{{ oom.stdout_lines }}"
This looks like a bad hack to me. Why don't you adjust OOMScoreAdjust in the system unit files of these services (or
corresponding setting in init scripts) ??