# Run local dynamic inventory script against remote Fuel server

**URL:** <https://forum.ansible.com/t/run-local-dynamic-inventory-script-against-remote-fuel-server/21976>\
**Category:** Ansible Project\
**Created:** [July 10, 2016, 9:08am UTC](https://forum.ansible.com/t/run-local-dynamic-inventory-script-against-remote-fuel-server/21976 "2016-07-10T09:08:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamroddo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iamroddo/32/321_2.png) [@iamroddo](https://forum.ansible.com/u/iamroddo)\
**Post date:** [July 10, 2016, 9:08am UTC](https://forum.ansible.com/t/run-local-dynamic-inventory-script-against-remote-fuel-server/21976/1 "2016-07-10T09:08:40Z")

</div>

I have found a dynamic inventory script ([https://github.com/martineg/ansible-fuel-inventory](https://github.com/martineg/ansible-fuel-inventory)) for Mirantis Fuel that runs just fine on the Fuel host itself. In my case I can’t install Ansible on the Fuel server so need to to run the dynamic inventory script remotely. I guess there ought to be a way to do this via SSH. Can anyone suggest how to do this simply and preferably without modifying the dynamic inventory script itself?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 10, 2016, 3:31pm UTC](https://forum.ansible.com/t/run-local-dynamic-inventory-script-against-remote-fuel-server/21976/2 "2016-07-10T15:31:41Z")

</div>

I guess this should work, but you'll need to set up ssh keys between Ansible control machine and the fuel server.  
Make a script(here called my\_script.sh) on Ansible control machine and make it executable.

#!/bin/bash  
ssh user@fuel-server /path/to/fuel.py

Then you can run ansible/ansible-playbook with  
-i my\_script.sh  
or change ansible.cfg accordingly.

---

<div class="post-metadata">

**Author:** ![iamroddo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iamroddo/32/321_2.png) [@iamroddo](https://forum.ansible.com/u/iamroddo)\
**Post date:** [July 17, 2016, 7:55am UTC](https://forum.ansible.com/t/run-local-dynamic-inventory-script-against-remote-fuel-server/21976/3 "2016-07-17T07:55:17Z")

</div>

Thanks for the reply, apologies for late response.

I _think_ the command “ssh user@fuel-server /path/to/fuel.py” attempts to run the command “/path/to/fuel.py” on the fuel-server. In any case the script fails.

I tried altering the dynamic inventory to that below.

#!/bin/bash  
ssh [user@fuel-server](mailto:user@fuel-server) ‘bash -s’ \< ./fuel.py

I can run the script from the command line of the Ansible server but it spits back what I think is a fuel client error. The same happens when I try to use the script as a dynamic inventory with Ansible (ansible -i dyn-invent all -m ping).

vagrant@ansible:~/playbooks/test-env$ ./dyn-invent  
bash: line 3: import: command not found  
bash: line 4: import: command not found  
bash: line 5: import: command not found  
bash: line 6: import: command not found  
bash: line 7: import: command not found  
bash: line 8: from: command not found  
bash: line 9: from: command not found  
usage:  
fuel [optional args] [action] [flags]

DEPRECATION WARNING:

In an upcoming release of Fuel Client, the syntax will

---

<div class="post-metadata">

**Author:** ![Dimon](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@Dimon](https://forum.ansible.com/u/Dimon)\
**Post date:** [July 18, 2016, 2:54pm UTC](https://forum.ansible.com/t/run-local-dynamic-inventory-script-against-remote-fuel-server/21976/4 "2016-07-18T14:54:36Z")

</div>

> Thanks for the reply, apologies for late response.
> 
> I _think_ the command “ssh user@fuel-server /path/to/fuel.py” attempts to run the command “/path/to/fuel.py” on the fuel-server. In any case the script fails.

would you mind sharing what specifically fails?

> I tried altering the dynamic inventory to that below.
> 
> #!/bin/bash  
> ssh [user@fuel-server](mailto:user@fuel-server) ‘bash -s’ \< ./fuel.py

isn’t this telling bash to interpret fuel.py ??? don’t you want something more like

> #!/bin/bash  
> ssh [user@fuel-server](mailto:user@fuel-server) ‘python’ \< ./fuel.py

at which point I’d think that copying fuel.py over to “fuel-server” and running it as:

> #!/bin/bash  
> ssh [user@fuel-server](mailto:user@fuel-server) ‘python /path/on/fuel/server//fuel.py’

would be more natural IMO.
