I need help of Ansible lineinfile module with a variable based on hostname. Here is what I have for the task:
On server vccs7ap01:
name: ulimits - find sidadm on the server
shell: hostname | sed ‘s/vc//’ | sed ‘s/ap[0-9][0-9]//g’ | sed ‘s/$/adm/’
register: sidadm
name: ulimits - add sidadm soft value to limits file
lineinfile:
path: /etc/security/limits.conf
regexp: ‘^sidadm.stdout\ soft’
line: “@sidadm.stdout\ soft 65536”
name: ulimits - add sidadm hard value to limits file
lineinfile:
path: /etc/security/limits.conf
regexp: ‘^sidadm.stdout\ hard’
line: “@sidadm.stdout\ hard 65536”
After ran the playbook, change was made to /etc/security/limits.conf: @sidadm.stdout soft 65536 @sidadm.stdout hard 65536
but I would like to have the entries:
cs7adm soft 65536
cs7adm hard 65536
I need help of Ansible lineinfile module with a variable based on hostname. Here is what I have for the task:>
On server vccs7ap01:
\- name: ulimits \- find sidadm on the server
shell: hostname | sed 's/vc//' | sed 's/ap\[0\-9\]\[0\-9\]//g' | sed 's/$/adm/'
register: sidadm
Ansible has already the hostname present in the variable "ansible_hostname", so you can really save the roundtrip to
vccs7ap01: