Forum Discussion

quickref's avatar
quickref
Icon for Nimbostratus rankNimbostratus
Jul 13, 2023

ansible script to return SSL TPS

Hi, i'm very new to Ansible. I managed to write my first simple script to get the ssl TPS stats from my devices.

When i run the command on the cli i get this output:

tmsh show sys performance | grep 'SSL TPS' -B 2 | awk '{print $3","$4","$5}'
Current,Average,Max(since
,,
0,0,0

Now i put this into a csv file . Threfor i started builduing a Ansible script which initailly just prints the output:

---
- name: execution of tmos command
hosts: f5

tasks:
- name: show ssl TPS
bigip_command:
commands: tmsh show sys performance | grep 'SSL TPS' -B 2 | awk '{print $3","$4","$5}'
provider:
server: "{{ inventory_hostname }}"
password: "{{ ansible_password }}"
user: "{{ ansible_user }}"
validate_certs: false
delegate_to: localhost
register: ssl_output

- name: Print ssl output
debug:
msg: "{{ ssl_output }}"

i get this output:

ok: [f5bigip] => {
"msg": {
"changed": false,
"executed_commands": [
"tmsh -c \\\"show sys performance \\\" | grep \\'SSL TPS\\' -B 2 | awk \\'{print \\$3\\\",\\\"\\$4\\\",\\\"\\$5\\\\}\\'"
],
"failed": false,
"stdout": [
"awk: cmd. line:1: {print \\$3\",\"\\$4\",\"\\$5\\}\nawk: cmd. line:1: ^ backslash not last character on line\nawk: cmd. line:1: {print \\$3\",\"\\$4\",\"\\$5\\}\nawk: cmd. line:1: ^ syntax error\ngrep: write error: Broken pipe"
],
"stdout_lines": [
[
"awk: cmd. line:1: {print \\$3\",\"\\$4\",\"\\$5\\}",
"awk: cmd. line:1: ^ backslash not last character on line",
"awk: cmd. line:1: {print \\$3\",\"\\$4\",\"\\$5\\}",
"awk: cmd. line:1: ^ syntax error",
"grep: write error: Broken pipe"
]
]
}
}

Can someone tell me how i need to modify the awk to get the backslah at the end of the line? i searched already the web but i don't understand most of the solutions to be honest.

 



  • bigip_command ansible module support bigip related command.