Vaprobash icon indicating copy to clipboard operation
Vaprobash copied to clipboard

Added $HOME variables for AWS vagrant deployment

Open cmosguy opened this issue 11 years ago • 28 comments

@fideloper I have updated some features for your Vaprobash. I updated the Vagrantfile template to allow a developer to deploy to an AWS ECE instance. This uses the aws-plugin for vagrant.

In order to make this work, I had to modify some of the scripts such that all /home/vagrant to $HOME. In addition, I had to change a gist reference in the nodejs.sh script to refer to my just for the same reason. Maybe we might want to consolidate this just into the repo itself as a self-contained file.

I have also implemented in the base.sh a way to create a 1G swap disk. I have found when creating an instance, we can run out of memory and the mysql databases crashes, which is a known issue.

Let me know your thoughts!

cmosguy avatar May 01 '14 23:05 cmosguy

Hey!

I have a few questions on this:

  • Are you sure $HOME still works everywhere it's been changed (tested this)? A lot of those scripts are run as root (base.sh, notably - in fact I think that might be the only one from your change set), so the mass changes of using $HOME won't necessarily work as you expect I think.
  • Changing the swap - is that AWS specific? What are you accomplishing there?
  • AWS Add-on - Neat, thanks :D

Let me know, just somethings I wanted to point out and a question on the swap change

fideloper avatar May 06 '14 15:05 fideloper

Hey @fideloper,

The whole impetus for changing to $HOME was to make it compatible for installs on AWS. The problem is when you setup an initial account on EC2 instances, the "root" or sudo user is called "ubuntu". The problem with the current scripts, they were all hard-coded with "vagrant" username. So, that is why I changed all of them to $HOME. Is there a better way here that I may not thinking about?

The swap was actually specific for AWS. The default EC2 instance has no swap, and the databases for the sites i setup on the instance crap out because of running out of memory. So I guess, you should probably leave this out, or we can copy to another script called "aws.sh" or something. That way, all AWS specific setup should go there. Should I fix this and copy over and do another PR?

cmosguy avatar May 06 '14 15:05 cmosguy

Mmm good questions then - I'm not sure on the best way to handle the AWS when the user is "ubuntu". It still looks like that's only an issue on base.sh, which needs to run as root (or a passwordless sudo user). Maybe something will come to me after lunch...

For Swap - it would be cool to test that out as a variable ("is aws"). Not sure if the best way is to include a flag to the script, or detect some environment variable to see if it's an ec2 instance. Do you know of a clean-ish way to make that test?

Continuing changes on this PR is fine, however you might want to make a new PR based on the develop branch. That might mean pulling in the latest develop and re-doing some work, as there are a few somewhat significant changes in the develop branch, which is based on Ubuntu 14.04 and will become master in the near-ish future.

fideloper avatar May 06 '14 15:05 fideloper

I just did a little googling and tested this on the EC2 instance. To test if you are actually on an EC2 instance you do this:

ec2metadata --instance-id

this is part of the cloud-utils package which is already included when you do the install with this specific ubuntu ami. We could do a regex to analyze the instance id name to tell if this is an instance, then run the swap commands.

cmosguy avatar May 06 '14 16:05 cmosguy

Howdy!

We've had some updates to the repo, and this is now creating merge conflicts. Let me know if you're interested in pursuing it as discussed (your strategy sounds good!)

fideloper avatar May 10 '14 23:05 fideloper

Hey Chris,

Sorry for the slow reply. OK, so this is what I did:

  1. I detected if using the AWS plugin and then the provisioning script will swap creation.
  2. I created a aws.sh file and placed all the swap creation for AWS in there. That way, in the future any other unique AWS contributions can go in there.

Finally, I did not do as you say about doing a PR on the develop branch for 14.04 related issues. Please let me know if this is still an issue. Let me know what else I can do here.

Thanks! Adam

cmosguy avatar May 12 '14 13:05 cmosguy

Great - however, can yo update your repository with the latest? We made a lot of changes this weekend to try to get to a 1.0 release and now this has merge conflicts since its behind after changes made this weekend/last week.

FYI, I'll likely hold off on merging this until we get somewhere stable (so I can tag a stable release for users). Then I'll begin pulling in new features (and of course bug fixes).

Thanks!

fideloper avatar May 12 '14 13:05 fideloper

oh sure i'll try that now.

On Mon, May 12, 2014 at 6:40 AM, Chris Fidao [email protected]:

Great - however, can yo update your repository with the latest? We made a lot of changes this weekend to try to get to a 1.0 release and now this has merge conflicts since its behind after changes made this weekend/last week.

FYI, I'll likely hold off on merging this until we get somewhere stable (so I can tag a stable release for users). Then I'll begin pulling in new features (and of course bug fixes).

Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/fideloper/Vaprobash/pull/296#issuecomment-42832632 .

cmosguy avatar May 12 '14 13:05 cmosguy

