Bash script block troubleshooting


#1

When chef runs a bash block it creates a “script” in the /tmp folder and
then runs it. It deletes this file when it’s done. Is there any way to
tell chef to leave it there. I have a bash block that’s failing. It runs
fine when I run it but comes back with a return code of “2” when chef runs
it and it causes everything to bomb out. I’d like to look at what it’s
running so I can a) make sure my variables are being populated properly and
b) run it, see the output and troubleshoot.

Thanks,

Mike G.


#2

mike,

add the following to your bash block, it will help u in your debugging

flags ‘-x’

this puts bash in debug mode and prints out each line after all
variables have been substituted and globs expanded

On Tue, Dec 20, 2011 at 1:10 AM, Michael Glenney mike.glenney@gmail.com wrote:

When chef runs a bash block it creates a “script” in the /tmp folder and
then runs it. It deletes this file when it’s done. Is there any way to
tell chef to leave it there. I have a bash block that’s failing. It runs
fine when I run it but comes back with a return code of “2” when chef runs
it and it causes everything to bomb out. I’d like to look at what it’s
running so I can a) make sure my variables are being populated properly and
b) run it, see the output and troubleshoot.

Thanks,

Mike G.


#3

additionally, run chef-client in debug mode

$ chef-client -l debug

On Tue, Dec 20, 2011 at 1:15 AM, Bryan Berry bryan.berry@gmail.com wrote:

mike,

add the following to your bash block, it will help u in your debugging

flags ‘-x’

this puts bash in debug mode and prints out each line after all
variables have been substituted and globs expanded

On Tue, Dec 20, 2011 at 1:10 AM, Michael Glenney mike.glenney@gmail.com wrote:

When chef runs a bash block it creates a “script” in the /tmp folder and
then runs it. It deletes this file when it’s done. Is there any way to
tell chef to leave it there. I have a bash block that’s failing. It runs
fine when I run it but comes back with a return code of “2” when chef runs
it and it causes everything to bomb out. I’d like to look at what it’s
running so I can a) make sure my variables are being populated properly and
b) run it, see the output and troubleshoot.

Thanks,

Mike G.


#4

Awesome. I’ll try it tonight. Didn’t know I could use that with chef.

Michael Glenney
Sent from my iPhone

On Dec 19, 2011, at 5:15 PM, Bryan Berry bryan.berry@gmail.com wrote:

mike,

add the following to your bash block, it will help u in your debugging

flags ‘-x’

this puts bash in debug mode and prints out each line after all
variables have been substituted and globs expanded

On Tue, Dec 20, 2011 at 1:10 AM, Michael Glenney mike.glenney@gmail.com wrote:

When chef runs a bash block it creates a “script” in the /tmp folder and
then runs it. It deletes this file when it’s done. Is there any way to
tell chef to leave it there. I have a bash block that’s failing. It runs
fine when I run it but comes back with a return code of “2” when chef runs
it and it causes everything to bomb out. I’d like to look at what it’s
running so I can a) make sure my variables are being populated properly and
b) run it, see the output and troubleshoot.

Thanks,

Mike G.


#5

Hi all!

I’m an avid chef user and recent convert to the chef way and ruby way. I’m a frequent reader of the list, but this is my first post, so if this is out of line for this list, let me know and I’ll post my question elsewhere.

I’m looking for a good cookbook for use with chef for a simple local DNS solution. Basically, what I want is to be able to do this (or something similar):

nodes=search(:nodes,"*:")
nodes.each do |n|
dns_server “add-n-to-dns-server” do
name n[:server_name] + “.” + node.chef_environment # e.g. server001.testing
type "host"
ipaddress n[:ipaddress]
action :add
not_if # or have the dns provider handle this provision
done
done

Then point my local servers to use the server running this cookbook as their primary DNS for local resolution

I’ve been toying with djbdns all day, but it isn’t working as advertised. One, it isn’t centos ready, and the bluepill code isn’t finished for the server config. Is there a simple DNS cookbook that’s pre-baked that might work for me? I’m even willing to use bind if it “just works”.

Thanks in advance. And for all the developers who read this list, thank you for all you do. Chef is great!

Best,
Vincent


#6

Try this dnsimple cookbook, it uses the API to add records.

https://github.com/heavywater/chef-dnsimple

–AJ

On 20 December 2011 17:11, Vincent Jorgensen
vincent.jorgensen@incentivenetworks.com wrote:

