tbarbugli / cassandra_snapshotter

A tool to backup cassandra nodes using snapshots and incremental backups on S3
Other
222 stars 122 forks source link

Add support for ssh config #31

Closed thesmart closed 10 years ago

thesmart commented 10 years ago

Does this script support use of SSH config files? It doesn't seem to work for me. I have a host, user, port, and IdentityFile defined in my ~/.ssh/config file, but the script still says:

Fatal error: Needed to prompt for a connection or sudo password (host: my_vm)

I have verified that no password is required for SSH nor sudo once logged in. Here's the config:

Host my_vm
Hostname 127.0.0.1
Port=1122
User=ubuntu
IdentityFile ~/.ssh/id_rsa
thesmart commented 10 years ago

Looks like adding env.use_ssh_config = True to main.py did the trick. However, it still doesn't work because the script insists on using a password for sudo:

Executed: sudo -S -p 'sudo password:'  /bin/bash -l -c "cassandra-snapshotter-agent  create-upload-manifest --manifest_path=/tmp/backupmanifest --snapshot_name=20140915194646 --snapshot_keyspaces= --snapshot_table= --data_path=/var/lib/cassandra/data/"

Aborting.

Fatal error: One or more hosts failed while executing task 'upload_node_backups'

I added the ubuntu user to the sudoers so that it would not require password. This is very common when using with Capistrano.

tbarbugli commented 10 years ago

Hi John, Thank you for reporting about this issue. You are right, the tool does not parse ssh config settings (I am going to add that and release in few hours) and expects the backup user to be in the sudoers group (with no password prompt) I should add that somewhere in the docs

Tommaso

2014-09-15 21:50 GMT+02:00 John Smart notifications@github.com:

Looks like adding env.use_ssh_config = True to main.py did the trick. However, it still doesn't work because the script insists on using a password for sudo:

Executed: sudo -S -p 'sudo password:' /bin/bash -l -c "cassandra-snapshotter-agent create-upload-manifest --manifest_path=/tmp/backupmanifest --snapshot_name=20140915194646 --snapshot_keyspaces= --snapshot_table= --data_path=/var/lib/cassandra/data/"

Aborting.

Fatal error: One or more hosts failed while executing task 'upload_node_backups'

I added the ubuntu user to the sudoers so that it would not require password. This is very common when using with Capistrano.

— Reply to this email directly or view it on GitHub https://github.com/tbarbugli/cassandra_snapshotter/issues/31#issuecomment-55647813 .

tbarbugli commented 10 years ago

this is solved in 0.3.0

thesmart commented 10 years ago

Thanks for the submission. The script now executes on the server using the config. However, I'm still getting an error about sudo password:

Fatal error: sudo() received nonzero return code 1 while executing!

Requested: cassandra-snapshotter-agent  create-upload-manifest --manifest_path=/tmp/backupmanifest --snapshot_name=20140915205230 --snapshot_keyspaces= --snapshot_table= --data_path=/var/lib/cassandra/data/
Executed: sudo -S -p 'sudo password:'  /bin/bash -l -c "cassandra-snapshotter-agent  create-upload-manifest --manifest_path=/tmp/backupmanifest --snapshot_name=20140915205230 --snapshot_keyspaces= --snapshot_table= --data_path=/var/lib/cassandra/data/"

Aborting.

Fatal error: One or more hosts failed while executing task 'upload_node_backups'

I have verified that this user is part of the sudo group and that they do not need a password for sudo commands.

tbarbugli commented 10 years ago

do you have more output from the execution? perhaps you can ssh the machine and issue the command yourself

cassandra-snapshotter-agent create-upload-manifest --manifest_path=/tmp/backupmanifest --snapshot_name=20140915205230 --snapshot_keyspaces= --snapshot_table= --data_path=/var/lib/cassandra/data/

2014-09-15 22:53 GMT+02:00 John Smart notifications@github.com:

Thanks for the submission. The script now executes on the server using the config. However, I'm still getting an error about sudo password:

Fatal error: sudo() received nonzero return code 1 while executing!

Requested: cassandra-snapshotter-agent create-upload-manifest --manifest_path=/tmp/backupmanifest --snapshot_name=20140915205230 --snapshot_keyspaces= --snapshot_table= --data_path=/var/lib/cassandra/data/ Executed: sudo -S -p 'sudo password:' /bin/bash -l -c "cassandra-snapshotter-agent create-upload-manifest --manifest_path=/tmp/backupmanifest --snapshot_name=20140915205230 --snapshot_keyspaces= --snapshot_table= --data_path=/var/lib/cassandra/data/"

Aborting.

Fatal error: One or more hosts failed while executing task 'upload_node_backups'

I have verified that this user is part of the sudo group and that they do not need a password for sudo commands.

— Reply to this email directly or view it on GitHub https://github.com/tbarbugli/cassandra_snapshotter/issues/31#issuecomment-55656995 .

thesmart commented 10 years ago
$ sudo cassandra-snapshotter-agent create-upload-manifest --manifest_path=/tmp/backupmanifest --snapshot_name=20140915205230 --snapshot_keyspaces= --snapshot_table= --data_path=/var/lib/cassandra/data/
Traceback (most recent call last):
  File "/usr/local/bin/cassandra-snapshotter-agent", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2872, in <module>
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 449, in _build_master
    ws.require(__requires__)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 745, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 639, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: ecdsa

hmm, maybe an issue with my python packages...

tbarbugli commented 10 years ago

that seems indeed something broken with pip / install packages; perhaps you can get away by updating pip and re install cassandra_snapshotter

2014-09-15 23:03 GMT+02:00 John Smart notifications@github.com:

ecdsa

thesmart commented 10 years ago

Ok, looks like Paramiko was failing to install properly on Ubuntu because it would not compile properly without python-dev. I had to run:

sudo pip uninstall paramiko
sudo apt-get install python-dev
sudo pip install paramiko

Thanks a lot for your help!

tbarbugli commented 10 years ago

Hi John,

Thank you for reporting this problem; I think I will add a verify install command at some point, it seems like lot can go wrong with python and fabric installs.

Tommaso

2014-09-15 23:23 GMT+02:00 John Smart notifications@github.com:

Ok, looks like Paramiko was failing to install properly on Ubuntu because it would not compile properly without python-dev. I had to run:

sudo pip uninstall paramiko sudo apt-get install python-dev sudo pip install paramiko

— Reply to this email directly or view it on GitHub https://github.com/tbarbugli/cassandra_snapshotter/issues/31#issuecomment-55661166 .