-
-
Save neidiom/3f6eff8c35e3a664da7f5b0313c6324e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run with | |
# chef-apply chef-rundeck.rb | |
require 'chef' | |
require 'chef/node' | |
require 'chef/mixin/xml_escape' | |
require 'chef/rest' | |
require 'chef/role' | |
require 'chef/environment' | |
require 'chef/data_bag' | |
require 'chef/data_bag_item' | |
require 'partial_search' | |
Chef::Config.from_file('/etc/chef/client.rb') | |
all_chef_nodes = search(:node, "*:*") | |
chef_nodes = all_chef_nodes.sort_by { |k| k.name } | |
template "/var/lib/rundeck/nodes.yaml" do | |
local true | |
source "/var/lib/rundeck/nodes.yaml.erb" | |
owner "rundeck" | |
group "adm" | |
variables(:chef_nodes => chef_nodes) | |
mode "0640" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @chef_nodes.each do |server| -%> | |
<%= server.name %>: | |
hostname: <%= server['ipaddress'] %> | |
nodename: <%= server.name %> | |
username: username | |
environment: <%= server.chef_environment %> | |
<% end -%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment