Run local dynamic inventory script against remote Fuel server

98 views
Skip to first unread message

Rod Oliver

unread,
Jul 10, 2016, 5:08:41 AM7/10/16
to Ansible Project
I have found a dynamic inventory script (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?

Kai Stian Olstad

unread,
Jul 10, 2016, 11:31:56 AM7/10/16
to ansible...@googlegroups.com
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.

--
Kai Stian Olstad

Rod Oliver

unread,
Jul 17, 2016, 3:55:17 AM7/17/16
to Ansible Project, ansible-pr...@olstad.com
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> '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] <namespace> [action] [flags]

            DEPRECATION WARNING:

                In an upcoming release of Fuel Client, the syntax will
<snip snip>

Dmitry Makovey

unread,
Jul 18, 2016, 10:54:36 AM7/18/16
to Ansible Project, ansible-pr...@olstad.com


On Sunday, July 17, 2016 at 12:55:17 AM UTC-7, Rod Oliver wrote:
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> '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> '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> 'python /path/on/fuel/server//fuel.py'

would be more natural IMO.
Reply all
Reply to author
Forward
0 new messages