@fideloper I completed the following:

  1. merged all your latest updates
  2. added text to the readme.md to explain the AWS plugin

My text for now does have information on how to create an image for 12.04 LTS, are we ready to go full speed ahead for the latest 14.04?

Go ahead and do the merge, see how things go here.

Thanks, Adam

cmosguy avatar May 12 '14 17:05 cmosguy

All speed ahead on 14.04!

I need to wait on merging here until we get a stable release out (the first stable release, actually) - then I'll start adding in new features.

If you emerged this all together, then it should be running on 14.04 - this would be a good time to test that nothing changed dramatically in setting up AWS.

I'll take a look as well when I'm back in front of a computer!

On Monday, May 12, 2014, cmosguy [email protected] wrote:

@fideloper https://github.com/fideloper I completed the following:

  1. merged all your latest updates
  2. added text to the readme.md to explain the AWS plugin

My text for now does have information on how to create an image for 12.04 LTS, are we ready to go full speed ahead for the latest 14.04?

Go ahead and do the merge, see how things go here.

Thanks, Adam

— Reply to this email directly or view it on GitHubhttps://github.com/fideloper/Vaprobash/pull/296#issuecomment-42860153 .

fideloper avatar May 12 '14 17:05 fideloper

@fideloper I am seeing PHP code when logging into server. Its as though the php module in apache is not working. Do you see the same thing?

cmosguy avatar May 13 '14 04:05 cmosguy

@fideloper it looks like there was an issue with this new ubuntu 14.04 install, we need to make sure we install the module: libapache2-mod-php5 I am adding this to the php.sh file as well.

cmosguy avatar May 13 '14 16:05 cmosguy

Not using lib-apache2-mod-php is fully on purpose.

Apache and nginx both use php5-fpm, and pass php requests off to php-fpm.

Apache uses the ProxyPassMatch line found in the virtualhost created in /etc/apache2/sites-available*.xip.io.conf file - that like tells it to take php files and send them too the php process.

(Note that the path to here the php files needs to match).

I'll need to know exactly what your installing, if your starting on a fresh vagrant at box and how you're accessing the server (URL?) to try to reproduce this.

Might be good to paste me your apache vhost and Vagrantfile so I can take look.

It's more likely just a misconfiguration - perhaps something I missed where users may use php outside of the defined path in te virtualhost (or something ... )

