Forum Discussion
Ansible bigip_command module error message
I'm trying to run a simple playbook to create a link in bash:
---
- name: Issue a command on the F5 devices
hosts: all
connection: local
environment:
F5_SERVER: '{{ ansible_host | default(inventory_hostname) }}'
gather_facts: false
tasks:
- name: Issue the command below
bigip_command:
commands:
- 'ln -sf /dev/sr0 /dev/cdrom'
However when I run this playbook, I'm getting an encoding error in AWX:
{
"msg": "'latin-1' codec can't encode characters in position 1-2: ordinal not in range(256)",
"exception": "
I'm wondering if the playbook is trying to run the command in TMOS rather than bash. Googling for that error returns a lot of Stack Overflow posts re: Python and needing to convert or define the script with UTF-8.
- Mike_ANimbostratus
I have been having issues with BASH commands using the bigip_command module. What I see after the job is run is below. As you can see it is 100%, atleast in my case, abending tmsh -c to any command. The module says it runs bash. I have not been able to figure out how to do it yet.
"executed_commands": [ "tmsh -c \\\"netstat -rn \\\" | grep \\\"^0.0.0.0\\\" | grep -v mgmt | awk \\'{print \\$2}\\'" ] "failed": false,
Here is what is in my playbook.
tasks: - name: Default Gateway bigip_command: commands: - netstat -rn | grep "^0.0.0.0" | grep -v mgmt | awk '{print $2}' provider: "{{ provider }}" register: f5_gateway_output - debug: var: f5_gateway_output
- ZukeCirrostratus
Mike your whitespace looks off. I pasted your playbook as printed above to yamllint.com and got errors. Try this.
--- tasks: - bigip_command: commands: - "netstat -rn | grep \"^0.0.0.0\" | grep -v mgmt | awk '{print $2}'" provider: "{{ provider }}" name: "Default Gateway" register: f5_gateway_output - debug: var: f5_gateway_output
- Mike_ANimbostratus
Zuke, even with what you pasted, I get the same response.
"executed_commands": [ "tmsh -c \\\"netstat -rn \\\" | grep \\\"^0.0.0.0\\\" | grep -v mgmt | awk \\'{print \\$2}\\'" ],
As you can see it is inserting "tmsh -c" before any command that is under the bigip_command module.
This module says it runs bash, I'm questioning how that is possible when "tmsh -c" is inserted before any command.
Have you successfully run a bash command with this bigip_command module?
- Mike_ANimbostratus
Just an update, it looks like it runs netstat -rn fine but when adding in the grep and awk statements it doesnt like it.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com