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?
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.
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] [action] [flags]
DEPRECATION WARNING:
In an upcoming release of Fuel Client, the syntax will
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.