Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\"bash\" unexpected argument #2452

Open
akashombase7 opened this issue Jan 20, 2025 · 7 comments
Open

\"bash\" unexpected argument #2452

akashombase7 opened this issue Jan 20, 2025 · 7 comments
Labels
awaiting-user-action issue awaiting user's response and/or requested action

Comments

@akashombase7
Copy link

ansible [core 2.16.3]
config file = /home/admin/ansible_automation/ansible.cfg
configured module search path = ['/home/admin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.12/site-packages/ansible
ansible collection location = /home/admin/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.12.6 (main, Sep 23 2024, 09:58:19) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/usr/bin/python3.12)
jinja version = 3.1.2
libyaml = True

f5-icontrol-rest==1.3.13
f5-sdk==3.0.21

ansible playbook:

  • name: Fetch config data
    hosts: f5 #localhost #f5
    gather_facts: False
    connection: local
    ignore_errors: yes
    collections:
    • f5networks.f5_modules
      vars:
      tasks:

    • name: Save the running configuration of the BIG-IP
      bigip_config:
      save: true
      provider:
      server:
      password:
      user:
      validate_certs: false
      delegate_to: localhost

    • name: Fetch F5 device configuration data
      bigip_device_info:
      gather_subset:
      - all
      provider:
      server:
      user:
      password:
      validate_certs: false
      transport: rest
      register: f5_config
      ignore_errors: yes
      delegate_to: localhost

    • name: run show version on remote devices
      bigip_command:
      commands: show sys version
      provider: # "{{ Creds }}"
      server:
      user:
      password:
      validate_certs: false
      server_port: 443
      transport: rest
      register: result
      delegate_to: localhost

Error:
nUsing /home/admin/ansible_automation/ansible.cfg as config file

PLAY [Fetch config data] *********************************************************************************************************

TASK [Save the running configuration of the BIG-IP] ******************************************************************************
fatal: [xxxxxxxxxxx -> localhost]: FAILED! => {"changed": false, "msg": "b'{"code":400,"message":"\\"bash\\" unexpected argument","errorStack":[],"apiError":26214401}'"}
...ignoring

