#1

how have others accomplished this:

I just created a wrapper recipe that calls a script that runs a few custom
stuff. Here is the cookbook:

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

However, I keep getting:

Error executing action run on resource ‘execute[install ffmeg]’

STDERR: sudo: sorry, you must have a tty to run sudo

How do I go around this if the server is unknown (EC2 instance)?


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic transmission,
and any documents attached hereto, (a) are protected by the Electronic
Communications Privacy Act (18 USC §§ 2510-2521), (b) may contain
confidential and/or legally privileged information, and © are for the
sole use of the intended recipient named above. If you have received this
electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


#2

This is typical for rhel family os, as amazon linux ami are.

The solution is to comment “Default requiretty” line within /etc/sudoers.

You could simply try using Chef::Util::FileEdit search_file_replace method
in your recipe (http://rubydoc.info/gems/chef/Chef/Util/FileEdit) to
comment that line before other configurations.

Cheers,
Marco

On Thu, Jul 31, 2014 at 7:55 PM, Nikhil Shah nshah@theorchard.com wrote:

how have others accomplished this:

I just created a wrapper recipe that calls a script that runs a few custom
stuff. Here is the cookbook:

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

However, I keep getting:

Error executing action run on resource ‘execute[install ffmeg]’

STDERR: sudo: sorry, you must have a tty to run sudo

How do I go around this if the server is unknown (EC2 instance)?


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


#3

Yea, that’s im used to is disabling the requiretty but creating an AWS
instance, it’s kind of hard to when the instance doesn’t exist yet =).

I’ll def. take a look at the FileEdit and see if I can get it working that
way. Is there another preferred method of running a bash script?

On Thu, Jul 31, 2014 at 3:34 PM, Marco Betti m.betti@gmail.com wrote:

This is typical for rhel family os, as amazon linux ami are.

The solution is to comment “Default requiretty” line within /etc/sudoers.

You could simply try using Chef::Util::FileEdit search_file_replace method
in your recipe (http://rubydoc.info/gems/chef/Chef/Util/FileEdit) to
comment that line before other configurations.

Cheers,
Marco

On Thu, Jul 31, 2014 at 7:55 PM, Nikhil Shah nshah@theorchard.com wrote:

how have others accomplished this:

I just created a wrapper recipe that calls a script that runs a few
custom stuff. Here is the cookbook:

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

However, I keep getting:

Error executing action run on resource ‘execute[install ffmeg]’

STDERR: sudo: sorry, you must have a tty to run sudo

How do I go around this if the server is unknown (EC2 instance)?


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic transmission,
and any documents attached hereto, (a) are protected by the Electronic
Communications Privacy Act (18 USC §§ 2510-2521), (b) may contain
confidential and/or legally privileged information, and © are for the
sole use of the intended recipient named above. If you have received this
electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


#4

would you be able to give an example of how I would use the FileEdit? I’m
not too fond of regex esp with a mixture of ruby

On Thu, Jul 31, 2014 at 3:42 PM, Nikhil Shah nshah@theorchard.com wrote:

Yea, that’s im used to is disabling the requiretty but creating an AWS
instance, it’s kind of hard to when the instance doesn’t exist yet =).

I’ll def. take a look at the FileEdit and see if I can get it working that
way. Is there another preferred method of running a bash script?

On Thu, Jul 31, 2014 at 3:34 PM, Marco Betti m.betti@gmail.com wrote:

This is typical for rhel family os, as amazon linux ami are.

The solution is to comment “Default requiretty” line within /etc/sudoers.

You could simply try using Chef::Util::FileEdit search_file_replace
method in your recipe (http://rubydoc.info/gems/chef/Chef/Util/FileEdit)
to comment that line before other configurations.

Cheers,
Marco

On Thu, Jul 31, 2014 at 7:55 PM, Nikhil Shah nshah@theorchard.com
wrote:

how have others accomplished this:

I just created a wrapper recipe that calls a script that runs a few
custom stuff. Here is the cookbook:

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

However, I keep getting:

Error executing action run on resource ‘execute[install ffmeg]’

STDERR: sudo: sorry, you must have a tty to run sudo

How do I go around this if the server is unknown (EC2 instance)?


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic transmission,
and any documents attached hereto, (a) are protected by the Electronic
Communications Privacy Act (18 USC §§ 2510-2521), (b) may contain
confidential and/or legally privileged information, and © are for the
sole use of the intended recipient named above. If you have received this
electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


#5

I can do it tomorrow morning, now it’s 10 PM here and I left my mac at the
office, sorry :slight_smile:

Marco

On Thu, Jul 31, 2014 at 9:55 PM, Nikhil Shah nshah@theorchard.com wrote:

would you be able to give an example of how I would use the FileEdit? I’m
not too fond of regex esp with a mixture of ruby

On Thu, Jul 31, 2014 at 3:42 PM, Nikhil Shah nshah@theorchard.com wrote:

Yea, that’s im used to is disabling the requiretty but creating an AWS
instance, it’s kind of hard to when the instance doesn’t exist yet =).

