- name: Collect server location
ansible.builtin.shell: "/bin/awk '$1 ~ /{{ inventory_hostname }}/ { print $3
}' {{ server_list_file }}"
register: grep_result
changed_when: ( grep_result.rc != 0 )
You don't need grep AND awk. Learn to use awk's expressions to find what you
need in a single command.
% cat serverlist.txt
serverA flavor locationX owner
serverB flavor locationY owner
serverC flavor locationZ owner
% awk '$1 ~ /serverB/ { print $3; }' serverlist.txt
locationY
Walter
--
Walter Rowe, Division Chief
Infrastructure Services Division
Mobile: 202.355.4123
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/AF495547-15F6-4E50-ACD2-D2B1F1A75945%40nist.gov.