FinalsClub / karmaworld

KarmaNotes.org v3.0
GNU Affero General Public License v3.0
7 stars 6 forks source link

VM issues #335

Closed charlesconnell closed 10 years ago

charlesconnell commented 10 years ago

I'm trying to run the VM, and documenting issues that occur.

[127.0.0.1] sudo: chown charles:www-data /var/www/karmaworld/var/log/supervisord.log
[127.0.0.1] out: chown: invalid user: `charles:www-data'
btbonval commented 10 years ago

There are no docs about creating a individual user because that step isn't required.

I based the VM on staging and prod. On those systems, everything is done using the django user. On Feb 19, 2014 12:19 PM, "Charles Connell" notifications@github.com wrote:

I'm trying to run the VM, and documenting issues that occur.

  • I needed to run touch /home/charles/.ssh/config
  • first_deploy asks for login password for vagrant. I guessed that this was "vagrant".
  • Then this:

[127.0.0.1] sudo: chown charles:www-data /var/www/karmaworld/var/log/supervisord.log [127.0.0.1] out: chown: invalid user: `charles:www-data'

Reply to this email directly or view it on GitHubhttps://github.com/FinalsClub/karmaworld/issues/335 .

btbonval commented 10 years ago

Additionally, if you have fab installed on your host machine (which I do not), you'll almost never need to SSH into the VM. Just point fab at localhost port 2222 as per the README.

I should look into renaming the vagrant user to match our staging/prod systems to give it a more authentic feel.

btbonval commented 10 years ago

Eventually we should support individual users on the VM, but that won't be until #334 is taken care of on staging and prod.

btbonval commented 10 years ago

That error you're seeing reminds me of when I used to do su <username> and not su - <username>. Without the dash, the ENV is not reset, so $HOME still points at the user that ran su <username>. Since you mentioned creating a charles user, I'm guessing that's exactly what happened.

You shouldn't need the password for vagrant (I believe I set it up for passwordless sudo on the VM), but yes, the password is "vagrant". That's default set by the Vagrant software. SSH to vagrant@localhost from vagrant@localhost is passwordless using an SSH key. If fact its the same SSH key you use when you type vagrant ssh, which is labeled "insecure_private_key" or something.

VM security can actually be problematic. Unlike a server in the real world, if someone gets a VM, they have all the time in the world to brute force all system passwords offline using any means. It's far better to be as insecure as possible for ease of VM end users and because all you're doing is giving the bad guys who nab your VM a bunch of passwords in their key chain once they've cracked the VM. So we try to make passwords as banal as possible on VMs and create throwaway SSH keys.

charlesconnell commented 10 years ago

I am just following the steps in our README. I used vagrant up, and then vmfab first_deploy. No ssh.

btbonval commented 10 years ago

When you said "I needed to run touch /home/charles/.ssh/config" I thought you were doing things by hand inside the VM. I get it now, that was on your host system not the VM.

