kapilt / juju-digitalocean

JuDo - A juju provider for digital ocean using a client side plugin and manual provisioning.
111 stars 17 forks source link

setting SSH Key #8

Closed 0vermind closed 10 years ago

0vermind commented 10 years ago

Hi guys, thanks for your useful charm! I need some help to set up the config file for juju-digitalocean. I have put file docean.conf in ~/.juju but it seems not to be recognized (there are no instruction in the wiki on github ).

Using export command to set the vars I get this error when I boostrap the environment

  File "/root/env/venv-juju-docean/local/lib/python2.7/site-packages/juju_docean/commands.py", line 28, in get_do_ssh_keys
    return [k.id for k in self.provider.get_ssh_keys()]
AttributeError: 'str' object has no attribute 'id'
ERROR exit status 1
(venv-juju-docean)root@ubuntu:~/.juju#

Also I don't understand the format of DO_SSH_KEY = default default is the keyname on DO panel or the actual content like in authorized_keys file?

Thanks in advance for any help.

kapilt commented 10 years ago

There isn't any docean.conf file referenced anywhere that i can see, i've tried to remove all references of that as its not supported by the implementation. All config is via environment variables at the moment.

Primarily the DO_CLIENT_ID and DO_API_KEY .. There was an issue with the DO_SSH_KEY environment variable, i'm fixing that and will push momentarily to github and pypi. You should be fine if you just unset the DO_SSH_KEY environment variable.

kapilt commented 10 years ago

fix committed in 500a8da355 released to pypi as juju-docean 0.1.0

also added some additional documentation.. the env variable if set should be the key name in the console, and its generally not needed, cause by default the plugin will create instances with all the keys found in via the digital ocean api.

0vermind commented 10 years ago

Hi @kapilt thanks for the fast fix! Setting vars from the command line it's working.

I tried to bootstrap using the up to date juju-docean environment in virtalenvwrapper from my pc using putty. It's boostrapping but in the end it's asking for password instead of using the key.

root@1.x.x..43's password:
2014/03/13 15:19.51:INFO Bootstrapping environment
Traceback (most recent call last):
  File "/root/venvs/juju-docean/bin/juju-docean", line 9, in <module>
    load_entry_point('juju-docean==0.2.1', 'console_scripts', 'juju-docean')()
  File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/cli.py", line 100, in main
    cmd.run()
  File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/commands.py", line 88, in run
    self.env.bootstrap_jenv(instance.ip_address)
  File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/env.py", line 93, in bootstrap_jenv
    os.path.join(boot_home, 'ssh'))
  File "/usr/lib/python2.7/shutil.py", line 169, in copytree
    names = os.listdir(src)
OSError: [Errno 2] No such file or directory: '/root/.juju/ssh'

Even if I set export DO_SSH_KEY=mykey or export DO_SSH_KEY="mykey" or even if I unset the DO_SSH_KEY completely.

p.s. Note that the docs in this wiki are still referring to the juju docean boostrap command instead of juju-docean boostrap if I understand well.

kapilt commented 10 years ago

its hard to tell without the missing context.. are you running the whole thing as root?

you need to have the private key counterpart of your digital ocean in the ~/.ssh directory of whichever user is running the juju docean command. soclearly if you don't have a ~/.ssh directory your root user does not have access to your DO ssh private key, and would never be able to login to the machine as a result. The plugin is trying to create copy of your ssh directory to a transient temp dir so it can bootstrap without having you enter in the new's machine ip address into environments.yaml.. anyways.. if you add your private key to ~/.ssh with the right perms/name it should be okay.

-k

On Thu, Mar 13, 2014 at 3:37 PM, 0vermind notifications@github.com wrote:

Hi @kapilt https://github.com/kapilt thanks for the fast fix! Setting vars from the command line it's working.

I tried to bootstrap using the up to date juju-docean environment. It's boostrapping but in the end it's asking for password

root@1.x.x..43's password: 2014/03/13 15:19.51:INFO Bootstrapping environment Traceback (most recent call last): File "/root/venvs/juju-docean/bin/juju-docean", line 9, in load_entry_point('juju-docean==0.2.1', 'console_scripts', 'juju-docean')() File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/cli.py", line 100, in main cmd.run() File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/commands.py", line 88, in run self.env.bootstrap_jenv(instance.ip_address) File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/env.py", line 93, in bootstrap_jenv os.path.join(boot_home, 'ssh')) File "/usr/lib/python2.7/shutil.py", line 169, in copytree names = os.listdir(src) OSError: [Errno 2] No such file or directory: '/root/.juju/ssh'