I’ll def. take a look at the FileEdit and see if I can get it working
that way. Is there another preferred method of running a bash script?

On Thu, Jul 31, 2014 at 3:34 PM, Marco Betti m.betti@gmail.com wrote:

This is typical for rhel family os, as amazon linux ami are.

The solution is to comment “Default requiretty” line within /etc/sudoers.

You could simply try using Chef::Util::FileEdit search_file_replace
method in your recipe (http://rubydoc.info/gems/chef/Chef/Util/FileEdit)
to comment that line before other configurations.

Cheers,
Marco

On Thu, Jul 31, 2014 at 7:55 PM, Nikhil Shah nshah@theorchard.com
wrote:

how have others accomplished this:

I just created a wrapper recipe that calls a script that runs a few
custom stuff. Here is the cookbook:

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

However, I keep getting:

Error executing action run on resource ‘execute[install ffmeg]’

STDERR: sudo: sorry, you must have a tty to run sudo

How do I go around this if the server is unknown (EC2 instance)?


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


#6

If you give a look to:
http://docs.getchef.com/resource_ruby_block.html
youl’ll find an example (“Update the /etc/hosts file”).

regex are the same as with sed, if you are used to it.

If yout put that ruby code within a ruby block it will be run during
convergence phase, oherwise if you’ll put it outside a ruby block it will
be run during compile phase.

Marco

On Thu, Jul 31, 2014 at 10:04 PM, Marco Betti m.betti@gmail.com wrote:

I can do it tomorrow morning, now it’s 10 PM here and I left my mac at the
office, sorry :slight_smile:

Marco

On Thu, Jul 31, 2014 at 9:55 PM, Nikhil Shah nshah@theorchard.com wrote:

would you be able to give an example of how I would use the FileEdit? I’m
not too fond of regex esp with a mixture of ruby

On Thu, Jul 31, 2014 at 3:42 PM, Nikhil Shah nshah@theorchard.com
wrote:

Yea, that’s im used to is disabling the requiretty but creating an AWS
instance, it’s kind of hard to when the instance doesn’t exist yet =).

I’ll def. take a look at the FileEdit and see if I can get it working
that way. Is there another preferred method of running a bash script?

On Thu, Jul 31, 2014 at 3:34 PM, Marco Betti m.betti@gmail.com wrote:

This is typical for rhel family os, as amazon linux ami are.

The solution is to comment “Default requiretty” line within
/etc/sudoers.

You could simply try using Chef::Util::FileEdit search_file_replace
method in your recipe (http://rubydoc.info/gems/chef/Chef/Util/FileEdit)
to comment that line before other configurations.

Cheers,
Marco

On Thu, Jul 31, 2014 at 7:55 PM, Nikhil Shah nshah@theorchard.com
wrote:

how have others accomplished this:

I just created a wrapper recipe that calls a script that runs a few
custom stuff. Here is the cookbook:

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

However, I keep getting:

Error executing action run on resource ‘execute[install ffmeg]’

STDERR: sudo: sorry, you must have a tty to run sudo

How do I go around this if the server is unknown (EC2 instance)?


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


#7

@Marco,

Would I be able to add this to my existing execute recipe:

ruby_block “edit sudoers” do

block do

rc = Chef::Util::FileEdit.new("/etc/sudoers")

rc.search_file_replace_line(/^Defaults\s+requiretty/,

   "#Defaults\trequiretty")

rc.write_file

end

end

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

On Thu, Jul 31, 2014 at 4:14 PM, Marco Betti m.betti@gmail.com wrote:

If you give a look to:
http://docs.getchef.com/resource_ruby_block.html
youl’ll find an example (“Update the /etc/hosts file”).

regex are the same as with sed, if you are used to it.

If yout put that ruby code within a ruby block it will be run during
convergence phase, oherwise if you’ll put it outside a ruby block it will
be run during compile phase.

Marco

On Thu, Jul 31, 2014 at 10:04 PM, Marco Betti m.betti@gmail.com wrote:

I can do it tomorrow morning, now it’s 10 PM here and I left my mac at
the office, sorry :slight_smile:

Marco

On Thu, Jul 31, 2014 at 9:55 PM, Nikhil Shah nshah@theorchard.com
wrote:

would you be able to give an example of how I would use the FileEdit?
I’m not too fond of regex esp with a mixture of ruby

On Thu, Jul 31, 2014 at 3:42 PM, Nikhil Shah nshah@theorchard.com
wrote:

Yea, that’s im used to is disabling the requiretty but creating an AWS
instance, it’s kind of hard to when the instance doesn’t exist yet =).

I’ll def. take a look at the FileEdit and see if I can get it working
that way. Is there another preferred method of running a bash script?

On Thu, Jul 31, 2014 at 3:34 PM, Marco Betti m.betti@gmail.com wrote:

This is typical for rhel family os, as amazon linux ami are.

The solution is to comment “Default requiretty” line within
/etc/sudoers.

