[chef] Re: Re: Run as root or as vagrant user


Chronological Thread 
  • From: Chandan Maheshwari < >
  • To: chef < >
  • Subject: [chef] Re: Re: Run as root or as vagrant user
  • Date: Sun, 12 May 2013 15:11:56 +0530

I am also having a similar kind of problem, I have my cookbook: where in my recipe, I am downloading tomcat.tar (this I have placed somewhere in my other machine). After downloading I extract the same tomcat.tar (suppose in location /home/ubuntu/tomcat). Now I am simply trying to start tomcat. I tried the below mentioned ways, but is not able to start/stop.

1) Modified the ~/.bashrc file from my recipe to export JAVA_HOME, CATALINA_HOME,
What I did is:

ran a bash script inside recipe to simply add the environment variables at the end of ~/.bashrc and then ran source ~/.bashrc

Now using "execute" resource, ran "/home/ubuntu/tomcat/bin/startup.sh"  BUT IT DO NOT START.

2) Modified the ~/.bashrc file from my recipe to export JAVA_HOME, CATALINA_HOME,
What I did is:

ran a bash script inside recipe to simply add the environment variables at the end of ~/.bashrc and then ran source ~/.bashrc

Inside bash script resource, ran "/home/ubuntu/tomcat/bin/startup.sh"  BUT IT DO NOT START.

3) Wrote a shell script and kept at the same location from where I am downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client (using resource remote_file) and then using the "execute" resource running the run_tomcat.sh.
Inside this run_tomcat.sh, I am exporting the environment variables and then running the "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.

4) Wrote a shell script and kept at the same location from where I am downloading tomcat.tar, downloaded the run_tomcat.sh on to the chef-client (using resource remote_file). Set environment variables using "environment resource" and run script using "execute" resource.
Inside this run_tomcat.sh, running the "/home/ubuntu/tomcat/bin/startup.sh"
BUT IT DO NOT START.


For point 3 and 4 above the strange thing is that other commands inside run_tomcat.sh, like extracting war, deleting some directory from the extracted war executes. BUT TOMCAT DOESN'T START UP.





On Sat, May 11, 2013 at 4:16 AM, AJ Christensen < " target="_blank"> > wrote:
Try the 'environment' parameter to the bash script resource (it's
actually from the Execute resource, but this inherits that)

bash 'foo' do
  environment 'MAVEN_OPTS' => '-Xms1024m -Xmx2048m -XX:MaxPermSize=500m'
end

etc.

Maybe consider structuring it a little different as well? Write a
shell script or similar, included in your code-base which wraps your
'mvn install', then just run that from Chef. That way you can re-run
or developers could run it if you're hooning around by hand anyway.
Just a thought :)

--AJ

On 11 May 2013 10:38, Mark H. Nichols < "> > wrote:
> I am creating a recipe to build JBoss AS 7.1.3 from source. The recipe works
> until the Maven build runs out of Java heap space. On the virtual machine
> I've set MAVEN_OPTS and JAVA_OPTS via a .bashrc file:
>
> MAVEN_OPTS='-Xms1024m -Xmx2048m -XX:MaxPermSize=500m'
>
> JAVA_OPTS='-Xms1024m -Xmx2048m -XX:MaxPermSize=512m -noverify'
>
>
> …
>
>
> export MAVEN_OPTS JAVA_OPTS …
>
>
>
> However these environment settings are for the 'vagrant' user on the VM and
> I suspect that the chef solo provisioner runs things as 'root'.
>
> I tried adding an export of JAVA_OPTS and MAVEN_OPTS to the recipe to force
> the memory setting regardless of the active user:
>
> …
>
> bash "mvn install -DskipTests" do
>
>   code <<-EOH
>
>   cd /home/vagrant/src/jbossas
>
>   export MAVEN_OPTS='-Xms1024m -Xmx2048m -XX:MaxPermSize=500m'
>
>   export JAVA_OPTS='-Xms1024m -Xmx2048m -XX:MaxPermSize=512m -noverify'
>
>   /usr/local/maven3/bin/mvn install -DskipTests -Dcheckstyle.skip=true
>
>   EOH
>
> end
> …
>
>
> But that too resulted in an "out of Java heap space" error.
>
> Obviously I am missing something. How do I ensure that my recipe has the
> heap space it requires?
>
> Thanks,
> Mark Nichols



--
Regards,
Chandan



Archive powered by MHonArc 2.6.16.

§