Even if I set export DO_SSH_KEY=mykey or even if I unset the DO_SSH_KEY completely.

p.s. Note that the docs in this wiki are still referring to the juju docean boostrap command instead of juju-docean boostrap if I understand well.

Reply to this email directly or view it on GitHubhttps://github.com/kapilt/juju-digitalocean/issues/8#issuecomment-37577271 .

0vermind commented 10 years ago

Hi @kapilt you are right I'm running it from root from another droplet only for this porpoise. And this droplet has the ~/.ssh key imported and working using putty. When I create a droplet from the admin panel the key is imported correctly, instead when I create the droplet using juju-docean the image is not including the ~/.ssh. Should I need to add some extra constraint?

0vermind commented 10 years ago

Update: if I reset the password from the control panel and then I imput in to the console when asked by juju-docean I get this error:

root@123.123.123.123's password:
2014/03/14 07:24.33:INFO Bootstrapping environment
Traceback (most recent call last):
  File "/root/venvs/juju-docean/bin/juju-docean", line 9, in <module>
    load_entry_point('juju-docean==0.2.1', 'console_scripts', 'juju-docean')()
  File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/cl                                               i.py", line 100, in main
    cmd.run()
  File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/co                                               mmands.py", line 88, in run
    self.env.bootstrap_jenv(instance.ip_address)
  File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/en                                               v.py", line 90, in bootstrap_jenv
    os.makedirs(os.path.join(boot_home, 'environments'))
  File "/root/venvs/juju-docean/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 17] File exists: '/root/.juju/boot-digitalocean/environments'
kapilt commented 10 years ago

i think i see the underlying issue now. i've got meetings all day today, but i'll try to address tonight and push an update.

On Fri, Mar 14, 2014 at 7:30 AM, 0vermind notifications@github.com wrote:

Update: if I reset the password from the control panel and then I imput in to the console when asked by juju-docean I get this error:

Traceback (most recent call last): File "/root/venvs/juju-docean/bin/juju-docean", line 9, in load_entry_point('juju-docean= =0.2.1', 'console_scripts', 'juju-docean')() File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/cl i.py", line 100, in main cmd.run() File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/co mmands.py", line 88, in run self.env.bootstrap_jenv(instance.ip_address) File "/root/venvs/juju-docean/local/lib/python2.7/site-packages/juju_docean/en v.py", line 90, in bootstrap_jenv os.makedirs(os.path.join(boot_home, 'environments')) File "/root/venvs/juju-docean/lib/python2.7/os.py", line 157, in makedirs mkdir(name, mode) OSError: [Errno 17] File exists: '/root/.juju/boot-digitalocean/environments'

Reply to this email directly or view it on GitHubhttps://github.com/kapilt/juju-digitalocean/issues/8#issuecomment-37638315 .

0vermind commented 10 years ago

Thanks for your effort @kapilt , looking forward to test the new version.

0vermind commented 10 years ago

Hi @kapilt, sorry for bumping the issue, but will you have some time to dedicate to the fix in the next few days? Otherwise I need to rethink of deploying on digitalocean and choose another host.

kapilt commented 10 years ago

geekmush, you don't need the fix to get going.. rm the /root/.juju/boot- digitalocean/environments directory, and then run 'juju init' or 'juju version' before using the plugin.

juju automatically generates those keys eagerly afaics as soon you do any commands. you need to be using a version of juju that's 1.17.4+

On Wed, Mar 19, 2014 at 6:59 AM, 0vermind notifications@github.com wrote:

Hi @kapilt https://github.com/kapilt, sorry for bumping the issue, but will you have some time to dedicate to the fix in the next few days? Otherwise I need to rethink of deploying on digitalocean and choose another host.

Reply to this email directly or view it on GitHubhttps://github.com/kapilt/juju-digitalocean/issues/8#issuecomment-38038351 .

0vermind commented 10 years ago

Thanks @kapilt for the hint I created a new ubuntu droplet and installed the juju:devel version. Keys are there now (in .juju/ssh I've got juju_id_rsa files) but nothing changed. When I create the droplet via juju-docean it's still asking for password.

kapilt commented 10 years ago

are you by chance on irc (freenode).. i'm hazmat on #juju. i feel like there's something getting lost in the translation, and it might be easier to just do an interactive session on this.

basically the questions are three.. do you have your the private portion of you DO key in ~/.ssh.. can you login into the instance that docean plugin launches without a password from the same machine.. and what does the api say for your keys.

kapilt commented 10 years ago

verified on irc/screenshare that the issue was the private key was not present on the client system and that with that in place things worked.