Did you run vagrant ssh-config and copy that into your config? (https://github.com/FinalsClub/karmaworld/blob/master/README.md#accessing-the-vm-via-fabric ) That sets up your ~/.ssh/config on the host system to automatically use the vagrant username when running Fabric against localhost. It looks like SSH is using your host username instead.

Check your ~/.ssh/config on the host system for this:

Host default
  HostName 127.0.0.1
  User vagrant                   # THIS LINE DOES THE THING
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/bryan/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL
btbonval commented 10 years ago

Maybe it would be more clear for the README to advise vagrant ssh-config >> ~/.ssh/config, which will create the config file if missing (so long as ~/.ssh is a thing) and appends the contents to the end of the file.

charlesconnell commented 10 years ago

Ah, I did not do that. My fault. Trying again now.

btbonval commented 10 years ago

I updated the README to be more clear. commit 0c6270123ce69e6a199a2cfb8d2af8d196e7d280

btbonval commented 10 years ago

Also I just noticed the alias alias vmfab='fab -H 127.0.0.1 --port=2222 -u vagrant' forces the username vagrant. If that was the alias you used, I'm not sure why "charles" came up at all in the VM output.

charlesconnell commented 10 years ago

The username charles is coming from env.local_user in the fabfile.

btbonval commented 10 years ago

derp. now it's my bad. Let me figure out what that variable should be. I need to install fab on my host system to test this so it'll be a minute or two.

btbonval commented 10 years ago

vmfab needed a small fix. Vagrant's ssh-config should be set to use a host identifier. README is updated. commit 0705bd71df9d0dd666efc1e657f885ab4c4e20fa

btbonval commented 10 years ago

Okay fixed env.local_user. commit d8e204a5978bd1d161f8a338ef1c3f029039731b

charlesconnell commented 10 years ago

Fix broke things.

➜  karmaworld git:(master) ✗ vmfab first_deploy
[karmavm] Executing task 'first_deploy'
Traceback (most recent call last):
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/main.py", line 736, in main
    *args, **kwargs
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/tasks.py", line 314, in execute
    multiprocessing
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/tasks.py", line 211, in _execute
    return task.run(*args, **kwargs)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/tasks.py", line 121, in run
    return self.wrapped(*args, **kwargs)
  File "/var/www/karmaworld/fabfile.py", line 265, in first_deploy
    link_code()
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/tasks.py", line 118, in __call__
    return self.run(*args, **kwargs)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/tasks.py", line 121, in run
    return self.wrapped(*args, **kwargs)
  File "/var/www/karmaworld/fabfile.py", line 93, in link_code
    if not files.exists(env.code_root):
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/contrib/files.py", line 35, in exists
    return not func(cmd).failed
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/network.py", line 528, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/operations.py", line 1002, in run
    warn_only=warn_only, stdout=stdout, stderr=stderr)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/operations.py", line 885, in _run_command
    channel=default_channel(), command=wrapped_command, pty=pty,
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/state.py", line 352, in default_channel
    chan = connections[env.host_string].get_transport().open_session()
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/network.py", line 109, in __getitem__
    self.connect(key)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/network.py", line 101, in connect
    self[key] = connect(user, host, port, sock)
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/network.py", line 343, in connect
    key_filename=key_filenames(),
  File "/var/www/karmaworld/venv/local/lib/python2.7/site-packages/fabric/network.py", line 174, in key_filenames
    return map(os.path.expanduser, keys)
  File "/var/www/karmaworld/venv/lib/python2.7/posixpath.py", line 261, in expanduser
    if not path.startswith('~'):
AttributeError: 'list' object has no attribute 'startswith'
btbonval commented 10 years ago

I've seen this error before. You in a virtualenv while running fabric? https://github.com/FinalsClub/karmaworld#completing-the-virtual-machine-with-fabric

I wish I could fix that.

charlesconnell commented 10 years ago

Nope.

On Wed 19 Feb 2014 04:06:02 PM EST, Bryan Bonvallet wrote:

I've seen this error before. You in a virtualenv while running fabric? https://github.com/FinalsClub/karmaworld#completing-the-virtual-machine-with-fabric

I wish I could fix that.

— Reply to this email directly or view it on GitHub https://github.com/FinalsClub/karmaworld/issues/335#issuecomment-35548423.

btbonval commented 10 years ago

Weird. I can create that problem 100% of the time by running fab while being inside a virtualenv, and I have otherwise never seen that error. Alright let me do some other testing.

btbonval commented 10 years ago

It looks like the line that error is caused by tilde evaluation. There's only one case of tilde evaluation. I'm going to try replacing that and I'll see if the error goes away in the usual way I cause it (fab inside venv).

btbonval commented 10 years ago

Status update: I'm chasing my own tail at this point trying to replace the tilde. Apparently env.user isn't set at the global scope, so I can't replace the ~ used to set env.repo_root until later in the fab execution. I have to look into Fabric to see what is advised.

btbonval commented 10 years ago

Status update: sorted the replacement stuff using scary stuff that kept wanting to infinitely recurse.

I'm still finding other errors because I had not previously installed fabric on my host machine. I always setup the VM with vagrant ssh; cd karmaworld; fab -H 127.0.0.1 first_deploy. That worked fine, but that's not what we want. Hacking through random problems as they come up.

btbonval commented 10 years ago

pushed fixes.

bootstrapped a VM from start to finish in 20 minutes. Debian servers were running fast today, that's a new record I think.

$ vagrant up
$ vagrant ssh-config --host karmavm >> ~/.ssh/config
$ fab -H karmavm first_deploy
dooopydoooopydooopdoop
$ 

Then I visited https://localhost:6659/. Added a course, uploaded a note. Navigated around without any failed forwards.

Setup an admin user (this is still onerous, I need to fabify it) and hopped into https://localhost:6659/moderator/. Deleted the course, which cascaded down the note and the tags on the note and all that. No problems.

Try again and let me know if there are problems. I recommend vagrant destroy for a fresh start.

btbonval commented 10 years ago

This ticket is 3 months old and no negative feedback came in, so it seems like the ticket has been addressed.