You could simply try using Chef::Util::FileEdit search_file_replace
method in your recipe (
http://rubydoc.info/gems/chef/Chef/Util/FileEdit) to comment that
line before other configurations.

Cheers,
Marco

On Thu, Jul 31, 2014 at 7:55 PM, Nikhil Shah nshah@theorchard.com
wrote:

how have others accomplished this:

I just created a wrapper recipe that calls a script that runs a few
custom stuff. Here is the cookbook:

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

However, I keep getting:

Error executing action run on resource ‘execute[install ffmeg]’

STDERR: sudo: sorry, you must have a tty to run sudo

How do I go around this if the server is unknown (EC2 instance)?


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/
Facebook http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic transmission,
and any documents attached hereto, (a) are protected by the Electronic
Communications Privacy Act (18 USC §§ 2510-2521), (b) may contain
confidential and/or legally privileged information, and © are for the
sole use of the intended recipient named above. If you have received this
electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


#8

Thank you all! The above actually did work.

On Thu, Jul 31, 2014 at 5:27 PM, Nikhil Shah nshah@theorchard.com wrote:

@Marco,

Would I be able to add this to my existing execute recipe:

ruby_block “edit sudoers” do

block do

rc = Chef::Util::FileEdit.new("/etc/sudoers")

rc.search_file_replace_line(/^Defaults\s+requiretty/,

   "#Defaults\trequiretty")

rc.write_file

end

end

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

On Thu, Jul 31, 2014 at 4:14 PM, Marco Betti m.betti@gmail.com wrote:

If you give a look to:
http://docs.getchef.com/resource_ruby_block.html
youl’ll find an example (“Update the /etc/hosts file”).

regex are the same as with sed, if you are used to it.

If yout put that ruby code within a ruby block it will be run during
convergence phase, oherwise if you’ll put it outside a ruby block it will
be run during compile phase.

Marco

On Thu, Jul 31, 2014 at 10:04 PM, Marco Betti m.betti@gmail.com wrote:

I can do it tomorrow morning, now it’s 10 PM here and I left my mac at
the office, sorry :slight_smile:

Marco

On Thu, Jul 31, 2014 at 9:55 PM, Nikhil Shah nshah@theorchard.com
wrote:

would you be able to give an example of how I would use the FileEdit?
I’m not too fond of regex esp with a mixture of ruby

On Thu, Jul 31, 2014 at 3:42 PM, Nikhil Shah nshah@theorchard.com
wrote:

Yea, that’s im used to is disabling the requiretty but creating an AWS
instance, it’s kind of hard to when the instance doesn’t exist yet =).

I’ll def. take a look at the FileEdit and see if I can get it working
that way. Is there another preferred method of running a bash script?

On Thu, Jul 31, 2014 at 3:34 PM, Marco Betti m.betti@gmail.com
wrote:

This is typical for rhel family os, as amazon linux ami are.

The solution is to comment “Default requiretty” line within
/etc/sudoers.

You could simply try using Chef::Util::FileEdit search_file_replace
method in your recipe (
http://rubydoc.info/gems/chef/Chef/Util/FileEdit) to comment that
line before other configurations.

Cheers,
Marco

On Thu, Jul 31, 2014 at 7:55 PM, Nikhil Shah nshah@theorchard.com
wrote:

how have others accomplished this:

I just created a wrapper recipe that calls a script that runs a few
custom stuff. Here is the cookbook:

cookbook_file “/tmp/ffmeg.sh” do

source “ffmeg.sh

mode 0755

end

execute “install ffmeg” do

command “sh /tmp/ffmeg.sh”

end

However, I keep getting:

Error executing action run on resource ‘execute[install ffmeg]’

STDERR: sudo: sorry, you must have a tty to run sudo

How do I go around this if the server is unknown (EC2 instance)?


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/
Facebook http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Ing. Marco Betti
RHCE RHEL4 id 804006512121056


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003
www.theorchard.com

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic
transmission, and any documents attached hereto, (a) are protected by the
Electronic Communications Privacy Act (18 USC §§ 2510-2521), (b) may
contain confidential and/or legally privileged information, and © are for
the sole use of the intended recipient named above. If you have received
this electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.


Nikhil ShahSystem Administrator
nshah@theorchard.comp. (+1) 212 308-5648

THE ORCHARD Distribution Done Right
23 E 4th St Fl 3, New York, NY 10003

Follow us: The Daily Rind http://www.dailyrindblog.com/ • Facebook
http://www.facebook.com/theorchard • Twitter
http://www.twitter.com/orchtweets • YouTube
http://www.youtube.com/user/theorchard • LinkedIn
http://www.linkedin.com/company/the-orchard

Privileged And Confidential Communication. This electronic transmission,
and any documents attached hereto, (a) are protected by the Electronic
Communications Privacy Act (18 USC §§ 2510-2521), (b) may contain
confidential and/or legally privileged information, and © are for the
sole use of the intended recipient named above. If you have received this
electronic message in error, please notify the sender and delete the
electronic message. Any disclosure, copying, distribution, or use of the
contents of the information received in error is strictly prohibited.