Hi all!

I’m an avid chef user and recent convert to the chef way and ruby way. I’m a frequent reader of the list, but this is my first post, so if this is out of line for this list, let me know and I’ll post my question elsewhere.

I’m looking for a good cookbook for use with chef for a simple local DNS solution. Basically, what I want is to be able to do this (or something similar):

nodes=search(:nodes,"*:")
nodes.each do |n|
dns_server “add-n-to-dns-server” do
name n[:server_name] + “.” + node.chef_environment # e.g. server001.testing
type "host"
ipaddress n[:ipaddress]
action :add
not_if # or have the dns provider handle this provision
done
done

Then point my local servers to use the server running this cookbook as their primary DNS for local resolution

I’ve been toying with djbdns all day, but it isn’t working as advertised. One, it isn’t centos ready, and the bluepill code isn’t finished for the server config. Is there a simple DNS cookbook that’s pre-baked that might work for me? I’m even willing to use bind if it “just works”.

Thanks in advance. And for all the developers who read this list, thank you for all you do. Chef is great!

Best,
Vincent


#7

Not a bad idea… if I could move where the domains are hosts I cannot :frowning: We are a GoDaddy shop for our public-facing enterprise. This just needs to be something to replace the Windows Server DNS that my predecessors left me.

On Dec 19, 2011, at 8:17 PM, AJ Christensen wrote:

Try this dnsimple cookbook, it uses the API to add records.

https://github.com/heavywater/chef-dnsimple

–AJ

On 20 December 2011 17:11, Vincent Jorgensen
vincent.jorgensen@incentivenetworks.com wrote:

Hi all!

I’m an avid chef user and recent convert to the chef way and ruby way. I’m a frequent reader of the list, but this is my first post, so if this is out of line for this list, let me know and I’ll post my question elsewhere.

I’m looking for a good cookbook for use with chef for a simple local DNS solution. Basically, what I want is to be able to do this (or something similar):

nodes=search(:nodes,"*:")
nodes.each do |n|
dns_server “add-n-to-dns-server” do
name n[:server_name] + “.” + node.chef_environment # e.g. server001.testing
type "host"
ipaddress n[:ipaddress]
action :add
not_if # or have the dns provider handle this provision
done
done

Then point my local servers to use the server running this cookbook as their primary DNS for local resolution

I’ve been toying with djbdns all day, but it isn’t working as advertised. One, it isn’t centos ready, and the bluepill code isn’t finished for the server config. Is there a simple DNS cookbook that’s pre-baked that might work for me? I’m even willing to use bind if it “just works”.

Thanks in advance. And for all the developers who read this list, thank you for all you do. Chef is great!

Best,
Vincent


#8

On Dec 20, 2011, at 5:11 AM, Vincent Jorgensen vincent.jorgensen@incentivenetworks.com wrote:

Hi all!

I’m an avid chef user and recent convert to the chef way and ruby way. I’m a frequent reader of the list, but this is my first post, so if this is out of line for this list, let me know and I’ll post my question elsewhere.

I’m looking for a good cookbook for use with chef for a simple local DNS solution. Basically, what I want is to be able to do this (or something similar):

nodes=search(:nodes,"*:")
nodes.each do |n|
dns_server “add-n-to-dns-server” do
name n[:server_name] + “.” + node.chef_environment # e.g. server001.testing
type "host"
ipaddress n[:ipaddress]
action :add
not_if # or have the dns provider handle this provision
done
done

Then point my local servers to use the server running this cookbook as their primary DNS for local resolution

I’ve been toying with djbdns all day, but it isn’t working as advertised. One, it isn’t centos ready, and the bluepill code isn’t finished for the server config. Is there a simple DNS cookbook that’s pre-baked that might work for me? I’m even willing to use bind if it “just works”.

Have a look at the latest versions of the djbdns and bluepill cookbooks on github github.com/opscode/cookbooks
There have been some recent commits to fix exactly this, and I’m not sure they have been released yet.

Once you get past the bluepill issue, depending on your usage pattern you may run into other problems.
We have been using djbdns for our HQ (private) DNS for months and it works; but we have local patches.

I have been looking at merging those backs, but I would love some external testing first. If you are willing to try, I can clean those up and send them to you. If they work for you I will take care of getting them merged.

Andrea

Thanks in advance. And for all the developers who read this list, thank you for all you do. Chef is great!

Best,
Vincent