In any case, on a new server (don't try to reprovison an old one), grab a new Vagrant file and try it out.

I'll try to do the same when I can get to a computer (doing some traveling this week for Laracon in NYC).

On Tuesday, May 13, 2014, cmosguy [email protected] wrote:

@fideloper https://github.com/fideloper it looks like there was an issue with this new ubuntu 14.04 install, we need to make sure we install the module: libapache2-mod-php5 I am adding this to the php.sh file as well.

— Reply to this email directly or view it on GitHubhttps://github.com/fideloper/Vaprobash/pull/296#issuecomment-42978886 .

fideloper avatar May 13 '14 16:05 fideloper

(Sorry if that sounds terse - I can't stand typing on my phone :D)

On Tuesday, May 13, 2014, Chris Fidao [email protected] wrote:

Not using lib-apache2-mod-php is fully on purpose.

Apache and nginx both use php5-fpm, and pass php requests off to php-fpm.

Apache uses the ProxyPassMatch line found in the virtualhost created in /etc/apache2/sites-available*.xip.io.conf file - that like tells it to take php files and send them too the php process.

(Note that the path to here the php files needs to match).

I'll need to know exactly what your installing, if your starting on a fresh vagrant at box and how you're accessing the server (URL?) to try to reproduce this.

Might be good to paste me your apache vhost and Vagrantfile so I can take look.

It's more likely just a misconfiguration - perhaps something I missed where users may use php outside of the defined path in te virtualhost (or something ... )

In any case, on a new server (don't try to reprovison an old one), grab a new Vagrant file and try it out.

I'll try to do the same when I can get to a computer (doing some traveling this week for Laracon in NYC).

On Tuesday, May 13, 2014, cmosguy <[email protected]javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:

@fideloper https://github.com/fideloper it looks like there was an issue with this new ubuntu 14.04 install, we need to make sure we install the module: libapache2-mod-php5 I am adding this to the php.sh file as well.

— Reply to this email directly or view it on GitHubhttps://github.com/fideloper/Vaprobash/pull/296#issuecomment-42978886 .

fideloper avatar May 13 '14 16:05 fideloper

@fideloper no problem I'll remove it and figure out what is going on in my setup. BTW, I heard you on the podcast the other day for laravel.io and about what your talk is about. I would be interested in hearing more about your "architecture" philosophy, but i can't make it to laracon. Let me know if you put your slides online or if it will get recorded.

cmosguy avatar May 13 '14 17:05 cmosguy

Will do!

On Tuesday, May 13, 2014, cmosguy [email protected] wrote:

@fideloper https://github.com/fideloper no problem I'll remove it and figure out what is going on in my setup. BTW, I heard you on the podcast the other day for laravel.io and about what your talk is about. I would be interested in hearing more about your "architecture" philosophy, but i can't make it to laracon. Let me know if you put your slides online or if it will get recorded.

— Reply to this email directly or view it on GitHubhttps://github.com/fideloper/Vaprobash/pull/296#issuecomment-42987493 .

fideloper avatar May 13 '14 19:05 fideloper

@fideloper i finally spent some time properly merging your updates. Here are things to note:

  1. For some reason we need > 385MB to get ruby to finish compiling locally.
  2. Mailcatcher is not working i can file a separate issue on this.
  3. AWS is working now with the installs. However, one must uncomment the section in order to use it properly. You can give it a try yourself:

curl -L https://raw.githubusercontent.com/cmosguy/Vaprobash/master/Vagrantfile > Vagrantfile

point to cmosguy repo and then uncomment the AWS section. See if you it passes your tests.

cmosguy avatar May 15 '14 14:05 cmosguy

Thanks, I'll give this a look in the near future! (Altho send me a reminder if you don't hear from me - I'm still working towards getting Vapro stable before pulling in new stuff :D )

fideloper avatar May 19 '14 12:05 fideloper

Going to merge this stuff in? Bringing it in manually to my own fork but would be nice to have it part of the upstream branch :)

amatecha avatar Jun 30 '14 02:06 amatecha

Tracking all of these changes is getting hard. Base.sh enables swap now, as needed to make some installs that reach the default memory allocated not fail upon provisioning. Is that still in place?

Github reports there are merge conflicts still, so I'm not sure how far behind this PR is.

fideloper avatar Jul 08 '14 11:07 fideloper

ping @cmosguy , think you'll get this PR up to date and merge-ready? :)

amatecha avatar Oct 18 '14 23:10 amatecha

Woops I didn't realize y'all were waiting on me. I need to essentially fetch upstream and merge and then the timeless experience of testing this :)

On Saturday, October 18, 2014, Andrew Matecha [email protected] wrote:

ping @cmosguy https://github.com/cmosguy , think you'll get this PR up to date and merge-ready? :)

— Reply to this email directly or view it on GitHub https://github.com/fideloper/Vaprobash/pull/296#issuecomment-59633512.

cmosguy avatar Oct 18 '14 23:10 cmosguy

No biggie, I'm not ultra-relying on it or anything (since I brought the changes into my own branch anyway) , but seems like a good feature to bring upstream :)

amatecha avatar Oct 23 '14 23:10 amatecha

I'm not familiar with the htaccess use there for adding a header - is https://github.com/cmosguy/Vaprobash/commit/081c3ebc20af3157232c268a0ec362275ad1c5d8#diff-f8fc67f4af770334a4a21c1277668bd2R73 missing a closing square bracket?

fideloper avatar Dec 01 '14 12:12 fideloper

Yeah, according to this documentation it does seem to be missing a closing bracket http://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_e

amatecha avatar Dec 03 '14 00:12 amatecha

@fideloper @amatecha i fixed the missing bracket, sorry about that.

So in order to get ember.js or angular.js to play nice with OAUTH2 authentication in Laravel you need to set these flags.

I am using this package: https://github.com/lucadegasperi/oauth2-server-laravel

And there was discussions here on how to implement the password grant_type system of authentication token with the server here: https://github.com/lucadegasperi/oauth2-server-laravel/issues/206

This is the only way things will work for OAUTH2. I have checked in an update to fix the bracket issue.

BTW, @fideloper you should do a webepisode or a SFH issue on how to get servers running with OAUTH2 authentication with Laravel.

cmosguy avatar Dec 03 '14 17:12 cmosguy

Is the auth heaader stuff unrelated to AWS? (so this is effectively 2 PR's?). Also, would this be needed in nginx also?

fideloper avatar Dec 03 '14 17:12 fideloper

Hey @fideloper!

  1. No, this is not related to AWS. This is a general Apache server thing that needs to be done.
  2. Forgive my ignorance on this git contribution i didn't mean to confuse this with a single PR. I have been just checking things in and pushing it to the server. I am not sure how to drive git to do different checkins as different PR's. (maybe you might know of the order of things to do this)
  3. I have not played with NGINX yet, and I am not sure about the exact details of what is required he for HTTP AUTHORIZATION headers. I would imagine there is some need for an equivalent command for the nginx. I did a little googling, and these are the instructions to enable HTTP_AUTHORIZATION headers for nginx: http://serverfault.com/questions/267670/how-to-get-nginx-to-pass-http-authorization-header-to-apache

For further explanation of requests (albeit with Laravel + Oauth2): http://www.slideshare.net/sulaeman1/your-rest-api-using-laravel see slides in there, they show the body, header, request, etc..

cmosguy avatar Dec 03 '14 22:12 cmosguy