- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: execute bash command
- Date: Mon, 24 Nov 2014 09:49:42 -0800
On Monday, November 24, 2014 at 1:29 AM, Gareth Allen wrote:
>
Hi all,
>
>
I've written my first custom resource to remove an omd site, I'm
>
trying to include an echo in my execute statement as the application
>
requires user input. My provider looks like this:
>
>
#----------
>
action :remove do
>
execute "remove-site" do
>
command "echo -e 'yes' | /usr/bin/omd rm #{new_resource.site_name}"
>
only_if { ::File.directory?("/opt/omd/sites/#{new_resource.site_name}") }
>
end
>
end
>
#----------
>
>
Then my recipe:
>
>
#----------
>
omd_site 'test' do
>
action :remove
>
end
>
#----------
>
>
The chef-client shows the following and succeeds, but the site is
>
never removed.
>
>
- execute echo -e 'yes' | /usr/bin/omd rm test
>
>
If I run the command manually everything works as expected. Below is
>
the output.
>
>
----------
>
PLEASE NOTE: This action removes all configuration files
>
and variable data of the site.
>
>
In detail the following steps will be done:
>
- Stop all processes of the site
>
- Unmount tmpfs of the site
>
- Remove tmpfs of the site from fstab
>
- Remove the system user <SITENAME>
>
- Remove the system group <SITENAME>
>
- Remove the site home directory
>
- Restart the system wide apache daemon
>
(yes/NO): Removing Crontab...
>
no crontab for test
>
Stopping dedicated Apache for site test...(not running)...OK
>
Stopping nagios...not running...OK
>
npcd was not running... could not stop
>
Stopping rrdcached...not running.
>
Unmounting temporary filesystem...OK
>
Removing /omd/sites/test/tmp from /etc/fstab...OK
>
Deleting user and group test...OK
>
Restarting Apache...[Mon Nov 24 11:26:25.553556 2014]
>
[proxy_html:notice] [pid 25995:tid 140261059786624] AH01425: I18n
>
support in mod_proxy_html requires mod_xml2enc. Without it, non-ASCII
>
characters in proxied pages are likely to display incorrectly.
>
AH00558: apache2: Could not reliably determine the server's fully
>
qualified domain name, using 127.0.1.1. Set the 'ServerName' directive
>
globally to suppress this message
>
OK
>
----------
Is this the output you expect? Is there anything different that you see when
you run it by hand?
>
>
I assume the problem is with the echo statement. Any ideas?
Could it be something as simple as code in another recipe re-creating the
site?
If it is a problem with giving data to the command’s stdin, you could try
using mixlib-shellout’s `input` feature instead of echoing to a pipe. We were
missing API documentation for this feature, but I added some just now:
https://github.com/opscode/mixlib-shellout/pull/75
>
>
Regards,
>
Gareth
HTH,
Dan DeLeo
Archive powered by MHonArc 2.6.16.