TASK [Fetch F5 device configuration data] ****************************************************************************************
fatal: [xxxxxxxxxxxxxx -> localhost]: FAILED! => {"changed": false, "msg": "b'{"code":401,"message":"Authorization failed: user=https://localhost/mgmt/cm/system/authn/providers/tmos/1f44a60e-11a7-3c51-a49f-82983026b41b/users/7dcfeb41-05eb-3551-ad54-376d915052e7 resource=/mgmt/shared/iapp/global-installed-packages verb=GET uri:http://localhost:8100/mgmt/shared/iapp/global-installed-packages referrer:10.163.40.105 sender:10.163.40.105","referer":"10.163.40.105","restOperationId":151014421,"kind":":resterrorresponse"}'"}
...ignoring

TASK [run show version on remote devices] ****************************************************************************************
fatal: [xxxxxxxxxxxxx -> localhost]: FAILED! => {"changed": false, "msg": ""bash" unexpected argument"}

@akashombase7 akashombase7 added bug Issues that are related to bugs in the Ansible modules untriaged issue that needs an initial response from the developers labels Jan 20, 2025
@pgouband
Copy link
Contributor

Hi @akashombase7,

I tested the following with success with ansible-core version 2.15 and 2.17 so I think there is an issue in your environment:

- hosts: all
  collections:
    - f5networks.f5_modules
  connection: local

  tasks:
     - name: Save the running configuration of the BIG-IP
       bigip_config:
         save: true
         provider:
           server: 10.1.1.9
           user: "admin"
           password: "mypassword"
           server_port: 443
           validate_certs: no
           no_f5_teem: yes
       delegate_to: localhost
       
     - name: Collect BIG-IP information
       bigip_device_info:
         gather_subset:
           - all
         provider:
           server: 10.1.1.9
           user: "admin"
           password: "mypassword"
           server_port: 443
           validate_certs: no
           no_f5_teem: yes
       delegate_to: localhost

     - name: run show version on remote devices
       bigip_command:
         commands: show sys version
         provider:
           server: 10.1.1.9
           user: "admin"
           password: "mypassword"
           server_port: 443
           validate_certs: no
           no_f5_teem: yes
       delegate_to: localhost
$ ansible-playbook -i hosts save.yml 

PLAY [all] **********************************************************************************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************************************************************
ok: [10.1.1.9]

TASK [Save the running configuration of the BIG-IP] *****************************************************************************************************************************************
changed: [10.1.1.9 -> localhost]

TASK [Collect BIG-IP information] ***********************************************************************************************************************************************************
ok: [10.1.1.9 -> localhost]

TASK [run show version on remote devices] ***************************************************************************************************************************************************
ok: [10.1.1.9 -> localhost]

PLAY RECAP **********************************************************************************************************************************************************************************
10.1.1.9                   : ok=4    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

@pgouband pgouband added awaiting-user-action issue awaiting user's response and/or requested action and removed bug Issues that are related to bugs in the Ansible modules untriaged issue that needs an initial response from the developers labels Jan 20, 2025
@akashombase7
Copy link
Author

akashombase7 commented Jan 20, 2025 via email

@pgouband
Copy link
Contributor

Hi @akashombase7,

First are you sending credentials via option "-u" on curl command?
So your command should look like:
curl -u admin:mypassword -k https://BIG-IPDeviceIP/mgmt/tm/sys/host-info

Also /host in the end doesn't seem available.

@akashombase7
Copy link
Author

Hello @pgouband thank for you reply. I have an idea why it's saying 'bash unexpected argument.' It seems some devices doesn't API connections from Ansible, and there is no bash access on some devices. However, could you check this new issue: why is device1 failing on the task 'run show version on remote devices,' while device2 is working fine on that task?

Device1:

Sys::Version
Main Package
Product BIG-IP
Version 15.1.2.1
Build 0.0.10
Edition Point Release 1
Date Fri Jan 15 13:43:15 PST 2021

Device2:

Sys::Version
Main Package
Product BIG-IP
Version 15.1.2.1
Build 0.0.10
Edition Point Release 1
Date Fri Jan 15 13:43:15 PST 202

task:

- name: run show version on remote devices
  bigip_command:
    commands: show sys version
    provider:    # "{{ Creds }}"
      server: "{{ inventory_hostname }}"
      user: 
      password: 
      validate_certs: false
      transport: rest
  register: result
  delegate_to: localhost

Output:

TASK [run show version on remote devices] ************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: AbstractDigestAuthHandler does not support the following scheme: 'X-Auth-Token'
fatal: [device1 -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/home/admin/.ansible/tmp/ansible-tmp-1737979161.221677-1206920-18261339151182/AnsiballZ_bigip_command.py", line 107, in \n _ansiballz_main()\n File "/home/admin/.ansible/tmp/ansible-tmp-1737979161.221677-1206920-18261339151182/AnsiballZ_bigip_command.py", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/home/admin/.ansible/tmp/ansible-tmp-1737979161.221677-1206920-18261339151182/AnsiballZ_bigip_command.py", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.f5networks.f5_modules.plugins.modules.bigip_command', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5_modules.plugins.modules.bigip_command', _modlib_path=modlib_path),\n File "", line 226, in run_module\n File "", line 98, in _run_module_code\n File "", line 88, in _run_code\n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_command.py", line 756, in \n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_command.py", line 749, in main\n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_command.py", line 679, in exec_module\n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible_collections/f5networks/f5_modules/plugins/modules/bigip_command.py", line 630, in exec_module\n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible_collections/f5networks/f5_modules/plugins/module_utils/icontrol.py", line 551, in tmos_version\n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible_collections/f5networks/f5_modules/plugins/module_utils/bigip.py", line 33, in api\n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible_collections/f5networks/f5_modules/plugins/module_utils/bigip.py", line 84, in connect_via_basic_auth\n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible_collections/f5networks/f5_modules/plugins/module_utils/icontrol.py", line 233, in get\n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible_collections/f5networks/f5_modules/plugins/module_utils/icontrol.py", line 194, in send\n File "/tmp/ansible_bigip_command_payload_ph1gnouw/ansible_bigip_command_payload.zip/ansible/module_utils/urls.py", line 1578, in open\n File "/usr/lib64/python3.12/urllib/request.py", line 215, in urlopen\n return opener.open(url, data, timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 521, in open\n response = meth(req, response)\n ^^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 630, in http_response\n response = self.parent.error(\n ^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 553, in error\n result = self._call_chain(*args)\n ^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 492, in _call_chain\n result = func(*args)\n ^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 1052, in http_error_401\n response = self.http_error_auth_reqed('www-authenticate',\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 1001, in http_error_auth_reqed\n return self.retry_http_basic_auth(host, req, realm)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 1016, in retry_http_basic_auth\n return self.parent.open(req, timeout=req.timeout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 521, in open\n response = meth(req, response)\n ^^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 630, in http_response\n response = self.parent.error(\n ^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 553, in error\n result = self._call_chain(*args)\n ^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 492, in _call_chain\n result = func(*args)\n ^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 1234, in http_error_401\n retry = self.http_error_auth_reqed('www-authenticate',\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/lib64/python3.12/urllib/request.py", line 1116, in http_error_auth_reqed\n raise ValueError("AbstractDigestAuthHandler does not support"\nValueError: AbstractDigestAuthHandler does not support the following scheme: 'X-Auth-Token'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
...ignoring
ok: [device2 -> localhost] => {"changed": false, "executed_commands": ["tmsh -c \"show sys version\""], "stdout": ["Sys::Version\nMain Package\n Product BIG-IP\n Version 15.1.2.1\n Build 0.0.10\n Edition Point Release 1\n Date Fri Jan 15 13:43:15 PST 2021"], "stdout_lines": [["Sys::Version", "Main Package", " Product BIG-IP", " Version 15.1.2.1", " Build 0.0.10", " Edition Point Release 1", " Date Fri Jan 15 13:43:15 PST 2021"]]}

@pgouband
Copy link
Contributor

pgouband commented Jan 27, 2025

Hi @akashombase7,

I suggest you try to reach API endpoint of each device using curl or Postman:
https://my.f5.com/manage/s/article/K000138026

Ansible module is working with one device so the issue is probably in your environment.
I suggest you open a ticket via https://my.f5.com/manage/s/

@akashombase7
Copy link
Author

akashombase7 commented Jan 27, 2025

hello @pgouband

When running curl on Device1, we received an 'Authorization Failed' error. However, the device is still getting a response from the API. Could above module failure issue be due to access permissions or anything else? fyi both device has admin role to my service account.

@pgouband
Copy link
Contributor

Hi @akashombase7,

If curl command output is Authorization failed that means an error in credentials but it's not an ansible issue so open a ticket via https://my.f5.com/manage/s/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-action issue awaiting user's response and/or requested action
Projects
None yet
Development

No branches or pull requests

2 participants