Chef - Repeat Recipe

Firstly, can (and this is good practice) a chef launch a recipe with a given interval for a certain role?

I have a ruby ​​script that manages user accounts and ssh identifiers, it currently runs on cron every hour, and I would like to turn it into a chef's recipe for obvious reasons (I want it to be there on all cars).

I see two ways to do this:

Or turn the script into a template, the recipe will simply display the template in the given path, and then register the cronjob

OR

Divide the script into resources, providers, etc., and let the chef run it every hour.

Ideas?

+3
source share
2 answers

chef-client ( -d, ) , upstart, runit/daemontools BluePill. cron - , :).

Chef , . , Chef , , , . , , :

package "haproxy"

service "haproxy" do
  action [:enable, :start]
end

template "/etc/haproxy/haproxy.cfg" do
  source "haproxy.cfg.erb"
end

- , . , haproxy ( , /etc/rc *.d), (, /etc/init.d/haproxy start). , , - . SHA256.

- execute, script ruby_block , - .

, - " " " " . Chef.

+8

.
:

1)

script , cronjob

( script, )

, - ... jtimberman: " , ". , .

2)

script , .., - .

- , , - , -.

, -- , - cron.

, , "", "" "" ( ssh). . : http://wiki.opscode.com/display/chef/Resources#Resources-File

"data-bag" ( json) . , opscode ( . /recipe/sysadmins.rb ): https://github.com/opscode/cookbooks/tree/master/users

, chef- ( opscode). chef-solo, "search (: users," groups: sysadmin ") , - -- ( - -repo).

+2

Source: https://habr.com/ru/post/1790297/


All Articles