Skip to content

Instantly share code, notes, and snippets.

@lusis
Created April 29, 2014 19:34
Show Gist options
  • Save lusis/2a99dd25fe5f56dda22c to your computer and use it in GitHub Desktop.
Save lusis/2a99dd25fe5f56dda22c to your computer and use it in GitHub Desktop.
# 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
<% @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